Skip to content

Commit 76dc878

Browse files
authored
feat: add edit mode for changing exception status and remove unused (#1475)
1 parent 7ef6c7e commit 76dc878

4 files changed

Lines changed: 15 additions & 41 deletions

File tree

application/CohortManager/src/Web/app/components/participantInformationPanel.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@ import {
33
formatDate,
44
formatCompactDate,
55
formatNhsNumber,
6-
formatPhoneNumber,
76
formatGenderValue,
87
} from "@/app/lib/utils";
98

109
interface ParticipantInformationPanelProps {
1110
readonly exceptionDetails: ExceptionDetails;
11+
readonly isEditMode: boolean;
1212
}
1313

1414
export default function ParticipantInformationPanel({
1515
exceptionDetails,
16+
isEditMode,
1617
}: Readonly<ParticipantInformationPanelProps>) {
1718
return (
1819
<>
1920
<div
2021
className={
21-
!exceptionDetails.serviceNowId
22+
!exceptionDetails.serviceNowId || isEditMode
2223
? "nhsuk-card nhsuk-do-dont-list nhsuk-u-margin-bottom-4"
2324
: "nhsuk-card app-card nhsuk-u-margin-bottom-4"
2425
}
2526
>
26-
{!exceptionDetails.serviceNowId && (
27+
{(!exceptionDetails.serviceNowId || isEditMode) && (
2728
<span className="nhsuk-do-dont-list__label nhsuk-u-font-weight-bold">
2829
Portal form: Request to amend incorrect patient PDS record data
2930
</span>
@@ -80,17 +81,6 @@ export default function ParticipantInformationPanel({
8081
{exceptionDetails.address}
8182
</dd>
8283
</div>
83-
<div className="nhsuk-summary-list__row">
84-
<dt className="nhsuk-summary-list__key">Contact details</dt>
85-
<dd className="nhsuk-summary-list__value">
86-
<p>
87-
{formatPhoneNumber(
88-
exceptionDetails.contactDetails?.phoneNumber ?? ""
89-
)}
90-
</p>
91-
<p>{exceptionDetails.contactDetails?.email}</p>
92-
</dd>
93-
</div>
9484
<div className="nhsuk-summary-list__row">
9585
<dt className="nhsuk-summary-list__key">
9686
Registered practice code
@@ -135,10 +125,10 @@ export default function ParticipantInformationPanel({
135125
</dl>
136126
</div>
137127
</div>
138-
{exceptionDetails.serviceNowId ? null : (
128+
{!isEditMode ? null : (
139129
<div className="nhsuk-card nhsuk-u-margin-bottom-4">
140130
<div className="nhsuk-card__content">
141-
<h2>Exception status</h2>
131+
<h2 id="exception-status">Exception status</h2>
142132
<p>
143133
Entering a ServiceNow case ID will change the status of the
144134
exception to “Raised”. <br />

application/CohortManager/src/Web/app/lib/utils.test.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
formatNhsNumber,
33
formatDate,
44
formatCompactDate,
5-
formatPhoneNumber,
65
getCurrentDate,
76
formatGenderValue,
87
} from "@/app/lib/utils";
@@ -37,20 +36,6 @@ describe("formatCompactDate", () => {
3736
});
3837
});
3938

40-
describe("formatPhoneNumber", () => {
41-
it("should format the phone number as XXXXX XXX XXX", () => {
42-
const input = "01619999999";
43-
const expectedOutput = "01619 999 999";
44-
expect(formatPhoneNumber(input)).toBe(expectedOutput);
45-
});
46-
47-
it("should return the input if it is not a valid phone number", () => {
48-
const input = "12345";
49-
const expectedOutput = "12345";
50-
expect(formatPhoneNumber(input)).toBe(expectedOutput);
51-
});
52-
});
53-
5439
describe("getCurrentDate", () => {
5540
it("should return the current date in the format YYYY-MM-DD", () => {
5641
const date = new Date();

application/CohortManager/src/Web/app/lib/utils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ export const formatCompactDate = (dateString: string): string => {
2525
return date.toLocaleDateString("en-GB", options);
2626
};
2727

28-
export const formatPhoneNumber = (phoneNumber: string): string => {
29-
return phoneNumber.replace(/(\d{5})(\d{3})(\d{3})/, "$1 $2 $3");
30-
};
31-
3228
export function getCurrentDate(): string {
3329
const date = new Date();
3430
const year = date.getFullYear();

application/CohortManager/src/Web/app/participant-information/[exceptionId]/page.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default async function Page(props: {
1717
readonly params: Promise<{
1818
readonly exceptionId: string;
1919
}>;
20+
readonly searchParams?: Promise<{ readonly edit?: string }>;
2021
}) {
2122
const session = await auth();
2223
const isCohortManager = await canAccessCohortManager(session);
@@ -27,6 +28,10 @@ export default async function Page(props: {
2728

2829
const params = await props.params;
2930
const exceptionId = Number(params.exceptionId);
31+
const resolvedSearchParams = props.searchParams
32+
? await props.searchParams
33+
: {};
34+
const isEditMode = resolvedSearchParams.edit === "true";
3035

3136
try {
3237
const exception = await fetchExceptions(exceptionId);
@@ -58,10 +63,6 @@ export default async function Page(props: {
5863
? `, ${exception.ExceptionDetails.ParticipantAddressLine5}`
5964
: ""
6065
}, ${exception.ExceptionDetails.ParticipantPostCode}`,
61-
contactDetails: {
62-
phoneNumber: exception.ExceptionDetails.TelephoneNumberHome,
63-
email: exception.ExceptionDetails.EmailAddressHome,
64-
},
6566
primaryCareProvider: exception.ExceptionDetails.PrimaryCareProvider,
6667
serviceNowId: exception.ServiceNowId ?? "",
6768
serviceNowCreatedDate: exception.ServiceNowCreatedDate,
@@ -94,7 +95,7 @@ export default async function Page(props: {
9495
Local reference (exception ID): {exceptionDetails.exceptionId}
9596
</span>
9697
</h1>
97-
{exceptionDetails.serviceNowId && (
98+
{exceptionDetails.serviceNowId && !isEditMode && (
9899
<dl
99100
className="nhsuk-summary-list"
100101
data-testid="exception-details-labels"
@@ -148,10 +149,11 @@ export default async function Page(props: {
148149
className="nhsuk-summary-list__actions"
149150
data-testid="change-link"
150151
>
151-
<a href="#">
152+
<a href="?edit=true#exception-status">
152153
Change{" "}
153154
<span className="nhsuk-u-visually-hidden">
154155
ServiceNow Case ID
156+
{isEditMode}
155157
</span>
156158
</a>
157159
</dd>
@@ -160,6 +162,7 @@ export default async function Page(props: {
160162
)}
161163
<ParticipantInformationPanel
162164
exceptionDetails={exceptionDetails}
165+
isEditMode={isEditMode}
163166
/>
164167
</div>
165168
</div>

0 commit comments

Comments
 (0)