diff --git a/components/case/status.js b/components/case/status.js new file mode 100644 index 00000000..e2076e04 --- /dev/null +++ b/components/case/status.js @@ -0,0 +1,166 @@ +import { setEventDetails } from "../../store/searchOutput/action"; +import { setCurrentPage } from "../../store/currentView/action"; +import { connect } from "react-redux"; +import useTranslation from "next-translate/useTranslation"; +import { formatDates } from "../utils"; +import { useState } from "react"; + +const statusClassMap = { + complete: "govuk-tag govuk-!-margin-top-2", + "in-progress": "govuk-tag govuk-tag--yellow govuk-!-margin-top-2", + "not-started": "govuk-tag govuk-tag--grey govuk-!-margin-top-2", + blocked: "govuk-tag govuk-tag--red govuk-!-margin-top-2" +}; + +const statusTextMap = { + complete: "Complete", + "in-progress": "In progress", + "not-started": "Not started", + blocked: "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 EventView = (eventsArr) => { + eventsArr = eventsArr.value; + + return eventsArr.map((item, key) => { +
{item.pinswg_name}
; + }); + }; + + const eventsArr = props.eventsObj?.value || []; + + // event publishiing flag set to true displa + + function hasOwnPropertyAndNotNull(obj, property) { + return obj.hasOwnProperty(property) && obj[property] !== null; + } + + const [expandAll, setExpandAll] = useState(null); + // null = use default (in-progress open) + // true = force open all + // false = force close all + + const handleToggleAll = () => { + setExpandAll((prev) => (prev === true ? false : true)); + }; + + return ( +
+
+
+

+ {t("case:status-title")} +

+ + +
    + {stages.map((stage) => { + const isDefaultOpen = + stage.status === "in-progress"; + + const isOpen = + expandAll === null ? isDefaultOpen : expandAll; + + return ( +
  • +
    + {stage.description && ( +
    + + + {stage.title} + + +
    + {stage.description} +
    +
    + )} +
    + +
    + + {statusTextMap[stage.status] || + "Not started"} + +
    +
  • + ); + })} +
+
+
+
+ ); +}; + +const mapStateToProps = (state) => { + return { + ...state + }; +}; + +const mapDispatchToProps = (dispatch) => { + return { + setEventDetails: (eventsObj) => { + dispatch(setEventDetails(eventsObj)); + }, + setCurrentPage: (currentPage) => { + dispatch(setCurrentPage(currentPage)); + } + }; +}; + +export default connect(mapStateToProps, mapDispatchToProps)(StatusDetails); diff --git a/components/case/summary.js b/components/case/summary.js index a2016bdf..f4f096b3 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -9,6 +9,7 @@ import transLookup from "../../data/lookuptranslations.json"; import Documents from "./documents"; import EventsDetails from "./events"; import MediaDetails from "./media"; +import StatusDetails from "./status"; import { createWatchedCases, @@ -563,6 +564,21 @@ const CaseSummary = (props) => { {t("case:summary-tab-documents-label")} +
  • + setWhichTab("case-status")} + > + {t("case:status-title")} + +
  • { showFilteredDocs={props.showFilteredDocs} />
    +
    + +
    diff --git a/components/case/summaryTypes/pinswg_sipscase.js b/components/case/summaryTypes/pinswg_sipscase.js index f837b525..5328b2a0 100644 --- a/components/case/summaryTypes/pinswg_sipscase.js +++ b/components/case/summaryTypes/pinswg_sipscase.js @@ -38,8 +38,6 @@ const Pinswg_sipscase = (props) => { new Date(a.pinswg_datedeadlineextended) )[0]; - console.log(latest); - return ( <> {detailsObj.pinswg_projectdescription != null ? ( diff --git a/locales/cy/case.json b/locales/cy/case.json index 40a40edc..7f3b7da8 100644 --- a/locales/cy/case.json +++ b/locales/cy/case.json @@ -148,5 +148,8 @@ "video-heading": "Fideos", "live-event-subheading": "Digwyddiad byw", "live-event-copy": "Mae digwyddiad sy'n cael ei ffrydio'n fyw yn digwydd nawr.", - "live-event-link": "Gwylio'r ffrydio byw" + "live-event-link": "Gwylio'r ffrydio byw", + "status-title": "Statws", + "status-show-all-label": "Dangoswch bob cam", + "status-hide-all-label": "Cuddio pob cam" } \ No newline at end of file diff --git a/locales/en/case.json b/locales/en/case.json index cb748277..37b43776 100644 --- a/locales/en/case.json +++ b/locales/en/case.json @@ -149,5 +149,8 @@ "video-heading": "Videos", "live-event-subheading": "Live event", "live-event-copy": "A live streamed event is happening now.", - "live-event-link": "Watch live stream" + "live-event-link": "Watch live stream", + "status-title": "Status", + "status-show-all-label": "Show all stages", + "status-hide-all-label": "Hide all stages" } \ No newline at end of file