diff --git a/console/public/locales/en.json b/console/public/locales/en.json index da527eabb..902b35d77 100644 --- a/console/public/locales/en.json +++ b/console/public/locales/en.json @@ -41,11 +41,15 @@ "create": { "action": "Create Campaign", "title": "New Campaign", - "description": "Select a campaign type you would like to create." + "description": "Select a campaign type you would like to create.", + "setup_failed": "The campaign was created, but its setup didn't finish" }, "details": { "title": "Campaign", - "description": "Configure your campaign settings and preview how it will appear to users." + "description": "Configure your campaign settings and preview how it will appear to users.", + "no_templates": "This campaign has no template yet.", + "create_template": "Create template", + "save_failed": "Couldn't save the campaign" }, "provider": { "title": "Select Provider", @@ -184,12 +188,20 @@ "upload_hint": "Click to browse and select an image" } } - } + }, + "save_failed": "Couldn't save the template", + "publish_failed": "Couldn't publish the campaign", + "create_failed": "Couldn't create the template" }, "review": { "title": "Review", "description": "Review your campaign before sending." - } + }, + "channel_unsupported": "This channel type is not yet supported.", + "duplicate_failed": "Couldn't duplicate the campaign", + "archive_failed": "Couldn't archive the campaign", + "unarchive_failed": "Couldn't unarchive the campaign", + "subscriptions_load_failed": "Couldn't load subscriptions." }, "channel_list": "Channels", "channels": { @@ -237,7 +249,9 @@ "cancel": "Cancel", "create": "Create Locale" } - } + }, + "load_failed": "Couldn't load locales.", + "create_failed": "Couldn't add the language" }, "provider": { "select": { @@ -1180,5 +1194,6 @@ "user_journeys_load_failed": "Couldn't load journeys.", "user_organizations_load_failed": "Couldn't load organizations.", "user_subscriptions_load_failed": "Couldn't load subscriptions.", - "users_load_failed": "Couldn't load users." + "users_load_failed": "Couldn't load users.", + "campaigns_load_failed": "Couldn't load campaigns." } diff --git a/console/src/api.test.ts b/console/src/api.test.ts new file mode 100644 index 000000000..ee4281e78 --- /dev/null +++ b/console/src/api.test.ts @@ -0,0 +1,33 @@ +import { afterEach, describe, expect, it, vi } from "vitest" +import api, { client } from "./api" + +describe("api.campaigns.templates.update", () => { + afterEach(() => vi.restoreAllMocks()) + + function patchBody() { + return vi.mocked(client.patch).mock.calls[0][1] + } + + // The server ignores a null sender; clearing only works with the nil UUID. + it("sends a cleared sender as the nil UUID", async () => { + vi.spyOn(client, "patch").mockResolvedValue({ data: {} }) + + await api.campaigns.templates.update("p1", "c1", "t1", { + data: { body: "Hi" }, + sender_identity_id: null, + }) + + expect(patchBody()).toEqual({ + data: { body: "Hi" }, + sender_identity_id: "00000000-0000-0000-0000-000000000000", + }) + }) + + it("leaves the sender out when it isn't changed", async () => { + vi.spyOn(client, "patch").mockResolvedValue({ data: {} }) + + await api.campaigns.templates.update("p1", "c1", "t1", { data: { body: "Hi" } }) + + expect(patchBody()).toEqual({ data: { body: "Hi" } }) + }) +}) diff --git a/console/src/api.ts b/console/src/api.ts index 9f93f0dfd..8054cd228 100644 --- a/console/src/api.ts +++ b/console/src/api.ts @@ -52,6 +52,9 @@ import type { } from "./types" import type { UUID } from "@/types/common" +// The server reads a null sender_identity_id as "leave it"; the nil UUID clears it. +const NIL_UUID = "00000000-0000-0000-0000-000000000000" + declare module "axios" { export interface AxiosRequestConfig { skipAuthRedirect?: boolean @@ -470,12 +473,14 @@ const api = { projectId: UUID, campaignId: UUID, templateId: UUID, - params: TemplateUpdateParams, + { sender_identity_id, ...params }: TemplateUpdateParams, ) => await client .patch