Merged PR 2283: Data driven status pages from CRM

Related work items: #22805
This commit is contained in:
Robert Bond
2026-04-29 15:29:54 +00:00
parent 1fd192b870
commit baf5b1838d
20 changed files with 1079 additions and 42 deletions
+23 -35
View File
@@ -4,6 +4,7 @@ import { connect } from "react-redux";
import useTranslation from "next-translate/useTranslation";
import { formatDates } from "../utils";
import { useState } from "react";
import { getStagesForAppealType } from "./summary/utils/caseStagesByAppealType";
const statusClassMap = {
complete: "govuk-tag govuk-!-margin-top-2",
@@ -13,41 +14,19 @@ const statusClassMap = {
};
const statusTextMap = {
complete: "Complete",
"in-progress": "In progress",
"not-started": "Not started",
blocked: "Blocked"
complete: "status-complete",
"in-progress": "status-in-progress",
"not-started": "status-not-started",
blocked: "status-blocked"
};
const StatusDetails = (props) => {
let { t } = useTranslation();
const stages = [
{
id: "application-received",
title: "Application received",
status: "complete",
href: "#",
description:
"We have received the case and checked that the initial information has been provided."
},
{
id: "consultation",
title: "Consultation period",
status: "in-progress",
href: "#",
description:
"People can view the case documents and submit comments during this stage."
},
{
id: "decision",
title: "Decision",
status: "not-started",
href: "#",
description:
"The decision will be published once the case has been reviewed and completed."
}
];
const stages = getStagesForAppealType(
props.currentView?.caseReference?.appealType,
props.currentView?.caseReference?.statuscode
);
const EventView = (eventsArr) => {
eventsArr = eventsArr.value;
@@ -105,18 +84,22 @@ const StatusDetails = (props) => {
key={stage.id}
>
<div className="govuk-task-list__name-and-hint">
{stage.description && (
{stage.descriptionKey && (
<details
className="govuk-details govuk-!-margin-top-2 govuk-!-margin-bottom-2"
open={isOpen}
>
<summary className="govuk-details__summary">
<span className="govuk-details__summary-text">
{stage.title}
{t(
`case-stages:${stage.titleKey}`
)}
</span>
</summary>
<div className="govuk-details__text">
{stage.description}
{t(
`case-stages:${stage.descriptionKey}`
)}
</div>
</details>
)}
@@ -132,8 +115,13 @@ const StatusDetails = (props) => {
"govuk-tag govuk-tag--grey govuk-!-margin-top-2"
}
>
{statusTextMap[stage.status] ||
"Not started"}
{t(
`case-stages:${
statusTextMap[
stage.status
] || "status-not-started"
}`
)}
</strong>
</div>
</li>
@@ -0,0 +1,836 @@
const slugify = (value) =>
value
.toString()
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-|-$/g, "");
const buildStages = (stages) =>
stages.map((stage) => ({
id: slugify(stage.titleKey),
...stage
}));
export const stagesByCaseType = {
DNS: buildStages([
{
stageId: 846040001,
titleKey: "pre-application",
descriptionKey: "pre-application-desc"
},
{
stageId: 846040002,
titleKey: "environmental-impact-assessment-scoping",
descriptionKey: "environmental-impact-assessment-scoping-desc"
},
{
stageId: 846040003,
titleKey: "notification",
descriptionKey: "notification-desc"
},
{
stageId: 846040004,
titleKey: "acceptance-checking",
descriptionKey: "acceptance-checking-desc"
},
{
stageId: 846040005,
titleKey: "invalid-submission",
descriptionKey: "invalid-submission-desc"
},
{
stageId: 846040006,
titleKey: "consultation",
descriptionKey: "consultation-desc"
},
{
stageId: 846040007,
titleKey: "re-consultation",
descriptionKey: "re-consultation-desc"
},
{
stageId: 846040008,
titleKey: "reporting",
descriptionKey: "reporting-desc"
},
{
stageId: 846040009,
titleKey: "inspectors-decision",
descriptionKey: "inspectors-decision-desc"
},
{
stageId: 846040011,
titleKey: "report-to-ministers",
descriptionKey: "report-to-ministers-desc"
},
{
stageId: 846040012,
titleKey: "minister-s-decision",
descriptionKey: "minister-s-decision-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
]),
SIP: "DNS",
PLANNING_S78: buildStages([
{
stageId: 846040014,
titleKey: "appeal-submitted",
descriptionKey: "appeal-submitted-desc"
},
{
stageId: 846040015,
titleKey: "appeal-registered",
descriptionKey: "appeal-registered-desc"
},
{
stageId: 846040016,
titleKey: "appeal-validated",
descriptionKey: "appeal-validated-desc"
},
{
stageId: 1,
titleKey: "case-in-progress",
descriptionKey: "case-in-progress-desc"
},
{
stageId: 846040017,
titleKey: "questionnaire-lpa-to-notify",
descriptionKey: "questionnaire-lpa-to-notify-desc"
},
{
stageId: 846040018,
titleKey: "representations-period",
descriptionKey: "representations-period-desc"
},
{
stageId: 846040019,
titleKey: "final-comments",
descriptionKey: "final-comments-desc"
},
{
stageId: 846040020,
titleKey: "event",
descriptionKey: "event-desc"
},
{
stageId: 846040021,
titleKey: "site-visit",
descriptionKey: "site-visit-desc"
},
{
stageId: 846040022,
titleKey: "decision-issued",
descriptionKey: "decision-issued-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
]),
CONDITIONS_73_79: "PLANNING_S78",
LBCAC: "PLANNING_S78",
LDCS: "PLANNING_S78",
PLANNING_OBLIGATIONS_S106: "PLANNING_S78",
PRIOR_NOTIFICATION: "PLANNING_S78",
HAS: buildStages([
{
stageId: 846040014,
titleKey: "appeal-submitted",
descriptionKey: "appeal-submitted-desc"
},
{
stageId: 846040015,
titleKey: "appeal-registered",
descriptionKey: "appeal-registered-desc"
},
{
stageId: 846040016,
titleKey: "appeal-validated",
descriptionKey: "appeal-validated-desc"
},
{
stageId: 1,
titleKey: "case-in-progress",
descriptionKey: "case-in-progress-desc"
},
{
stageId: 846040021,
titleKey: "site-visit",
descriptionKey: "site-visit-desc"
},
{
stageId: 846040022,
titleKey: "decision-issued",
descriptionKey: "decision-issued-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
]),
CALL_INS: buildStages([
{
stageId: 846040023,
titleKey: "application-called-in",
descriptionKey: "application-called-in-desc"
},
{
stageId: 846040043,
titleKey: "application-registered",
descriptionKey: "application-registered-desc"
},
{
stageId: 846040024,
titleKey: "application-validated",
descriptionKey: "application-validated-desc"
},
{
stageId: 1,
titleKey: "case-in-progress",
descriptionKey: "case-in-progress-desc"
},
{
stageId: 846040025,
titleKey: "lpa-to-notify",
descriptionKey: "lpa-to-notify-desc"
},
{
stageId: 846040026,
titleKey: "representations-period",
descriptionKey: "representations-period-desc"
},
{
stageId: 846040019,
titleKey: "final-comments",
descriptionKey: "final-comments-desc"
},
{
stageId: 846040020,
titleKey: "event",
descriptionKey: "event-desc"
},
{
stageId: 846040021,
titleKey: "site-visit",
descriptionKey: "site-visit-desc"
},
{
stageId: 846040028,
titleKey: "report-issued-to-welsh-ministers",
descriptionKey: "report-issued-to-welsh-ministers-desc"
},
{
stageId: 846040012,
titleKey: "minister-s-decision",
descriptionKey: "minister-s-decision-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
]),
ENFORCEMENT: buildStages([
{
stageId: 846040014,
titleKey: "appeal-submitted",
descriptionKey: "appeal-submitted-desc"
},
{
stageId: 846040015,
titleKey: "appeal-registered",
descriptionKey: "appeal-registered-desc"
},
{
stageId: 846040029,
titleKey: "fee-due",
descriptionKey: "fee-due-desc"
},
{
stageId: 846040030,
titleKey: "validated",
descriptionKey: "appeal-validated-desc"
},
{
stageId: 1,
titleKey: "case-in-progress",
descriptionKey: "case-in-progress-desc"
},
{
stageId: 846040017,
titleKey: "questionnaire-lpa-to-notify",
descriptionKey: "questionnaire-lpa-to-notify-desc"
},
{
stageId: 846040018,
titleKey: "representations-period",
descriptionKey: "representations-period-desc"
},
{
stageId: 846040019,
titleKey: "final-comments",
descriptionKey: "final-comments-desc"
},
{
stageId: 846040020,
titleKey: "event",
descriptionKey: "event-desc"
},
{
stageId: 846040021,
titleKey: "site-visit",
descriptionKey: "site-visit-desc"
},
{
stageId: 846040022,
titleKey: "decision-issued",
descriptionKey: "decision-issued-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
]),
ENFORCEMENT_LISTED_BUILDING: "ENFORCEMENT",
MAINTENANCE_OF_LAND: "ENFORCEMENT",
RIGHTS_OF_WAY_SCHEDULE_14: buildStages([
{
stageId: 846040014,
titleKey: "appeal-submitted",
descriptionKey: "appeal-submitted-desc"
},
{
stageId: 846040015,
titleKey: "appeal-registered",
descriptionKey: "appeal-registered-desc"
},
{
stageId: 846040016,
titleKey: "appeal-validated",
descriptionKey: "appeal-validated-desc"
},
{
stageId: 846040031,
titleKey: "appeal-start-case-in-progress",
descriptionKey: "case-in-progress-desc"
},
{
stageId: 846040032,
titleKey: "statements-representations-period",
descriptionKey: "statements-representations-period-desc"
},
{
stageId: 846040019,
titleKey: "final-comments",
descriptionKey: "final-comments-desc"
},
{
stageId: 846040021,
titleKey: "site-visit",
descriptionKey: "site-visit-desc"
},
{
stageId: 846040022,
titleKey: "decision-issued",
descriptionKey: "decision-issued-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
]),
RIGHTS_OF_WAY_ORDERS: buildStages([
{
stageId: 846040033,
titleKey: "order-submitted",
descriptionKey: "order-submitted-desc"
},
{
stageId: 846040034,
titleKey: "order-submission-registered",
descriptionKey: "order-submission-registered-desc"
},
{
stageId: 846040035,
titleKey: "order-submission-validated",
descriptionKey: "order-submission-validated-desc"
},
{
stageId: 846040036,
titleKey: "case-started-case-in-progress",
descriptionKey: "case-started-case-in-progress-desc"
},
{
stageId: 846040010,
titleKey: "statements",
descriptionKey: "statements-desc"
},
{
stageId: 846040019,
titleKey: "final-comments",
descriptionKey: "final-comments-desc"
},
{
stageId: 846040037,
titleKey: "event-site-visit",
descriptionKey: "event-site-visit-desc"
},
{
stageId: 846040022,
titleKey: "decision-issued",
descriptionKey: "decision-issued-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
]),
REQUESTS_FOR_DIRECTION: buildStages([
{
stageId: 846040042,
titleKey: "application-submitted",
descriptionKey: "application-submitted-desc"
},
{
stageId: 846040043,
titleKey: "application-registered",
descriptionKey: "application-registered-desc"
},
{
stageId: 846040036,
titleKey: "application-start-case-in-progress",
descriptionKey: "application-start-case-in-progress-desc"
},
{
stageId: 846040010,
titleKey: "statements",
descriptionKey: "statements-desc"
},
{
stageId: 846040019,
titleKey: "final-comments",
descriptionKey: "statements-desc"
},
{
stageId: 846040022,
titleKey: "decision-issued",
descriptionKey: "decision-issued-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
]),
ADVERTS: buildStages([
{
stageId: 846040014,
titleKey: "appeal-submitted",
descriptionKey: "appeal-submitted-desc"
},
{
stageId: 846040015,
titleKey: "appeal-registered",
descriptionKey: "appeal-registered-desc"
},
{
stageId: 846040016,
titleKey: "appeal-validated",
descriptionKey: "appeal-validated-desc"
},
{
stageId: 1,
titleKey: "case-started-case-in-progress",
descriptionKey: "case-in-progress-desc"
},
{
stageId: 846040017,
titleKey: "questionnaire-lpa-to-notify",
descriptionKey: "questionnaire-lpa-to-notify-desc"
},
{
stageId: 846040010,
titleKey: "statements",
descriptionKey: "statements-desc"
},
{
stageId: 846040019,
titleKey: "final-comments",
descriptionKey: "final-comments-desc"
},
{
stageId: 846040021,
titleKey: "site-visit",
descriptionKey: "site-visit-desc"
},
{
stageId: 846040022,
titleKey: "decision-issued",
descriptionKey: "decision-issued-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
]),
HEDGEROW_TPO: buildStages([
{
stageId: 846040014,
titleKey: "appeal-submitted",
descriptionKey: "appeal-submitted-desc"
},
{
stageId: 846040015,
titleKey: "appeal-registered",
descriptionKey: "appeal-registered-desc"
},
{
stageId: 846040016,
titleKey: "appeal-validated",
descriptionKey: "appeal-validated-desc"
},
{
stageId: 846040031,
titleKey: "appeal-start-case-in-progress",
descriptionKey: "case-in-progress-desc"
},
{
stageId: 846040017,
titleKey: "questionnaire-lpa-to-notify",
descriptionKey: "questionnaire-lpa-to-notify-desc"
},
{
stageId: 846040032,
titleKey: "statements-representations-period",
descriptionKey: "statements-representations-period-desc"
},
{
stageId: 846040019,
titleKey: "final-comments",
descriptionKey: "final-comments-desc"
},
{
stageId: 846040021,
titleKey: "site-visit",
descriptionKey: "site-visit-desc"
},
{
stageId: 846040022,
titleKey: "decision-issued",
descriptionKey: "decision-issued-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
]),
COMMON_LAND: buildStages([
{
stageId: 846040042,
titleKey: "application-submitted",
descriptionKey: "application-submitted-desc"
},
{
stageId: 846040043,
titleKey: "application-registered",
descriptionKey: "application-registered-desc"
},
{
stageId: 846040024,
titleKey: "application-validated",
descriptionKey: "application-validated-desc"
},
{
stageId: 1,
titleKey: "application-start-case-in-progress",
descriptionKey: "application-start-case-in-progress-desc"
},
{
stageId: 846040038,
titleKey: "applicant-statement-on-representations",
descriptionKey: "applicant-statement-on-representations-desc"
},
{
stageId: 846040039,
titleKey: "representatives-comment",
descriptionKey: "representatives-comment-desc"
},
{
stageId: 846040027,
titleKey: "applicants-final-comment",
descriptionKey: "applicants-final-comment-desc"
},
{
stageId: 846040037,
titleKey: "event-site-visit",
descriptionKey: "event-site-visit-desc"
},
{
stageId: 846040022,
titleKey: "decision-issued",
descriptionKey: "decision-issued-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
]),
COMPULSORY_PURCHASE_ORDERS: buildStages([
{
stageId: 846040033,
titleKey: "order-submitted",
descriptionKey: "order-submitted-desc"
},
{
stageId: 846040040,
titleKey: "order-registered",
descriptionKey: "order-submission-registered-desc"
},
{
stageId: 846040041,
titleKey: "order-validated",
descriptionKey: "order-submission-validated-desc"
},
{
stageId: 1,
titleKey: "case-in-progress",
descriptionKey: "case-started-case-in-progress-desc"
},
{
stageId: 846040010,
titleKey: "statements",
descriptionKey: "statements-desc"
},
{
stageId: 846040019,
titleKey: "final-comments",
descriptionKey: "final-comments-desc"
},
{
stageId: 846040037,
titleKey: "event-site-visit",
descriptionKey: "event-site-visit-desc"
},
{
stageId: 846040011,
titleKey: "report-to-ministers",
descriptionKey: "report-to-ministers-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
]),
ELECTRICITY_ACT: "PLANNING_S78",
HARBOUR_REVISION_ORDER: "COMPULSORY_PURCHASE_ORDERS",
TRANSPORT_WORKS: "PLANNING_S78",
WAYLEAVE: buildStages([
{
stageId: 846040042,
titleKey: "application-submitted",
descriptionKey: "application-submitted-desc"
},
{
stageId: 846040043,
titleKey: "application-registered",
descriptionKey: "application-registered-desc"
},
{
stageId: 846040024,
titleKey: "application-validated",
descriptionKey: "application-validated-desc"
},
{
stageId: 1,
titleKey: "case-in-progress",
descriptionKey: "application-start-case-in-progress-desc"
},
{
stageId: 846040021,
titleKey: "site-visit",
descriptionKey: "site-visit-desc"
},
{
stageId: 846040044,
titleKey: "report-to-desnz",
descriptionKey: "report-to-desnz-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
]),
NON_VALIDATION: buildStages([
{
stageId: 846040014,
titleKey: "appeal-submitted",
descriptionKey: "appeal-submitted-desc"
},
{
stageId: 846040015,
titleKey: "appeal-registered",
descriptionKey: "appeal-registered-desc"
},
{
stageId: 846040016,
titleKey: "appeal-validated",
descriptionKey: "appeal-validated-desc"
},
{
stageId: 1,
titleKey: "case-in-progress-assessment",
descriptionKey: "case-in-progress-desc"
},
{
stageId: 846040022,
titleKey: "decision-outcome",
descriptionKey: "decision-outcome-desc"
},
{
stageId: 846040013,
titleKey: "case-closed",
descriptionKey: "case-closed-desc"
}
])
};
export const caseTypeAliases = {
// Planning S78 group
S78: "PLANNING_S78",
PLANNING_78: "PLANNING_S78",
PLANNING_S78: "PLANNING_S78",
CONDITIONS_73_79: "CONDITIONS_73_79",
LBCAC: "LBCAC",
LDCS: "LDCS",
PLANNING_OBLIGATIONS_S106: "PLANNING_OBLIGATIONS_S106",
PRIOR_NOTIFICATION: "PRIOR_NOTIFICATION",
// Other types
HAS: "HAS",
CALL_INS: "CALL_INS",
CALL_IN: "CALL_INS",
ENFORCEMENT: "ENFORCEMENT",
ENFORCEMENT_LISTED_BUILDING: "ENFORCEMENT_LISTED_BUILDING",
MAINTENANCE_OF_LAND: "MAINTENANCE_OF_LAND",
RIGHTS_OF_WAY_SCHEDULE_14: "RIGHTS_OF_WAY_SCHEDULE_14",
RIGHTS_OF_WAY_ORDERS: "RIGHTS_OF_WAY_ORDERS",
REQUESTS_FOR_DIRECTION: "REQUESTS_FOR_DIRECTION",
ADVERTS: "ADVERTS",
HEDGEROW_TPO: "HEDGEROW_TPO",
COMMON_LAND: "COMMON_LAND",
COMPULSORY_PURCHASE_ORDERS: "COMPULSORY_PURCHASE_ORDERS",
ELECTRICITY_ACT: "ELECTRICITY_ACT",
HARBOUR_REVISION_ORDER: "HARBOUR_REVISION_ORDER",
TRANSPORT_WORKS: "TRANSPORT_WORKS",
WAYLEAVE: "WAYLEAVE",
NON_VALIDATION: "NON_VALIDATION",
DNS: "DNS",
SIP: "SIP"
};
const normaliseCaseType = (caseType) =>
caseType
?.toString()
.trim()
.toUpperCase()
.replace(/&/g, "AND")
.replace(/[^A-Z0-9]+/g, "_")
.replace(/^_|_$/g, "");
const resolveStages = (caseTypeOrAppealTypeId) => {
const appealTypeKey =
caseTypeKeyByAppealTypeId[Number(caseTypeOrAppealTypeId)];
const normalised = normaliseCaseType(caseTypeOrAppealTypeId);
const key = appealTypeKey || caseTypeAliases[normalised] || normalised;
const entry = stagesByCaseType[key];
if (!entry) return [];
if (typeof entry === "string") {
return stagesByCaseType[entry] || [];
}
return entry;
};
export const getStagesForAppealType = (caseType, currentStageId) => {
const stages = resolveStages(caseType);
const currentStageNumber = Number(currentStageId);
const currentIndex = stages.findIndex(
(stage) => Number(stage.stageId) === currentStageNumber
);
return stages.map((stage, index) => ({
...stage,
status:
currentIndex === -1
? "not-started"
: index < currentIndex
? "complete"
: index === currentIndex
? "in-progress"
: "not-started"
}));
};
export const caseTypeKeyByAppealTypeId = {
846040000: "PLANNING_S78",
846040001: "CONDITIONS_73_79",
846040002: "SIP",
846040003: "PLANNING_OBLIGATIONS_S106",
846040004: "HAS",
846040005: "ENFORCEMENT",
846040006: "ENFORCEMENT_LISTED_BUILDING",
846040007: "MAINTENANCE_OF_LAND",
846040008: "LDCS",
846040009: "PLANNING_S78",
846040010: "CALL_INS",
846040011: "DNS",
846040012: "ELECTRICITY_ACT",
846040013: "TRANSPORT_WORKS",
846040014: "HARBOUR_REVISION_ORDER",
846040015: "RIGHTS_OF_WAY_SCHEDULE_14",
846040016: "COMMON_LAND",
846040017: "HEDGEROW_TPO",
846040018: "ADVERTS",
846040019: "COMPULSORY_PURCHASE_ORDERS",
846040020: "PLANNING_S78",
846040021: "WAYLEAVE",
846040024: "NON_VALIDATION",
846040025: "LBCAC"
};