From 67b15da5bf4a09b1aa5047a8a2a77e7195a62be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Thu, 11 Jul 2024 15:23:30 +0100 Subject: [PATCH] feat: Read from new `team_settings` table (#3391) --- api.planx.uk/modules/admin/session/summary.ts | 9 +-- .../modules/flows/moveFlow/service.ts | 3 +- .../inviteToPay/createPaymentSendEvents.ts | 4 +- .../inviteToPay/sendConfirmationEmail.ts | 7 ++- .../service/inviteToPay/sendPaymentEmail.ts | 59 +++++++++++-------- .../service/resumeApplication.test.ts | 3 +- .../service/resumeApplication.ts | 13 ++-- .../saveAndReturn/service/utils.test.ts | 3 +- .../modules/saveAndReturn/service/utils.ts | 13 ++-- api.planx.uk/modules/send/email/index.test.ts | 4 +- api.planx.uk/modules/send/email/service.ts | 7 ++- api.planx.uk/package.json | 2 +- api.planx.uk/pnpm-lock.yaml | 8 +-- api.planx.uk/tests/mocks/inviteToPayData.ts | 2 +- .../tests/mocks/saveAndReturnMocks.ts | 5 +- api.planx.uk/types.ts | 16 +---- e2e/tests/api-driven/package.json | 2 +- e2e/tests/api-driven/pnpm-lock.yaml | 8 +-- e2e/tests/ui-driven/package.json | 2 +- e2e/tests/ui-driven/pnpm-lock.yaml | 8 +-- editor.planx.uk/package.json | 2 +- editor.planx.uk/pnpm-lock.yaml | 57 +++++++----------- .../components/FindProperty/Public/Map.tsx | 2 +- .../src/components/Header.test.tsx | 6 +- .../Settings/GeneralSettings/BoundaryForm.tsx | 2 +- .../Settings/GeneralSettings/index.tsx | 2 +- .../src/pages/FlowEditor/lib/store/team.ts | 4 +- editor.planx.uk/src/pages/Pay/InviteToPay.tsx | 14 ++--- editor.planx.uk/src/routes/teamSettings.tsx | 2 +- editor.planx.uk/src/routes/views/draft.tsx | 2 +- .../src/routes/views/published.tsx | 2 +- .../src/routes/views/standalone.tsx | 2 +- .../1720511391883_run_sql_migration/down.sql | 28 +++++++++ .../1720511391883_run_sql_migration/up.sql | 32 ++++++++++ 34 files changed, 194 insertions(+), 141 deletions(-) create mode 100644 hasura.planx.uk/migrations/1720511391883_run_sql_migration/down.sql create mode 100644 hasura.planx.uk/migrations/1720511391883_run_sql_migration/up.sql diff --git a/api.planx.uk/modules/admin/session/summary.ts b/api.planx.uk/modules/admin/session/summary.ts index 9139719bc5..d74b93038d 100644 --- a/api.planx.uk/modules/admin/session/summary.ts +++ b/api.planx.uk/modules/admin/session/summary.ts @@ -2,17 +2,12 @@ import { GovUKPayment, PaymentRequest, Session, + Team, } from "@opensystemslab/planx-core/types"; import { NextFunction, Request, Response } from "express"; import { gql } from "graphql-request"; -import { - Breadcrumb, - Flow, - LowCalSession, - Passport, - Team, -} from "../../../types"; +import { Breadcrumb, Flow, LowCalSession, Passport } from "../../../types"; import { $api } from "../../../client"; /** diff --git a/api.planx.uk/modules/flows/moveFlow/service.ts b/api.planx.uk/modules/flows/moveFlow/service.ts index e77a811422..6c05c62c40 100644 --- a/api.planx.uk/modules/flows/moveFlow/service.ts +++ b/api.planx.uk/modules/flows/moveFlow/service.ts @@ -1,6 +1,7 @@ import { gql } from "graphql-request"; -import { Flow, Team } from "../../../types"; +import { Flow } from "../../../types"; import { $public, getClient } from "../../../client"; +import { Team } from "@opensystemslab/planx-core/types"; export const moveFlow = async (flowId: string, teamSlug: string) => { const team = await $public.team.getBySlug(teamSlug); diff --git a/api.planx.uk/modules/pay/service/inviteToPay/createPaymentSendEvents.ts b/api.planx.uk/modules/pay/service/inviteToPay/createPaymentSendEvents.ts index d9020df1c9..2c67cd6027 100644 --- a/api.planx.uk/modules/pay/service/inviteToPay/createPaymentSendEvents.ts +++ b/api.planx.uk/modules/pay/service/inviteToPay/createPaymentSendEvents.ts @@ -1,4 +1,4 @@ -import { ComponentType } from "@opensystemslab/planx-core/types"; +import { ComponentType, Team } from "@opensystemslab/planx-core/types"; import { NextFunction, Request, Response } from "express"; import { gql } from "graphql-request"; import { @@ -7,7 +7,7 @@ import { } from "../../../../lib/hasura/metadata"; import { $api, $public } from "../../../../client"; import { getMostRecentPublishedFlow } from "../../../../helpers"; -import { Flow, Node, Team } from "../../../../types"; +import { Flow, Node } from "../../../../types"; enum Destination { BOPS = "bops", diff --git a/api.planx.uk/modules/pay/service/inviteToPay/sendConfirmationEmail.ts b/api.planx.uk/modules/pay/service/inviteToPay/sendConfirmationEmail.ts index 6ee3820fda..92e30223d7 100644 --- a/api.planx.uk/modules/pay/service/inviteToPay/sendConfirmationEmail.ts +++ b/api.planx.uk/modules/pay/service/inviteToPay/sendConfirmationEmail.ts @@ -46,7 +46,12 @@ async function getDataForPayeeAndAgentEmails( flow { slug team { - notifyPersonalisation: notify_personalisation + notifyPersonalisation: team_settings { + helpEmail: help_email + helpPhone: help_phone + emailReplyToId: email_reply_to_id + helpOpeningHours: help_opening_hours + } } } paymentRequests: payment_requests( diff --git a/api.planx.uk/modules/pay/service/inviteToPay/sendPaymentEmail.ts b/api.planx.uk/modules/pay/service/inviteToPay/sendPaymentEmail.ts index ac2ca1d9f5..14dd6cea5c 100644 --- a/api.planx.uk/modules/pay/service/inviteToPay/sendPaymentEmail.ts +++ b/api.planx.uk/modules/pay/service/inviteToPay/sendPaymentEmail.ts @@ -9,8 +9,7 @@ import { sendEmail, } from "../../../../lib/notify"; import { InviteToPayNotifyConfig } from "../../../../types"; -import { Team } from "../../../../types"; -import type { PaymentRequest } from "@opensystemslab/planx-core/types"; +import type { PaymentRequest, Team } from "@opensystemslab/planx-core/types"; import { $public } from "../../../../client"; interface SessionDetails { @@ -75,7 +74,7 @@ const validatePaymentRequest = async ( name slug domain - notifyPersonalisation: notify_personalisation + settings: team_settings } } } @@ -108,28 +107,38 @@ const validatePaymentRequest = async ( const getInviteToPayNotifyConfig = async ( session: SessionDetails, paymentRequest: PaymentRequest, -): Promise => ({ - personalisation: { - ...session.flow.team.notifyPersonalisation, - sessionId: paymentRequest.sessionId, - paymentRequestId: paymentRequest.id, - payeeEmail: paymentRequest.payeeEmail, - payeeName: paymentRequest.payeeName, - agentName: paymentRequest.applicantName, - address: ( - paymentRequest.sessionPreviewData?._address as Record<"title", string> - ).title, - fee: getFee(paymentRequest), - projectType: - (await $public.formatRawProjectTypes( - paymentRequest.sessionPreviewData?.["proposal.projectType"] as string[], - )) || "Project type not submitted", - serviceName: session.flow.name, - serviceLink: getServiceLink(session.flow.team, session.flow.slug), - expiryDate: calculateExpiryDate(paymentRequest.createdAt), - paymentLink: getPaymentLink(session, paymentRequest), - }, -}); +): Promise => { + const flow = session.flow; + const { settings } = session.flow.team; + + return { + personalisation: { + helpEmail: settings.helpEmail, + helpPhone: settings.helpPhone, + emailReplyToId: settings.emailReplyToId, + helpOpeningHours: settings.helpOpeningHours, + sessionId: paymentRequest.sessionId, + paymentRequestId: paymentRequest.id, + payeeEmail: paymentRequest.payeeEmail, + payeeName: paymentRequest.payeeName, + agentName: paymentRequest.applicantName, + address: ( + paymentRequest.sessionPreviewData?._address as Record<"title", string> + ).title, + fee: getFee(paymentRequest), + projectType: + (await $public.formatRawProjectTypes( + paymentRequest.sessionPreviewData?.[ + "proposal.projectType" + ] as string[], + )) || "Project type not submitted", + serviceName: session.flow.name, + serviceLink: getServiceLink(flow.team, flow.slug), + expiryDate: calculateExpiryDate(paymentRequest.createdAt), + paymentLink: getPaymentLink(session, paymentRequest), + }, + }; +}; const getFee = (paymentRequest: PaymentRequest) => { const toPounds = (pence: number) => pence / 100; diff --git a/api.planx.uk/modules/saveAndReturn/service/resumeApplication.test.ts b/api.planx.uk/modules/saveAndReturn/service/resumeApplication.test.ts index b7cba296bf..1c57226fdb 100644 --- a/api.planx.uk/modules/saveAndReturn/service/resumeApplication.test.ts +++ b/api.planx.uk/modules/saveAndReturn/service/resumeApplication.test.ts @@ -1,4 +1,4 @@ -import { LowCalSession, Team } from "../../../types"; +import { LowCalSession } from "../../../types"; import supertest from "supertest"; import app from "../../../server"; import { queryMock } from "../../../tests/graphqlQueryMock"; @@ -8,6 +8,7 @@ import { } from "../../../tests/mocks/saveAndReturnMocks"; import { buildContentFromSessions } from "./resumeApplication"; import { PartialDeep } from "type-fest"; +import { Team } from "@opensystemslab/planx-core/types"; const ENDPOINT = "/resume-application"; const TEST_EMAIL = "simulate-delivered@notifications.service.gov.uk"; diff --git a/api.planx.uk/modules/saveAndReturn/service/resumeApplication.ts b/api.planx.uk/modules/saveAndReturn/service/resumeApplication.ts index b229a7f1b0..5e0c877c0b 100644 --- a/api.planx.uk/modules/saveAndReturn/service/resumeApplication.ts +++ b/api.planx.uk/modules/saveAndReturn/service/resumeApplication.ts @@ -1,9 +1,9 @@ -import type { SiteAddress } from "@opensystemslab/planx-core/types"; +import type { SiteAddress, Team } from "@opensystemslab/planx-core/types"; import { differenceInDays } from "date-fns"; import { gql } from "graphql-request"; import { $api, $public } from "../../../client"; import { sendEmail } from "../../../lib/notify"; -import { LowCalSession, Team } from "../../../types"; +import { LowCalSession } from "../../../types"; import { DAYS_UNTIL_EXPIRY, calculateExpiryDate, getResumeLink } from "./utils"; /** @@ -17,7 +17,7 @@ const resumeApplication = async (teamSlug: string, email: string) => { const config = { personalisation: await getPersonalisation(sessions, team), reference: null, - emailReplyToId: team.notifyPersonalisation.emailReplyToId, + emailReplyToId: team.settings.emailReplyToId, }; const response = await sendEmail("resume", email, config); return response; @@ -64,7 +64,7 @@ const validateRequest = async ( teams(where: { slug: { _eq: $teamSlug } }) { slug name - notifyPersonalisation: notify_personalisation + settings: team_settings domain } } @@ -93,7 +93,10 @@ const getPersonalisation = async (sessions: LowCalSession[], team: Team) => { return { teamName: team.name, content: await buildContentFromSessions(sessions, team), - ...team.notifyPersonalisation, + helpEmail: team.settings.helpEmail, + helpPhone: team.settings.helpPhone, + helpOpeningHours: team.settings.helpOpeningHours, + emailReplyToId: team.settings.emailReplyToId, }; }; diff --git a/api.planx.uk/modules/saveAndReturn/service/utils.test.ts b/api.planx.uk/modules/saveAndReturn/service/utils.test.ts index e0d2eb0328..6cf33d0649 100644 --- a/api.planx.uk/modules/saveAndReturn/service/utils.test.ts +++ b/api.planx.uk/modules/saveAndReturn/service/utils.test.ts @@ -1,5 +1,6 @@ +import { Team } from "@opensystemslab/planx-core/types"; import { queryMock } from "../../../tests/graphqlQueryMock"; -import { LowCalSession, LowCalSessionData, Team } from "../../../types"; +import { LowCalSession, LowCalSessionData } from "../../../types"; import { getResumeLink, getSessionDetails, diff --git a/api.planx.uk/modules/saveAndReturn/service/utils.ts b/api.planx.uk/modules/saveAndReturn/service/utils.ts index a7f54a9132..baa416371f 100644 --- a/api.planx.uk/modules/saveAndReturn/service/utils.ts +++ b/api.planx.uk/modules/saveAndReturn/service/utils.ts @@ -1,7 +1,7 @@ -import { SiteAddress } from "@opensystemslab/planx-core/types"; +import { SiteAddress, Team } from "@opensystemslab/planx-core/types"; import { format, addDays } from "date-fns"; import { gql } from "graphql-request"; -import { LowCalSession, Team } from "../../../types"; +import { LowCalSession } from "../../../types"; import { Template, getClientForTemplate, sendEmail } from "../../../lib/notify"; import { $api, $public } from "../../../client"; @@ -59,7 +59,7 @@ const sendSingleApplicationEmail = async ({ const config = { personalisation: getPersonalisation(session, flowSlug, flowName, team), reference: null, - emailReplyToId: team.notifyPersonalisation.emailReplyToId, + emailReplyToId: team.settings.emailReplyToId, }; const firstSave = !session.hasUserSaved; if (firstSave && !session.submittedAt) @@ -97,7 +97,7 @@ const validateSingleSessionRequest = async ( team { name slug - notifyPersonalisation: notify_personalisation + settings: team_settings domain } } @@ -176,7 +176,10 @@ const getPersonalisation = ( serviceName: flowName, teamName: team.name, sessionId: session.id, - ...team.notifyPersonalisation, + helpEmail: team.settings.helpEmail, + helpPhone: team.settings.helpPhone, + helpOpeningHours: team.settings.helpOpeningHours, + emailReplyToId: team.settings.emailReplyToId, ...session, }; }; diff --git a/api.planx.uk/modules/send/email/index.test.ts b/api.planx.uk/modules/send/email/index.test.ts index ff6c89e263..c0b2cae2f1 100644 --- a/api.planx.uk/modules/send/email/index.test.ts +++ b/api.planx.uk/modules/send/email/index.test.ts @@ -50,7 +50,7 @@ describe(`sending an application by email to a planning office`, () => { teams: [ { sendToEmail: "planning.office.example@council.gov.uk", - notifyPersonalisation: { emailReplyToId: "abc123" }, + settings: { emailReplyToId: "abc123" }, }, ], }, @@ -153,7 +153,7 @@ describe(`sending an application by email to a planning office`, () => { teams: [ { sendToEmail: null, - notifyPersonalisation: { emailReplyToId: "abc123" }, + settings: { emailReplyToId: "abc123" }, }, ], }, diff --git a/api.planx.uk/modules/send/email/service.ts b/api.planx.uk/modules/send/email/service.ts index 7ba6e6ffb6..7cb7e0e606 100644 --- a/api.planx.uk/modules/send/email/service.ts +++ b/api.planx.uk/modules/send/email/service.ts @@ -17,7 +17,12 @@ export async function getTeamEmailSettings(localAuthority: string) { query GetTeamEmailSettings($slug: String) { teams(where: { slug: { _eq: $slug } }) { sendToEmail: submission_email - notifyPersonalisation: notify_personalisation + notifyPersonalisation: team_settings { + helpEmail: help_email + helpPhone: help_phone + emailReplyToId: email_reply_to_id + helpOpeningHours: help_opening_hours + } } } `, diff --git a/api.planx.uk/package.json b/api.planx.uk/package.json index 9e1d308b8a..82f46fc379 100644 --- a/api.planx.uk/package.json +++ b/api.planx.uk/package.json @@ -5,7 +5,7 @@ "packageManager": "pnpm@8.6.6", "dependencies": { "@airbrake/node": "^2.1.8", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#b43b268", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#75127e6", "@types/isomorphic-fetch": "^0.0.36", "adm-zip": "^0.5.10", "aws-sdk": "^2.1467.0", diff --git a/api.planx.uk/pnpm-lock.yaml b/api.planx.uk/pnpm-lock.yaml index c1b21ac157..474d6d91d4 100644 --- a/api.planx.uk/pnpm-lock.yaml +++ b/api.planx.uk/pnpm-lock.yaml @@ -14,8 +14,8 @@ dependencies: specifier: ^2.1.8 version: 2.1.8 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#b43b268 - version: github.com/theopensystemslab/planx-core/b43b268 + specifier: git+https://github.com/theopensystemslab/planx-core#75127e6 + version: github.com/theopensystemslab/planx-core/75127e6 '@types/isomorphic-fetch': specifier: ^0.0.36 version: 0.0.36 @@ -8203,8 +8203,8 @@ packages: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} dev: false - github.com/theopensystemslab/planx-core/b43b268: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/b43b268} + github.com/theopensystemslab/planx-core/75127e6: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/75127e6} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/api.planx.uk/tests/mocks/inviteToPayData.ts b/api.planx.uk/tests/mocks/inviteToPayData.ts index 4f4d4dfcaf..6f0ad73dcf 100644 --- a/api.planx.uk/tests/mocks/inviteToPayData.ts +++ b/api.planx.uk/tests/mocks/inviteToPayData.ts @@ -83,7 +83,7 @@ export const validPaymentRequest = { name: "Buckinghamshire", slug: "buckinghamshire", domain: "planningservices.buckinghamshire.gov.uk", - notifyPersonalisation: { + settings: { helpEmail: "help@council.gov.uk", helpPhone: "123", helpOpeningHours: "9a-5p", diff --git a/api.planx.uk/tests/mocks/saveAndReturnMocks.ts b/api.planx.uk/tests/mocks/saveAndReturnMocks.ts index 12415a5222..0fcdc37285 100644 --- a/api.planx.uk/tests/mocks/saveAndReturnMocks.ts +++ b/api.planx.uk/tests/mocks/saveAndReturnMocks.ts @@ -1,17 +1,18 @@ import { v4 as uuidV4 } from "uuid"; import type { LowCalSession, Flow } from "../../types"; +import { Team } from "@opensystemslab/planx-core/types"; export const mockTeam = { id: 1, slug: "test-team", name: "Test Team", - notifyPersonalisation: { + settings: { helpEmail: "example@council.gov.uk", helpPhone: "(01234) 567890", helpOpeningHours: "Monday - Friday, 9am - 5pm", emailReplyToId: "727d48fa-cb8a-42f9-b8b2-55032f3bb451", }, -}; +} as Team; export const mockFlow: Flow = { id: "dcfd4f07-76da-4b67-9822-2aca92b27551", diff --git a/api.planx.uk/types.ts b/api.planx.uk/types.ts index aa38f936db..60c8272418 100644 --- a/api.planx.uk/types.ts +++ b/api.planx.uk/types.ts @@ -1,5 +1,5 @@ import { PaymentRequest } from "@opensystemslab/planx-core/dist/types"; -import { GovUKPayment } from "@opensystemslab/planx-core/types"; +import { GovUKPayment, Team } from "@opensystemslab/planx-core/types"; /** * @deprecated Migrating to Node from planx-core @@ -49,20 +49,6 @@ export interface UserData { export type Breadcrumb = Record; -export interface Team { - id: number; - slug: string; - name: string; - domain?: string; - boundaryBBox?: object; - notifyPersonalisation: { - helpEmail: string; - helpPhone: string; - helpOpeningHours: string; - emailReplyToId: string; - }; -} - export interface Passport { data: Record; } diff --git a/e2e/tests/api-driven/package.json b/e2e/tests/api-driven/package.json index f59a16d87b..a26bd30205 100644 --- a/e2e/tests/api-driven/package.json +++ b/e2e/tests/api-driven/package.json @@ -7,7 +7,7 @@ "packageManager": "pnpm@8.6.6", "dependencies": { "@cucumber/cucumber": "^9.3.0", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#b43b268", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#75127e6", "axios": "^1.6.8", "dotenv": "^16.3.1", "dotenv-expand": "^10.0.0", diff --git a/e2e/tests/api-driven/pnpm-lock.yaml b/e2e/tests/api-driven/pnpm-lock.yaml index 325902c9a3..cdadc2cd71 100644 --- a/e2e/tests/api-driven/pnpm-lock.yaml +++ b/e2e/tests/api-driven/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: ^9.3.0 version: 9.3.0 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#b43b268 - version: github.com/theopensystemslab/planx-core/b43b268 + specifier: git+https://github.com/theopensystemslab/planx-core#75127e6 + version: github.com/theopensystemslab/planx-core/75127e6 axios: specifier: ^1.6.8 version: 1.6.8 @@ -3053,8 +3053,8 @@ packages: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} dev: false - github.com/theopensystemslab/planx-core/b43b268: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/b43b268} + github.com/theopensystemslab/planx-core/75127e6: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/75127e6} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/e2e/tests/ui-driven/package.json b/e2e/tests/ui-driven/package.json index 59e49915dd..eeae99cbee 100644 --- a/e2e/tests/ui-driven/package.json +++ b/e2e/tests/ui-driven/package.json @@ -8,7 +8,7 @@ "postinstall": "./install-dependencies.sh" }, "dependencies": { - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#b43b268", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#75127e6", "axios": "^1.6.8", "dotenv": "^16.3.1", "eslint": "^8.56.0", diff --git a/e2e/tests/ui-driven/pnpm-lock.yaml b/e2e/tests/ui-driven/pnpm-lock.yaml index a8b7649791..2f1970bebb 100644 --- a/e2e/tests/ui-driven/pnpm-lock.yaml +++ b/e2e/tests/ui-driven/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#b43b268 - version: github.com/theopensystemslab/planx-core/b43b268 + specifier: git+https://github.com/theopensystemslab/planx-core#75127e6 + version: github.com/theopensystemslab/planx-core/75127e6 axios: specifier: ^1.6.8 version: 1.6.8 @@ -2782,8 +2782,8 @@ packages: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} dev: false - github.com/theopensystemslab/planx-core/b43b268: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/b43b268} + github.com/theopensystemslab/planx-core/75127e6: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/75127e6} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/editor.planx.uk/package.json b/editor.planx.uk/package.json index 297c6d69d5..10ccc6e6b8 100644 --- a/editor.planx.uk/package.json +++ b/editor.planx.uk/package.json @@ -13,7 +13,7 @@ "@mui/material": "^5.15.2", "@mui/utils": "^5.15.2", "@opensystemslab/map": "^0.8.3", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#b43b268", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#75127e6", "@tiptap/core": "^2.4.0", "@tiptap/extension-bold": "^2.0.3", "@tiptap/extension-bubble-menu": "^2.1.13", diff --git a/editor.planx.uk/pnpm-lock.yaml b/editor.planx.uk/pnpm-lock.yaml index 7ea2dbb091..c918ec40b8 100644 --- a/editor.planx.uk/pnpm-lock.yaml +++ b/editor.planx.uk/pnpm-lock.yaml @@ -43,8 +43,8 @@ dependencies: specifier: ^0.8.3 version: 0.8.3 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#b43b268 - version: github.com/theopensystemslab/planx-core/b43b268(@types/react@18.2.45) + specifier: git+https://github.com/theopensystemslab/planx-core#75127e6 + version: github.com/theopensystemslab/planx-core/75127e6(@types/react@18.2.45) '@tiptap/core': specifier: ^2.4.0 version: 2.4.0(@tiptap/pm@2.0.3) @@ -6798,7 +6798,7 @@ packages: '@storybook/preview-api': 7.6.7 '@storybook/theming': 7.6.7(react-dom@18.2.0)(react@18.2.0) '@storybook/types': 7.6.7 - '@types/lodash': 4.14.202 + '@types/lodash': 4.17.6 color-convert: 2.0.1 dequal: 2.0.3 lodash: 4.17.21 @@ -6819,11 +6819,11 @@ packages: - supports-color dev: true - /@storybook/builder-manager@8.1.10(prettier@3.0.0): + /@storybook/builder-manager@8.1.10(prettier@3.3.2): resolution: {integrity: sha512-dhg54zpaglR9XKNAiwMqm5/IONMCEG/hO/iTfNHJI1rAGeWhvM71cmhF+VlKUcjpTlIfHe7J19+TL+sWQJNgtg==} dependencies: '@fal-works/esbuild-plugin-global-externals': 2.1.2 - '@storybook/core-common': 8.1.10(prettier@3.0.0) + '@storybook/core-common': 8.1.10(prettier@3.3.2) '@storybook/manager': 8.1.10 '@storybook/node-logger': 8.1.10 '@types/ejs': 3.1.5 @@ -6927,12 +6927,12 @@ packages: '@babel/types': 7.24.7 '@ndelangen/get-tarball': 3.0.9 '@storybook/codemod': 8.1.10 - '@storybook/core-common': 8.1.10(prettier@3.0.0) + '@storybook/core-common': 8.1.10(prettier@3.3.2) '@storybook/core-events': 8.1.10 - '@storybook/core-server': 8.1.10(prettier@3.0.0)(react-dom@18.2.0)(react@18.2.0) + '@storybook/core-server': 8.1.10(prettier@3.3.2)(react-dom@18.2.0)(react@18.2.0) '@storybook/csf-tools': 8.1.10 '@storybook/node-logger': 8.1.10 - '@storybook/telemetry': 8.1.10(prettier@3.0.0) + '@storybook/telemetry': 8.1.10(prettier@3.3.2) '@storybook/types': 8.1.10 '@types/semver': 7.5.8 '@yarnpkg/fslib': 2.10.3 @@ -7071,7 +7071,7 @@ packages: - supports-color dev: true - /@storybook/core-common@8.1.10(prettier@3.0.0): + /@storybook/core-common@8.1.10(prettier@3.3.2): resolution: {integrity: sha512-+0GhgDRQwUlXu1lY77NdLnVBVycCEW0DG7eu7rvLYYkTyNRxbdl2RWsQpjr/j4sxqT6u82l9/b+RWpmsl4MgMQ==} peerDependencies: prettier: ^2 || ^3 @@ -7100,8 +7100,8 @@ packages: node-fetch: 2.7.0 picomatch: 2.3.1 pkg-dir: 5.0.0 - prettier: 3.0.0 - prettier-fallback: /prettier@3.0.0 + prettier: 3.3.2 + prettier-fallback: /prettier@3.3.2 pretty-hrtime: 1.0.3 resolve-from: 5.0.0 semver: 7.6.2 @@ -7133,16 +7133,16 @@ packages: ts-dedent: 2.2.0 dev: true - /@storybook/core-server@8.1.10(prettier@3.0.0)(react-dom@18.2.0)(react@18.2.0): + /@storybook/core-server@8.1.10(prettier@3.3.2)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-jNL5/daNyo7Rcu+y/bOmSB1P65pmcaLwvpr31EUEIISaAqvgruaneS3GKHg2TR0wcxEoHaM4abqhW6iwkI/XYQ==} dependencies: '@aw-web-design/x-default-browser': 1.4.126 '@babel/core': 7.24.7 '@babel/parser': 7.24.7 '@discoveryjs/json-ext': 0.5.7 - '@storybook/builder-manager': 8.1.10(prettier@3.0.0) + '@storybook/builder-manager': 8.1.10(prettier@3.3.2) '@storybook/channels': 8.1.10 - '@storybook/core-common': 8.1.10(prettier@3.0.0) + '@storybook/core-common': 8.1.10(prettier@3.3.2) '@storybook/core-events': 8.1.10 '@storybook/csf': 0.1.11 '@storybook/csf-tools': 8.1.10 @@ -7152,7 +7152,7 @@ packages: '@storybook/manager-api': 8.1.10(react-dom@18.2.0)(react@18.2.0) '@storybook/node-logger': 8.1.10 '@storybook/preview-api': 8.1.10 - '@storybook/telemetry': 8.1.10(prettier@3.0.0) + '@storybook/telemetry': 8.1.10(prettier@3.3.2) '@storybook/types': 8.1.10 '@types/detect-port': 1.3.5 '@types/diff': 5.2.1 @@ -7594,11 +7594,11 @@ packages: qs: 6.12.3 dev: true - /@storybook/telemetry@8.1.10(prettier@3.0.0): + /@storybook/telemetry@8.1.10(prettier@3.3.2): resolution: {integrity: sha512-pwiMWrq85D0AnaAgYNfB2w2BDgqnetQ+tXwsUAw4fUEFwA4oPU6r0uqekRbNNE6wmSSYjiiFP3JgknBFqjd2hg==} dependencies: '@storybook/client-logger': 8.1.10 - '@storybook/core-common': 8.1.10(prettier@3.0.0) + '@storybook/core-common': 8.1.10(prettier@3.3.2) '@storybook/csf-tools': 8.1.10 chalk: 4.1.2 detect-package-manager: 2.0.1 @@ -7912,20 +7912,6 @@ packages: pretty-format: 27.5.1 dev: true - /@testing-library/dom@8.20.1: - resolution: {integrity: sha512-/DiOQ5xBxgdYRC8LNk7U+RWat0S3qRLeIw3ZIkMQ9kkVlRmwD/Eg8k8CqIpD6GW7u20JIUOfMKbxtiLutpjQ4g==} - engines: {node: '>=12'} - dependencies: - '@babel/code-frame': 7.24.7 - '@babel/runtime': 7.24.7 - '@types/aria-query': 5.0.4 - aria-query: 5.1.3 - chalk: 4.1.2 - dom-accessibility-api: 0.5.16 - lz-string: 1.5.0 - pretty-format: 27.5.1 - dev: true - /@testing-library/dom@9.3.4: resolution: {integrity: sha512-FlS4ZWlp97iiNWig0Muq8p+3rVDjRiYE+YKGbAqXOu9nwJFFOdL00kFpz42M+4huzYi86vAK1sOOfyOG45muIQ==} engines: {node: '>=14'} @@ -7963,7 +7949,7 @@ packages: react-dom: ^18.0.0 dependencies: '@babel/runtime': 7.24.7 - '@testing-library/dom': 8.20.1 + '@testing-library/dom': 9.3.4 '@types/react-dom': 18.2.18 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) @@ -8570,7 +8556,6 @@ packages: /@types/lodash@4.17.6: resolution: {integrity: sha512-OpXEVoCKSS3lQqjx9GGGOapBeuW5eUboYHRlHP9urXPX25IKZ6AnP5ZRxtVf63iieUbsHxLn8NQ5Nlftc6yzAA==} - dev: false /@types/mdast@3.0.15: resolution: {integrity: sha512-LnwD+mUEfxWMa1QpDraczIn6k0Ee3SMicuYSSzS6ZYl2gKS09EClnJYGd8Du6rfc5r/GZEk5o1mRb8TaTj03sQ==} @@ -21847,9 +21832,9 @@ packages: use-sync-external-store: 1.2.0(react@18.2.0) dev: false - github.com/theopensystemslab/planx-core/b43b268(@types/react@18.2.45): - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/b43b268} - id: github.com/theopensystemslab/planx-core/b43b268 + github.com/theopensystemslab/planx-core/75127e6(@types/react@18.2.45): + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/75127e6} + id: github.com/theopensystemslab/planx-core/75127e6 name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/editor.planx.uk/src/@planx/components/FindProperty/Public/Map.tsx b/editor.planx.uk/src/@planx/components/FindProperty/Public/Map.tsx index 6e88d7393e..554e77e804 100644 --- a/editor.planx.uk/src/@planx/components/FindProperty/Public/Map.tsx +++ b/editor.planx.uk/src/@planx/components/FindProperty/Public/Map.tsx @@ -63,7 +63,7 @@ export default function PlotNewAddress(props: PlotNewAddressProps): FCReturn { const [environment, boundaryBBox] = useStore((state) => [ state.previewEnvironment, - state.teamSettings.boundaryBbox, + state.teamSettings.boundaryBBox, ]); useEffect(() => { diff --git a/editor.planx.uk/src/components/Header.test.tsx b/editor.planx.uk/src/components/Header.test.tsx index 94e370320e..e3e2cfee26 100644 --- a/editor.planx.uk/src/components/Header.test.tsx +++ b/editor.planx.uk/src/components/Header.test.tsx @@ -26,7 +26,7 @@ const mockTeam1: Team = { linkColour: "#0010A4", favicon: null, }, - teamSettings: { + settings: { boundaryUrl: "https://www.planning.data.gov.uk/", helpEmail: "example@council.co.uk", helpPhone: "(01234) 56789", @@ -52,7 +52,7 @@ const mockTeam2: Team = { linkColour: "#0010A4", favicon: null, }, - teamSettings: { + settings: { boundaryUrl: "https://www.planning.data.gov.uk/", helpEmail: "example@council.co.uk", helpPhone: "(01234) 56789", @@ -74,7 +74,7 @@ describe("Header Component - Editor Route", () => { setState({ previewEnvironment: "editor", teamName: mockTeam1.name, - teamSettings: mockTeam1.teamSettings, + teamSettings: mockTeam1.settings, teamTheme: mockTeam1.theme, teamSlug: mockTeam1.slug, user: { diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/GeneralSettings/BoundaryForm.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/GeneralSettings/BoundaryForm.tsx index 2c3185c52a..767ebd75ec 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Settings/GeneralSettings/BoundaryForm.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/GeneralSettings/BoundaryForm.tsx @@ -47,7 +47,7 @@ export default function BoundaryForm({ formikConfig, onSuccess }: FormProps) { const isUpdateSuccess = await useStore.getState().updateTeamSettings({ boundaryUrl: values.boundaryUrl, - boundaryBbox: convertToBoundingBox(data), + boundaryBBox: convertToBoundingBox(data), }); if (isUpdateSuccess) { onSuccess(); diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/GeneralSettings/index.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/GeneralSettings/index.tsx index b2ee94db39..b57672a2c5 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Settings/GeneralSettings/index.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/GeneralSettings/index.tsx @@ -28,7 +28,7 @@ const GeneralSettings: React.FC = () => { if (!fetchedTeam) throw Error("Unable to find team"); setFormikConfig({ - initialValues: fetchedTeam.teamSettings, + initialValues: fetchedTeam.settings, onSubmit: () => {}, validateOnBlur: false, validateOnChange: false, diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/team.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/team.ts index 5a2a2080a0..00a334b171 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/team.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/team.ts @@ -45,7 +45,7 @@ export const teamStore: StateCreator< teamId: team.id, teamIntegrations: team.integrations, teamName: team.name, - teamSettings: team.teamSettings, + teamSettings: team.settings, teamSlug: team.slug, teamTheme: team.theme, }); @@ -60,7 +60,7 @@ export const teamStore: StateCreator< id: get().teamId, integrations: get().teamIntegrations, name: get().teamName, - teamSettings: get().teamSettings, + settings: get().teamSettings, slug: get().teamSlug, theme: get().teamTheme, }), diff --git a/editor.planx.uk/src/pages/Pay/InviteToPay.tsx b/editor.planx.uk/src/pages/Pay/InviteToPay.tsx index 9b5ad7973c..ec9d1a52c5 100644 --- a/editor.planx.uk/src/pages/Pay/InviteToPay.tsx +++ b/editor.planx.uk/src/pages/Pay/InviteToPay.tsx @@ -26,7 +26,9 @@ const FormInner = styled(Box)(({ theme }) => ({ const InviteToPay: React.FC = ({ createdAt }) => { const theme = useTheme(); const expiryDate = getExpiryDateForPaymentRequest(createdAt); - const team = useStore((state) => state.getTeam()); + const { helpEmail, helpOpeningHours, helpPhone } = useStore( + (state) => state.teamSettings, + ); return ( <> @@ -70,18 +72,14 @@ const InviteToPay: React.FC = ({ createdAt }) => { - Telephone {team.notifyPersonalisation?.helpPhone} - - - {team.notifyPersonalisation?.helpOpeningHours} + Telephone {helpPhone} + {helpOpeningHours} Email{" "} - - {team.notifyPersonalisation?.helpEmail} - + {helpEmail} We aim to respond within 2 working days. diff --git a/editor.planx.uk/src/routes/teamSettings.tsx b/editor.planx.uk/src/routes/teamSettings.tsx index 75f14a89b7..8427b37501 100644 --- a/editor.planx.uk/src/routes/teamSettings.tsx +++ b/editor.planx.uk/src/routes/teamSettings.tsx @@ -22,7 +22,7 @@ const teamSettingsRoutes = compose( })), mount({ - "/": redirect("./team"), + "/": redirect("./general"), "/:tab": map(async (req) => { const isAuthorised = useStore.getState().canUserEditTeam(req.params.team); diff --git a/editor.planx.uk/src/routes/views/draft.tsx b/editor.planx.uk/src/routes/views/draft.tsx index e21bb6d3ac..881988884f 100644 --- a/editor.planx.uk/src/routes/views/draft.tsx +++ b/editor.planx.uk/src/routes/views/draft.tsx @@ -77,13 +77,13 @@ const fetchSettingsForDraftView = async ( helpPhone: help_phone helpOpeningHours: help_opening_hours emailReplyToId: email_reply_to_id + boundaryBBox: boundary_bbox } integrations { hasPlanningData: has_planning_data } slug } - settings slug name } diff --git a/editor.planx.uk/src/routes/views/published.tsx b/editor.planx.uk/src/routes/views/published.tsx index da8eb891bd..a97a426a52 100644 --- a/editor.planx.uk/src/routes/views/published.tsx +++ b/editor.planx.uk/src/routes/views/published.tsx @@ -103,13 +103,13 @@ export const fetchSettingsForPublishedView = async ( helpPhone: help_phone helpOpeningHours: help_opening_hours emailReplyToId: email_reply_to_id + boundaryBBox: boundary_bbox } integrations { hasPlanningData: has_planning_data } slug } - settings status publishedFlows: published_flows( limit: 1 diff --git a/editor.planx.uk/src/routes/views/standalone.tsx b/editor.planx.uk/src/routes/views/standalone.tsx index 027bfd7ccf..8de2a37b67 100644 --- a/editor.planx.uk/src/routes/views/standalone.tsx +++ b/editor.planx.uk/src/routes/views/standalone.tsx @@ -77,13 +77,13 @@ const fetchDataForStandaloneView = async ( helpPhone: help_phone helpOpeningHours: help_opening_hours emailReplyToId: email_reply_to_id + boundaryBBox: boundary_bbox } integrations { hasPlanningData: has_planning_data } slug } - settings } globalSettings: global_settings { diff --git a/hasura.planx.uk/migrations/1720511391883_run_sql_migration/down.sql b/hasura.planx.uk/migrations/1720511391883_run_sql_migration/down.sql new file mode 100644 index 0000000000..f8befa0df9 --- /dev/null +++ b/hasura.planx.uk/migrations/1720511391883_run_sql_migration/down.sql @@ -0,0 +1,28 @@ +-- Previous version of teams_summary view from 1713084872473_create_view_teams_summary/up.sql + +CREATE OR REPLACE VIEW "public"."teams_summary" AS SELECT + t.id, + t.name, + t.slug, + t.reference_code, + t.settings->>'homepage' as homepage, + t.domain as subdomain, + ti.has_planning_data as planning_data_enabled, + '@todo' as article_4s_enabled, + t.notify_personalisation as govnotify_personalisation, + CASE + WHEN coalesce(ti.production_govpay_secret, ti.staging_govpay_secret) is not null + THEN true + ELSE false + END as govpay_enabled, + t.submission_email as send_to_email_address, + coalesce(ti.production_bops_submission_url, ti.staging_bops_submission_url) as bops_submission_url, + tt.logo, + tt.favicon, + tt.primary_colour, + tt.link_colour, + tt.action_colour +FROM teams t + JOIN team_integrations ti on ti.team_id = t.id + JOIN team_themes tt on tt.team_id = t.id +ORDER BY t.name ASC; diff --git a/hasura.planx.uk/migrations/1720511391883_run_sql_migration/up.sql b/hasura.planx.uk/migrations/1720511391883_run_sql_migration/up.sql new file mode 100644 index 0000000000..32ffa2afde --- /dev/null +++ b/hasura.planx.uk/migrations/1720511391883_run_sql_migration/up.sql @@ -0,0 +1,32 @@ +CREATE OR REPLACE VIEW "public"."teams_summary" AS SELECT + t.id, + t.name, + t.slug, + t.reference_code, + t.settings->>'homepage' as homepage, + t.domain as subdomain, + ti.has_planning_data as planning_data_enabled, + '@todo' as article_4s_enabled, + jsonb_build_object( + 'helpEmail', ts.help_email, + 'helpPhone', ts.help_phone, + 'emailReplyToId', ts.email_reply_to_id, + 'helpOpeningHours', ts.help_opening_hours + ) as govnotify_personalisation, + CASE + WHEN coalesce(ti.production_govpay_secret, ti.staging_govpay_secret) is not null + THEN true + ELSE false + END as govpay_enabled, + t.submission_email as send_to_email_address, + coalesce(ti.production_bops_submission_url, ti.staging_bops_submission_url) as bops_submission_url, + tt.logo, + tt.favicon, + tt.primary_colour, + tt.link_colour, + tt.action_colour +FROM teams t + JOIN team_integrations ti on ti.team_id = t.id + JOIN team_themes tt on tt.team_id = t.id + JOIN team_settings ts on ts.team_id = t.id +ORDER BY t.name ASC;