diff --git a/src/export/digitalPlanning/model.test.ts b/src/export/digitalPlanning/model.test.ts index e099f1d6..9386bb42 100644 --- a/src/export/digitalPlanning/model.test.ts +++ b/src/export/digitalPlanning/model.test.ts @@ -26,7 +26,9 @@ const mockMetadataForSession = ( team: { name: teamSlug, slug: teamSlug, - referenceCode: referenceCode, + settings: { + referenceCode: referenceCode, + }, }, }, }); diff --git a/src/export/digitalPlanning/model.ts b/src/export/digitalPlanning/model.ts index bf75ebfa..30f14b63 100644 --- a/src/export/digitalPlanning/model.ts +++ b/src/export/digitalPlanning/model.ts @@ -986,7 +986,7 @@ export class DigitalPlanning { private getMetadata(): Payload["metadata"] { return { id: this.sessionId, - organisation: this.metadata.flow.team.referenceCode, + organisation: this.metadata.flow.team.settings.referenceCode, submittedAt: new Date().toISOString(), source: "PlanX", service: { diff --git a/src/requests/session.ts b/src/requests/session.ts index cfda41bb..7107eac0 100644 --- a/src/requests/session.ts +++ b/src/requests/session.ts @@ -172,7 +172,9 @@ export async function getSessionMetadata( team { name slug - referenceCode: reference_code + settings: team_settings { + referenceCode: reference_code + } } } } diff --git a/src/requests/team.ts b/src/requests/team.ts index 02ccc7ef..a77abed8 100644 --- a/src/requests/team.ts +++ b/src/requests/team.ts @@ -96,11 +96,6 @@ export async function createTeam( client: GraphQLClient, newTeam: NewTeam, ): Promise { - const input = { - ...newTeam, - settings: newTeam.settings ?? {}, - theme: newTeam.theme ?? {}, - }; const response: { insert_teams_one: { id: number } } = await client.request( gql` mutation CreateTeam( @@ -108,7 +103,6 @@ export async function createTeam( $slug: String! $domain: String $submissionEmail: String - $referenceCode: String $settings: team_settings_insert_input! $theme: team_themes_insert_input! ) { @@ -118,7 +112,6 @@ export async function createTeam( slug: $slug domain: $domain submission_email: $submissionEmail - reference_code: $referenceCode # Create empty records for associated tables - these can get populated later team_settings: { data: $settings } theme: { data: $theme } @@ -129,7 +122,29 @@ export async function createTeam( } } `, - input, + { + ...newTeam, + settings: { + boundary_url: newTeam?.settings?.boundaryUrl, + boundary_bbox: newTeam?.settings?.boundaryBBox, + reference_code: newTeam?.settings?.referenceCode, + help_email: newTeam?.settings?.helpEmail, + help_phone: newTeam?.settings?.helpPhone, + help_opening_hours: newTeam?.settings?.helpOpeningHours, + email_reply_to_id: newTeam?.settings?.emailReplyToId, + homepage: newTeam?.settings?.homepage, + external_planning_site_url: newTeam?.settings?.externalPlanningSiteUrl, + external_planning_site_name: + newTeam?.settings?.externalPlanningSiteName, + }, + theme: { + primary_colour: newTeam.theme?.primaryColour, + action_colour: newTeam.theme?.actionColour, + link_colour: newTeam.theme?.linkColour, + logo: newTeam.theme?.logo, + favicon: newTeam.theme?.favicon, + }, + }, ); return response.insert_teams_one.id; } diff --git a/src/types/session.ts b/src/types/session.ts index 33aa39af..838b312f 100644 --- a/src/types/session.ts +++ b/src/types/session.ts @@ -69,7 +69,9 @@ export type SessionMetadata = { team: { name: string; slug: string; - referenceCode: string; + settings: { + referenceCode: string; + }; }; }; };