@nnc-digital/nnc-design-system 1.0.0-alpha58 → 1.0.0-alpha59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23646,8 +23646,46 @@ var ImageAndText = function (_a) {
23646
23646
  React.createElement(Content$5, { dangerouslySetInnerHTML: { __html: sanitizeHtml$1(textContent) } }))))));
23647
23647
  };
23648
23648
 
23649
+ var CaseAppointmentType;
23650
+ (function (CaseAppointmentType) {
23651
+ CaseAppointmentType["Hearing"] = "hearing";
23652
+ CaseAppointmentType["Opening"] = "opening";
23653
+ CaseAppointmentType["Writing"] = "writing";
23654
+ })(CaseAppointmentType || (CaseAppointmentType = {}));
23655
+
23649
23656
  const Container$I = styled.div`
23650
23657
  display: block;
23658
+ box-sizing: border-box;
23659
+ `;
23660
+
23661
+ const GroupContainer = styled.div`
23662
+ display: flex;
23663
+ flex-direction: column;
23664
+ margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.large};
23665
+ `;
23666
+
23667
+ const InquestContainer = styled.div`
23668
+ display: flex;
23669
+ flex-direction: row;
23670
+ align-items: flex-start;
23671
+ justify-content: flex-start;
23672
+ flex-wrap: wrap;
23673
+
23674
+ @media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
23675
+ flex-wrap: nowrap;
23676
+ }
23677
+ `;
23678
+
23679
+ const InquestTime = styled.div`
23680
+ flex-grow: 0;
23681
+ flex-shrink: 0;
23682
+ `;
23683
+
23684
+ const InquestDetails = styled.div`
23685
+ flex-grow: 1;
23686
+ @media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
23687
+ padding-left: ${(props) => props.theme.theme_vars.spacingSizes.small};
23688
+ }
23651
23689
  `;
23652
23690
 
23653
23691
  /**
@@ -23655,32 +23693,100 @@ const Container$I = styled.div`
23655
23693
  */
