203 lines
9.0 KiB
JavaScript
203 lines
9.0 KiB
JavaScript
import useTranslation from "next-translate/useTranslation";
|
|
import { useRouter } from "next/router";
|
|
import _ from "lodash";
|
|
|
|
const RepsOnResults = (props) => {
|
|
let { t } = useTranslation();
|
|
|
|
const detailsObj = props.detailsObj;
|
|
|
|
function showReps(startDate, endDate) {
|
|
let date = new Date();
|
|
date = new Date(date.toDateString());
|
|
const start = new Date(startDate);
|
|
const end = new Date(endDate);
|
|
|
|
return date >= start && date <= end ? true : false;
|
|
}
|
|
|
|
function showRepButton(appealType) {
|
|
switch (appealType) {
|
|
case 846040012:
|
|
case 846040013:
|
|
case 846040014:
|
|
//for ROW case 846040015:
|
|
case 846040020:
|
|
case 846040021:
|
|
case 846040023:
|
|
case 846040024:
|
|
return false;
|
|
case 846040004:
|
|
return isLPA ? true : false;
|
|
|
|
case 846040015:
|
|
return props.searchDetailsObj[0].value[0]
|
|
.pinswg_specialistcaseprocess == 846040001
|
|
? showReps(
|
|
props.searchDetailsObj[0].value[0].pinswg_startdate,
|
|
props.searchDetailsObj[0].value[0]
|
|
.pinswg_finalcommentsduedate
|
|
)
|
|
: true;
|
|
|
|
case 846040018:
|
|
let shouldShow =
|
|
props.searchDetailsObj[0].value[0]
|
|
.pinswg_speacialistcaseprocess == 846040000 && isLPA
|
|
? true
|
|
: props.searchDetailsObj[0].value[0]
|
|
.pinswg_speacialistcaseprocess == 846040001
|
|
? true
|
|
: false;
|
|
|
|
return shouldShow;
|
|
|
|
case 846040019:
|
|
return showReps(
|
|
props.searchDetailsObj[0].value[0].pinswg_startdate,
|
|
props.searchDetailsObj[0].value[0].pinswg_statementduedate
|
|
);
|
|
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
function showRepsEnded(startDate, endDate) {
|
|
let date = new Date();
|
|
date = new Date(date.toDateString());
|
|
const start = new Date(startDate);
|
|
const end = new Date(endDate);
|
|
return date > start && date > end ? true : false;
|
|
}
|
|
|
|
function formatDates(dateObj, showTime) {
|
|
var dateObj = new Date(dateObj);
|
|
var dd = String(dateObj.getDate()).padStart(2, "0");
|
|
var mm = String(dateObj.getMonth() + 1).padStart(2, "0"); //January is 0!
|
|
var yyyy = dateObj.getFullYear();
|
|
var hh = dateObj.getHours();
|
|
hh = ("0" + hh).slice(-2);
|
|
var mins = dateObj.getMinutes();
|
|
mins = ("0" + mins).slice(-2);
|
|
|
|
const dateStr = showTime
|
|
? hh == 0 && mins == 0
|
|
? ""
|
|
: hh + ":" + mins
|
|
: dd + "/" + mm + "/" + yyyy + " ";
|
|
return dateStr;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<br />
|
|
{(_.has(detailsObj, "pinswg_startdate") ||
|
|
_.has(detailsObj, "pinswg_applicationacceptedasvalid") ||
|
|
_.has(detailsObj, "pinswg_consultationopen")) &&
|
|
showReps(
|
|
detailsObj.pinswg_startdate ||
|
|
detailsObj.pinswg_applicationacceptedasvalid ||
|
|
detailsObj.pinswg_consultationopen,
|
|
detailsObj.pinswg_finalcommentsduedate ||
|
|
detailsObj.pinswg_endofrepresentationperiod ||
|
|
detailsObj.pinswg_consultationclose
|
|
) && (
|
|
<>
|
|
{showRepButton(detailsObj.appealType) ? (
|
|
<>
|
|
{/* <Link
|
|
href={{
|
|
pathname:
|
|
"/myportal/representation",
|
|
query: {
|
|
case: detailsObj.pinswg_name,
|
|
},
|
|
}}
|
|
className="govuk-button"
|
|
>
|
|
{t(
|
|
"case:summary-make-representation-label"
|
|
)}
|
|
</Link> */}
|
|
<div className="govuk-body govuk-!-font-size-14">
|
|
{props.appealType == 846040002
|
|
? t(
|
|
"case:summary-consultation-open-label"
|
|
)
|
|
: t(
|
|
"case:summary-representation-open-label"
|
|
)}{" "}
|
|
</div>
|
|
</>
|
|
) : !isLPA &&
|
|
props.currentView.caseReference.appealType ==
|
|
846040004 ? (
|
|
""
|
|
) : (
|
|
<>
|
|
<div className="govuk-grid-column-full govuk-!-padding-left-0">
|
|
<div className="govuk-button-group">
|
|
<p className="govuk-body">
|
|
{t(
|
|
"case:representation-date-passed-label",
|
|
{
|
|
startDate: formatDates(
|
|
detailsObj.pinswg_startdate
|
|
),
|
|
endDate:
|
|
props.currentView
|
|
.caseReference
|
|
.appealType ==
|
|
846040019
|
|
? formatDates(
|
|
detailsObj.pinswg_statementduedate
|
|
)
|
|
: formatDates(
|
|
detailsObj.pinswg_finalcommentsduedate
|
|
),
|
|
}
|
|
)}
|
|
<br />{" "}
|
|
{t(
|
|
"case:representation-date-passed-additional-label"
|
|
)}{" "}
|
|
<Link
|
|
href={
|
|
"mailto:" +
|
|
t(
|
|
"home:login-contact-email"
|
|
)
|
|
}
|
|
>
|
|
{t("home:login-contact-email")}
|
|
</Link>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</>
|
|
)}
|
|
</>
|
|
)}{" "}
|
|
{_.has(detailsObj, "pinswg_startdate") &&
|
|
(detailsObj.pinswg_startdate != null ||
|
|
detailsObj.pinswg_finalcommentsduedate != null) &&
|
|
showRepsEnded(
|
|
detailsObj.pinswg_startdate,
|
|
detailsObj.pinswg_finalcommentsduedate
|
|
) && (
|
|
<div className="govuk-body govuk-!-font-size-14">
|
|
{t("case:representation-period-ended-on-label")}
|
|
{detailsObj.appealType == 846040019
|
|
? formatDates(detailsObj.pinswg_statementduedate)
|
|
: formatDates(
|
|
detailsObj.pinswg_finalcommentsduedate
|
|
)}
|
|
</div>
|
|
)}
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default RepsOnResults;
|