import { resolveRepresentationWindow, isRepresentationWindowOpen, isRepresentationWindowClosed, canShowRepresentationButtonForAppealType, canStartHouseholderRepresentation, canStartCpoRepresentation } from "../../../../lib/domain/representation-policy"; export function showRepsLocal(startDate, endDate) { return isRepresentationWindowOpen(startDate, endDate); } export function showRepsEndedLocal(startDate, endDate) { return isRepresentationWindowClosed(startDate, endDate); } export function isConsultationWindowOpen(detailsObj) { return showRepsLocal( detailsObj.pinswg_consultationopen, detailsObj.pinswg_consultationclose ); } export function isGeneralRepresentationWindowOpen(detailsObj) { return resolveRepresentationWindow(detailsObj).isOpen; } export function canShowRepButtonForAppealType({ appealType, isLPA, searchDetailsObj }) { if (!canShowRepresentationButtonForAppealType(appealType)) { return false; } switch (appealType) { case 846040004: return canStartHouseholderRepresentation(appealType, isLPA); case 846040015: return searchDetailsObj[0].value[0].pinswg_specialistcaseprocess == 846040001 ? showRepsLocal( searchDetailsObj[0].value[0].pinswg_startdate, searchDetailsObj[0].value[0].pinswg_finalcommentsduedate ) : true; case 846040018: let shouldShow = searchDetailsObj[0].value[0].pinswg_speacialistcaseprocess == 846040000 && isLPA ? true : searchDetailsObj[0].value[0] .pinswg_speacialistcaseprocess == 846040001 ? true : false; return shouldShow; case 846040019: return canStartCpoRepresentation( appealType, searchDetailsObj[0].value[0] ); default: return true; } } export function getEntryCtaLabelKey(appealType) { return appealType == 846040002 ? "case:summary-make-consultation-label" : "case:summary-make-representation-label"; } export function shouldSuppressBlockedMessage({ appealType, isLPA }) { return !isLPA && appealType == 846040004; } export function getGeneralBlockedEndDate(detailsObj, appealType) { return appealType == 846040019 ? detailsObj.pinswg_statementduedate : detailsObj.pinswg_finalcommentsduedate; } export function isRepresentationPeriodEnded(detailsObj) { return showRepsEndedLocal( detailsObj.pinswg_startdate, detailsObj.pinswg_finalcommentsduedate ); }