23656
23694
  var InquestSchedule = function (_a) {
23657
23695
  var caseAppointments = _a.caseAppointments, title = _a.title, _b = _a.error, error = _b === void 0 ? false : _b;
23696
+ var hearings = caseAppointments.filter(function (appointment) {
23697
+ return appointment.appointmentType.toLowerCase().includes(CaseAppointmentType.Hearing);
23698
+ });
23699
+ var openings = caseAppointments.filter(function (appointment) {
23700
+ return appointment.appointmentType.toLowerCase().includes(CaseAppointmentType.Opening);
23701
+ });
23702
+ var writings = caseAppointments.filter(function (appointment) {
23703
+ return appointment.appointmentType.toLowerCase().includes(CaseAppointmentType.Writing);
23704
+ });
23705
+ var groupHearingsByDay = function (appointments) {
23706
+ return appointments.reduce(function (acc, inquest) {
23707
+ var inquestDate = new Date(inquest.startDateTime);
23708
+ var inquestISODay = inquestDate.toISOString().substring(0, 10);
23709
+ if (!acc[inquestISODay]) {
23710
+ acc[inquestISODay] = [];
23711
+ }
23712
+ acc[inquestISODay].push(inquest);
23713
+ return acc;
23714
+ }, {});
23715
+ };
23716
+ var hearingDayGrouped = groupHearingsByDay(hearings);
23717
+ var openingDayGrouped = groupHearingsByDay(openings);
23718
+ var writingDayGrouped = groupHearingsByDay(writings);
23719
+ var formatDate = function (inquestDay) {
23720
+ return inquestDay
23721
+ .toLocaleDateString('en-GB', {
23722
+ weekday: 'long',
23723
+ day: 'numeric',
23724
+ month: 'long',
23725
+ year: 'numeric',
23726
+ })
23727
+ .replace(',', '');
23728
+ };
23729
+ var formatTime = function (inquestDate) {
23730
+ return inquestDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
23731
+ };
23732
+ var transformToSections = function (groupedData) {
23733
+ return Object.keys(groupedData).map(function (day) {
23734
+ var inquestDayDate = new Date(day);
23735
+ return {
23736
+ title: formatDate(inquestDayDate),
23737
+ content: (React.createElement(Row$1, null, groupedData[day]
23738
+ .sort(function (a, b) {
23739
+ return new Date(a.startDateTime).getTime() - new Date(b.startDateTime).getTime();
23740
+ })
23741
+ .map(function (inquest, key) {
23742
+ var startDateTime = new Date(inquest.startDateTime);
23743
+ var timeOfDeath = new Date(inquest.dateTimeOfDeath);
23744
+ return (React.createElement(Column, { small: "full", medium: "full", large: "full", key: key },
23745
+ React.createElement(InquestContainer, null,
23746
+ React.createElement(InquestTime, null,
23747
+ React.createElement("strong", null, formatTime(startDateTime))),
23748
+ React.createElement(InquestDetails, null,
23749
+ React.createElement("strong", null, "Name:"),
23750
+ " ",
23751
+ inquest.fullName,
23752
+ ".",
23753
+ React.createElement("br", null),
23754
+ React.createElement("strong", null, "Died:"),
23755
+ " ",
23756
+ formatDate(timeOfDeath),
23757
+ " at ",
23758
+ inquest.placeOfDeath,
23759
+ ". Aged ",
23760
+ inquest.age,
23761
+ ' ',
23762
+ "years.",
23763
+ React.createElement("br", null),
23764
+ React.createElement("strong", null, "Court location:"),
23765
+ " ",
23766
+ inquest.courtroomFullAddress,
23767
+ ".",
23768
+ React.createElement("br", null),
23769
+ React.createElement("strong", null, "Coroner:"),
23770
+ " ",
23771
+ inquest.coroner,
23772
+ "."))));
23773
+ }))),
23774
+ };
23775
+ });
23776
+ };
23658
23777
  return (React.createElement(Container$I, { "data-testid": "InquestSchedule" },
23659
- React.createElement("div", { className: "table-container" },
23660
- React.createElement("table", null,
23661
- React.createElement("caption", null, title),
23662
- React.createElement("thead", null,
23663
- React.createElement("tr", null,
23664
- React.createElement("th", { scope: "col" }, "Name"),
23665
- React.createElement("th", { scope: "col" }, "Age"),
23666
- React.createElement("th", { scope: "col" }, "Place of death"),
23667
- React.createElement("th", { scope: "col" }, "Date of death"),
23668
- React.createElement("th", { scope: "col" }, "Name of coroner"),
23669
- React.createElement("th", { scope: "col" }, "Location"),
23670
- React.createElement("th", { scope: "col" }, "Date and time"))),
23671
- React.createElement("tbody", null,
23672
- caseAppointments.map(function (item, index) { return (React.createElement("tr", { key: index },
23673
- React.createElement("td", null, item.fullName),
23674
- React.createElement("td", null, item.age),
23675
- React.createElement("td", null, item.placeOfDeath),
23676
- React.createElement("td", null, new Date(item.dateTimeOfDeath).toLocaleString('en-GB')),
23677
- React.createElement("td", null, item.coroner),
23678
- React.createElement("td", null, item.courtroomFullAddress),
23679
- React.createElement("td", null, new Date(item.startDateTime).toLocaleString('en-GB')))); }),
23680
- caseAppointments.length === 0 && (React.createElement("tr", null,
23681
- React.createElement("td", { colSpan: 7 },
23682
- React.createElement("p", null, "We can't find any results at the moment."),
23683
- error ? (React.createElement("p", null, " The information is currently unavailable.")) : (React.createElement("p", null, "There are no inquests scheduled for next month."))))))))));
23778
+ Object.keys(hearingDayGrouped).length > 0 && (React.createElement(GroupContainer, null,
23779
+ React.createElement(Heading, { level: 2, text: title }),
23780
+ React.createElement(Accordion$1, { sections: transformToSections(hearingDayGrouped) }))),
23781
+ Object.keys(openingDayGrouped).length > 0 && (React.createElement(GroupContainer, null,
23782
+ React.createElement(Heading, { level: 2, text: "Inquest Openings" }),
23783
+ React.createElement(Accordion$1, { sections: transformToSections(openingDayGrouped) }))),
23784
+ Object.keys(writingDayGrouped).length > 0 && (React.createElement(GroupContainer, null,
23785
+ React.createElement(Heading, { level: 2, text: "Inquests in Writing" }),
23786
+ React.createElement(Accordion$1, { sections: transformToSections(writingDayGrouped) }))),
23787
+ caseAppointments.length === 0 && (React.createElement("div", null,
23788
+ React.createElement("p", null, "We can't find any results at the moment."),
23789
+ error ? (React.createElement("p", null, " The information is currently unavailable.")) : (React.createElement("p", null, "There are no inquests scheduled for next month."))))));
23684
23790
  };
23685
23791
 
23686
23792
  const Container$H = styled.div`