From c8b08a04a62e1a8fb13b32c78ee8b28762b23fa7 Mon Sep 17 00:00:00 2001 From: Robert Bond Date: Thu, 16 Apr 2026 10:47:54 +0000 Subject: [PATCH] Merged PR 2250: fixed typo Related work items: #22632 --- .../representationInterestedPartyPerson.js | 2 +- package.json | 4 +- pages/api/email/getall.js | 65 ++++++++++--------- pages/api/email/getcaseref.js | 2 +- 4 files changed, 39 insertions(+), 34 deletions(-) diff --git a/components/case/representation/representationInterestedPartyPerson.js b/components/case/representation/representationInterestedPartyPerson.js index d6ba6bdd..63c21ab7 100644 --- a/components/case/representation/representationInterestedPartyPerson.js +++ b/components/case/representation/representationInterestedPartyPerson.js @@ -304,7 +304,7 @@ const RepInterestedPartyPerson = (props) => { ); }} > - {t("common:save-exit-button")}sssss + {t("common:save-exit-button")} )} diff --git a/package.json b/package.json index 36af15ac..e1a965f5 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,9 @@ "start3": "NODE_ENV=production next start", "start": "NODE_ENV=production node_modules/next/dist/bin/next start", "lint": "next lint", - "prisma:generate": "prisma generate" + "prisma:generate": "prisma generate", + "test:reps": "cd '../../welsh government/Playwright/Playwright' && npx playwright test tests/loggedin/raiserep.spec.js --headed", + "test:newappeal": "cd '../../welsh government/Playwright/Playwright' && npx playwright test tests/loggedin/newappeal.spec.js --headed" }, "browser": { "child_process": false diff --git a/pages/api/email/getall.js b/pages/api/email/getall.js index d906dc34..3d7a4bda 100644 --- a/pages/api/email/getall.js +++ b/pages/api/email/getall.js @@ -86,15 +86,13 @@ const buildNotifyPayloads = (watchlistByEmail) => { const ref = doc.pinswg_isharedocumentreference || t.noRef; const name = doc.pinswg_name || t.untitled; const date = - formatDates( - doc.pinswg_documentpublisheddate?.split("T")[0], - language - ) || t.noDate; + formatDates(doc.pinswg_documentpublisheddate, language) || + t.noDate; const link = (process.env.NEXTAUTH_URL || "") + doc.pinswg_hashlink || "[No Link]"; - return ` - ${name} (${date})\n ${t.link}: ${link}`; + return ` - [${name} (${date})](${link})`; }) .join("\n"); }; @@ -119,11 +117,12 @@ const buildNotifyPayloads = (watchlistByEmail) => { .map((event) => { const name = event.pinswg_name || t.unnamed; const date = - formatDates( - event.pinswg_dateeventrequested?.split("T")[0], - language - ) || t.noDate; - return ` - ${name} ${t.on} ${date}`; + formatDates(event.pinswg_dateeventrequested, false) || + t.noDate; + const time = + formatDates(event.pinswg_dateeventrequested, true) || + t.noDate; + return ` - ${name} ${t.on} ${date} ${time}`; }) .join("\n"); }; @@ -149,15 +148,9 @@ const buildNotifyPayloads = (watchlistByEmail) => { return reps .map((rep) => { const start = - formatDates( - rep.pinswg_consultationopen?.split("T")[0], - language - ) || t.na; + formatDates(rep.pinswg_consultationopen, false) || t.na; const end = - formatDates( - rep.pinswg_consultationclose?.split("T")[0], - language - ) || t.na; + formatDates(rep.pinswg_consultationclose, false) || t.na; return ` - ${t.open}: ${start} ${t.to} ${t.close}: ${end}`; }) @@ -197,28 +190,33 @@ const buildNotifyPayloads = (watchlistByEmail) => { "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue" ] || "Unknown Case"; + const appealType = + entry[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ] || ""; + const docSection = entry.documents?.length - ? `Documents added or updated:\n${formatDocuments( + ? `### Documents added or updated:\n${formatDocuments( entry.documents, "en" )}\n` : ""; const sipSection = entry.sipEvents?.length - ? `SIP Events created:\n${formatSipEvents( + ? `### SIP Events created:\n${formatSipEvents( entry.sipEvents )}\n` : ""; const repsSection = entry.repsPeriods?.length - ? `Consultation Periods:\n${formatReps( + ? `### Consultation Periods:\n${formatReps( entry.repsPeriods )}\n` : ""; - const caseUnsubscribelink = `Unsubscribe to updates on this case ${process.env.NEXTAUTH_URL}/unsubscribe/${entry.pinswg_watchlistid}`; + const caseUnsubscribelink = `[Unsubscribe](${process.env.NEXTAUTH_URL}/unsubscribe/${entry.pinswg_watchlistid}) to updates on this case `; - return `Case: ${caseRef}\nLink to case:${ + return `---\n## Case: [${caseRef}](${ process.env.NEXTAUTH_URL - }/case/${caseRef}\n\n${[ + }/case/${caseRef}) - ${appealType}\n\n${[ docSection, sipSection, repsSection, @@ -228,9 +226,9 @@ const buildNotifyPayloads = (watchlistByEmail) => { .join("\n")}`; }) .join("\n\n"), - unsubscribeLink: `Unsubscribe by selecting this link if you no longer want to receive any updates ${ + unsubscribeLink: `[Unsubscribe](${ process.env.NEXTAUTH_URL + "/unsubscribeall/" + contactId - }` + }) by selecting this link if you no longer want to receive any updates ` }; const personalisationCY = { @@ -242,6 +240,11 @@ const buildNotifyPayloads = (watchlistByEmail) => { "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue" ] || "Achos Anhysbys"; + const appealType = + entry[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ] || ""; + const docSection = entry.documents?.length ? `Dogfennau wedi'u hychwanegu neu eu diweddaru:\n${formatDocuments( entry.documents, @@ -261,11 +264,11 @@ const buildNotifyPayloads = (watchlistByEmail) => { )}\n` : ""; - const caseUnsubscribelink = `Dad-danysgrifio i ddiweddariadau ar yr achos hwn ${process.env.NEXTAUTH_URL}/unsubscribe/${entry.pinswg_watchlistid}`; + const caseUnsubscribelink = `[Dad-danysgrifio](${process.env.NEXTAUTH_URL}/cy/unsubscribe/${entry.pinswg_watchlistid}) i ddiweddariadau ar yr achos hwn `; - return `Achos: ${caseRef}\nDolen i'r achos: ${ + return `## Achos: [${caseRef}](${ process.env.NEXTAUTH_URL - }/case/${caseRef}\n\n${[ + }/cy/case/${caseRef}) - ${appealType}\n\n${[ docSection, sipSection, repsSection, @@ -276,7 +279,7 @@ const buildNotifyPayloads = (watchlistByEmail) => { }) .join("\n\n"), unsubscribeLink: `Dad-danysgrifiwch drwy ddewis y ddolen hon os nad ydych chi eisiau derbyn unrhyw ddiweddariadau mwyach ${ - process.env.NEXTAUTH_URL + "/unsubscribeall/" + contactId + process.env.NEXTAUTH_URL + "/cy/unsubscribeall/" + contactId }` }; @@ -304,7 +307,7 @@ export default async function CombinedApiProxy(req, res) { const token = await getToken(); // Step 1: Fetch all watchlist entries - const watchlistQuery = `pinswg_watchlists?$count=true&$filter=pinswg_emailnotifications ne null&$expand=pinswg_Contact($select=contactid,emailaddress1,firstname,lastname,pinswg_preferredlanguage)&$select=pinswg_emailnotifications,_pinswg_watchedcase_value`; + const watchlistQuery = `pinswg_watchlists?$count=true&$filter=pinswg_emailnotifications ne null&$expand=pinswg_Contact($select=contactid,emailaddress1,firstname,lastname,pinswg_preferredlanguage)&$select=pinswg_emailnotifications,_pinswg_watchedcase_value,pinswg_appealcasetype`; const watchlistRes = await axios.get( WEBAPI_URL + watchlistQuery + hashAPIPath(watchlistQuery), azureHeaders(token.access_token) diff --git a/pages/api/email/getcaseref.js b/pages/api/email/getcaseref.js index 52e07578..58c44557 100644 --- a/pages/api/email/getcaseref.js +++ b/pages/api/email/getcaseref.js @@ -25,7 +25,7 @@ export default async function ApiProxy(req, res) { const token = await getToken(); const queryUrl = - "pinswg_watchlists?$count=true&$filter=pinswg_emailnotifications ne null&$expand=pinswg_Contact($select=contactid,emailaddress1)&$select=pinswg_emailnotifications,_pinswg_watchedcase_value"; + "pinswg_watchlists?$count=true&$filter=pinswg_emailnotifications ne null&$expand=pinswg_Contact($select=contactid,emailaddress1)&$select=pinswg_emailnotifications,_pinswg_watchedcase_value,pinswg_appealcasetype"; try { const { data } = await axios.get(