diff --git a/packages/client-graphql/docs/inbox/1.methods.md b/packages/client-graphql/docs/inbox/1.methods.md index 01076377..4b498033 100644 --- a/packages/client-graphql/docs/inbox/1.methods.md +++ b/packages/client-graphql/docs/inbox/1.methods.md @@ -6,7 +6,7 @@ import { Inbox } from "@trycourier/client-graphql"; const inboxApi = Inbox(authorization: Authorization); const getInboxCount = async (params?: { - accountId?: string, + tenantId?: string, status?: "read" | "unread", tags?: string[], }) => { @@ -23,7 +23,7 @@ import { Inbox } from "@trycourier/client-graphql"; const inboxApi = Inbox(authorization: Authorization); const getInboxMessages = async (params?: { - accountId?: string, + tenantId?: string, status?: "read" | "unread", tags?: string[], }) => { diff --git a/packages/client-graphql/src/inbox/__tests__/count.spec.ts b/packages/client-graphql/src/inbox/__tests__/count.spec.ts index 0b468393..a62b863c 100644 --- a/packages/client-graphql/src/inbox/__tests__/count.spec.ts +++ b/packages/client-graphql/src/inbox/__tests__/count.spec.ts @@ -21,7 +21,7 @@ describe("getInboxCount", () => { Array [ "https://fxw3r7gdm9.execute-api.us-east-1.amazonaws.com/production/q", Object { - "body": "{\\"query\\":\\"query GetInboxCount($params: FilterParamsInput) {\\\\n count(params: $params)\\\\n}\\\\n\\",\\"operationName\\":\\"GetInboxCount\\",\\"variables\\":{}}", + "body": "{\\"query\\":\\"query GetInboxCount($params: FilterParamsInput) {\\\\n count(params: $params)\\\\n}\\\\n\\",\\"operationName\\":\\"GetInboxCount\\",\\"variables\\":{\\"params\\":{}}}", "headers": Object { "content-type": "application/json", "x-courier-client-key": "CLIENT_KEY", diff --git a/packages/client-graphql/src/inbox/count.ts b/packages/client-graphql/src/inbox/count.ts index dbfaddeb..9fa05359 100644 --- a/packages/client-graphql/src/inbox/count.ts +++ b/packages/client-graphql/src/inbox/count.ts @@ -7,7 +7,7 @@ export const GET_INBOX_COUNT = ` `; export interface IInboxCountParams { - accountId?: string; + tenantId?: string; status: "read" | "unread"; tags?: string[]; from?: string | number; @@ -23,9 +23,15 @@ export const getInboxCount = return Promise.resolve(); } + const { tenantId, ...rest } = params || {}; + const results = await client .query(GET_INBOX_COUNT, { - params, + params: { + ...rest, + // [HACK] map tenantId to accountId in order to keep this backwards compatible + accountId: tenantId, + }, }) .toPromise(); return results?.data; diff --git a/packages/client-graphql/src/inbox/messages.ts b/packages/client-graphql/src/inbox/messages.ts index 6c85f421..404d0d97 100644 --- a/packages/client-graphql/src/inbox/messages.ts +++ b/packages/client-graphql/src/inbox/messages.ts @@ -2,7 +2,7 @@ import { Client } from "urql"; import { IActionElemental } from "./message"; export interface IGetInboxMessagesParams { - accountId?: string; + tenantId?: string; archived?: boolean; from?: string | number; limit?: number; @@ -100,13 +100,15 @@ export const getInboxMessages = return Promise.resolve(undefined); } - const { limit, ...restParams } = params ?? {}; + const { limit, tenantId, ...restParams } = params ?? {}; const results = await client .query(createGetInboxMessagesQuery(!after), { after, limit, params: { ...restParams, + // [HACK] map tenantId to accountId in order to keep this backwards compatible + accountId: tenantId, pinned: false, }, pinnedParams: { diff --git a/packages/client-graphql/src/messages.ts b/packages/client-graphql/src/messages.ts index afed9af3..06599eab 100644 --- a/packages/client-graphql/src/messages.ts +++ b/packages/client-graphql/src/messages.ts @@ -9,7 +9,7 @@ export const GET_MESSAGE_COUNT = ` `; export interface IMessageCountParams { - accountId?: string; + tenantId?: string; tags?: string[]; from?: number; isRead?: boolean; @@ -31,7 +31,7 @@ export const getMessageCount = }; export interface IGetMessagesParams { - accountId?: string; + tenantId?: string; from?: number; isRead?: boolean; limit?: number; @@ -136,9 +136,17 @@ export const getMessages = return Promise.resolve(undefined); } - const { limit, ...restParams } = params ?? {}; + const { limit, tenantId, ...restParams } = params ?? {}; const results = await client - .query(QUERY_MESSAGES, { after, limit, params: restParams }) + .query(QUERY_MESSAGES, { + after, + limit, + params: { + ...restParams, + // [HACK] map tenantId to accountId in order to keep this backwards compatible + accountId: tenantId, + }, + }) .toPromise(); const messages = results?.data?.messages?.nodes; diff --git a/packages/client-graphql/src/preferences.ts b/packages/client-graphql/src/preferences.ts index 3f8102d8..e6e13341 100644 --- a/packages/client-graphql/src/preferences.ts +++ b/packages/client-graphql/src/preferences.ts @@ -88,30 +88,31 @@ const DRAFT_PREFERENCE_PAGE = ` } `; -type GetRecipientPreferences = (accountId?: string) => Promise; +type GetRecipientPreferences = (tenantId?: string) => Promise; export const getRecipientPreferences = (client: Client | undefined): GetRecipientPreferences => - async (accountId?: string) => { + async (tenantId?: string) => { if (!client) { return; } const results = await client - .query(RECIPIENT_PREFERENCES, { accountId }) + .query(RECIPIENT_PREFERENCES, { accountId: tenantId }) .toPromise(); return results.data?.recipientPreferences.nodes; }; -type GetPreferencePage = (accountId?: string) => Promise; +type GetPreferencePage = (tenantId?: string) => Promise; export const getPreferencePage = (client: Client | undefined): GetPreferencePage => - async (accountId?: string) => { + async (tenantId?: string) => { if (!client) { return; } const results = await client .query(PREFERENCE_PAGE, { - accountId: accountId, + // [HACK] map tenantId to accountId in order to keep this backwards compatible + accountId: tenantId, }) .toPromise(); return results.data?.preferencePage; @@ -140,7 +141,7 @@ type UpdateRecipientPreferences = (payload: { hasCustomRouting: boolean; routingPreferences: Array; digestSchedule: string; - accountId?: string; + tenantId?: string; }) => Promise; export const updateRecipientPreferences = (client: Client | undefined): UpdateRecipientPreferences => @@ -158,7 +159,7 @@ export const updateRecipientPreferences = routingPreferences: payload.routingPreferences, digestSchedule: payload.digestSchedule, }, - accountId: payload.accountId, + accountId: payload.tenantId, }) .toPromise(); diff --git a/packages/components/src/components/PreferencePage.tsx b/packages/components/src/components/PreferencePage.tsx index 9acedeee..a456fa10 100644 --- a/packages/components/src/components/PreferencePage.tsx +++ b/packages/components/src/components/PreferencePage.tsx @@ -32,16 +32,16 @@ const FooterContainer = styled.div` `; const PreferencePage: React.FunctionComponent<{ - accountId?: string; + tenantId?: string; draft?: boolean; -}> = ({ accountId, draft = false }) => { +}> = ({ tenantId, draft = false }) => { return (
- +