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( diff --git a/pages/api/health.js b/pages/api/health.js new file mode 100644 index 00000000..ba9aab91 --- /dev/null +++ b/pages/api/health.js @@ -0,0 +1,9 @@ +export default function handler(req, res) { + if (req.method !== "GET") { + return res.status(405).json({ error: "Method not allowed" }); + } + res.status(200).json({ + status: "UP", + timestamp: new Date().toISOString() + }); +} diff --git a/pages/index.js b/pages/index.js index ef0a423d..40510139 100644 --- a/pages/index.js +++ b/pages/index.js @@ -163,14 +163,14 @@ export const getServerSideProps = wrapper.getServerSideProps( var relayToken = await getToken(); relayToken = relayToken.access_token; - console.log("\n////////////////////\nauth sess:", thisSession); + //console.log("\n////////////////////\nauth sess:", thisSession); const showLoginCheck = process.env.SHOWLOGIN || false; const showMapCheck = process.env.SHOWMAPS || false; const showReps = process.env.SHOWREPRESENTATIONS || false; store.dispatch(setShowReps(showReps, showLoginCheck)); - console.log("server checks :", showReps, showLoginCheck); + //console.log("server checks :", showReps, showLoginCheck); let hasLoginCode = thisSession != null; console.log("server side has session:", thisSession != null); @@ -178,7 +178,7 @@ export const getServerSideProps = wrapper.getServerSideProps( let ggLocale = typeof query.ui_locales != "undefined" && query.ui_locales; - console.log("hasloginCode:", hasLoginCode + "\n////////////////////\n"); + //console.log("hasloginCode:", hasLoginCode + "\n////////////////////\n"); let ggToken = {}; let ggUserInfo = {}; @@ -190,8 +190,6 @@ export const getServerSideProps = wrapper.getServerSideProps( store.dispatch(setContainerID(thisSession.user.id)); portalUserObj = await getPortalLogin(thisSession.user.email); - } else { - console.log("///////////////\nempty session \n///////////////\n"); } return {