diff --git a/src/api/itemPublish.ts b/src/api/itemPublish.ts index 893b006f..9695817f 100644 --- a/src/api/itemPublish.ts +++ b/src/api/itemPublish.ts @@ -14,4 +14,4 @@ export const publishItem = async ( axios .get(`${API_HOST}/${buildItemPublishRoute(id, notification)}`) .then(({ data }) => data), - ); + ); diff --git a/src/api/routes.ts b/src/api/routes.ts index 75239712..73bb97f1 100644 --- a/src/api/routes.ts +++ b/src/api/routes.ts @@ -277,8 +277,12 @@ export const buildPostInvitationsRoute = (itemId: UUID) => export const buildResendInvitationRoute = (args: { itemId: UUID; id: UUID }) => `${ITEMS_ROUTE}/${args.itemId}/${INVITATIONS_ROUTE}/${args.id}/send`; -export const buildItemPublishRoute = (itemId: UUID, notification: boolean) => - `${ITEMS_ROUTE}/${itemId}/publish${qs.stringify(notification)}`; +export const buildItemPublishRoute = (itemId: UUID, notification: boolean) => { + const queryString = notification + ? qs.stringify({ notification }, { addQueryPrefix: true }) + : ''; + return `${ITEMS_ROUTE}/${itemId}/publish${queryString}`; +}; export const API_ROUTES = { APPS_ROUTE, diff --git a/src/mutations/itemPublish.test.ts b/src/mutations/itemPublish.test.ts index 3c2858cb..067580c7 100644 --- a/src/mutations/itemPublish.test.ts +++ b/src/mutations/itemPublish.test.ts @@ -6,9 +6,7 @@ import { StatusCodes } from 'http-status-codes'; import { mockMutation, setUpTest, waitForMutation } from '../../test/utils'; import { REQUEST_METHODS } from '../api/utils'; import { buildItemTagsKey, MUTATION_KEYS } from '../config/keys'; -import { - buildItemPublishRoute, -} from '../api/routes'; +import { buildItemPublishRoute } from '../api/routes'; import { publishItemRoutine } from '../routines'; import { ITEMS, ITEM_TAGS, UNAUTHORIZED_RESPONSE } from '../../test/constants'; @@ -90,7 +88,7 @@ describe('Publish Item', () => { await waitForMutation(); }); - // expect(queryClient.getQueryState(itemTagKey)?.isInvalidated).toBeTruthy(); + // expect(queryClient.getQueryState(itemTagKey)?.isInvalidated).toBeTruthy(); expect(mockedNotifier).toHaveBeenCalledWith( expect.objectContaining({ type: publishItemRoutine.FAILURE, diff --git a/src/mutations/itemPublish.ts b/src/mutations/itemPublish.ts index f7808b2e..abb26efe 100644 --- a/src/mutations/itemPublish.ts +++ b/src/mutations/itemPublish.ts @@ -11,7 +11,8 @@ export default (queryClient: QueryClient, queryConfig: QueryClientConfig) => { * @param notification {boolean} send out email notification */ queryClient.setMutationDefaults(MUTATION_KEYS.PUBLISH_ITEM, { - mutationFn: ({ id, notification }) => Api.publishItem(id, notification, queryConfig ), + mutationFn: ({ id, notification }) => + Api.publishItem(id, notification, queryConfig), onSuccess: () => { notifier?.({ type: publishItemRoutine.SUCCESS }); }, diff --git a/src/mutations/member.test.ts b/src/mutations/member.test.ts index 27109dcc..51e0e1d7 100644 --- a/src/mutations/member.test.ts +++ b/src/mutations/member.test.ts @@ -129,7 +129,6 @@ describe('Member Mutations', () => { }); it(`Unauthorized`, async () => { - // set random data in cache queryClient.setQueryData(CURRENT_MEMBER_KEY, MEMBER_RESPONSE); const endpoints = [ diff --git a/src/mutations/member.ts b/src/mutations/member.ts index 7540788c..9d71dc60 100644 --- a/src/mutations/member.ts +++ b/src/mutations/member.ts @@ -23,7 +23,8 @@ export default (queryClient: QueryClient, queryConfig: QueryClientConfig) => { const { notifier } = queryConfig; queryClient.setMutationDefaults(MUTATION_KEYS.DELETE_MEMBER, { - mutationFn: (payload) => Api.deleteMember(payload, queryConfig).then(() => + mutationFn: (payload) => + Api.deleteMember(payload, queryConfig).then(() => Api.signOut(queryConfig), ), onSuccess: () => { diff --git a/src/routines/itemPublish.ts b/src/routines/itemPublish.ts index cc45ea12..7a1c7323 100644 --- a/src/routines/itemPublish.ts +++ b/src/routines/itemPublish.ts @@ -1,4 +1,4 @@ import createRoutine from './utils'; /* eslint-disable import/prefer-default-export */ -export const publishItemRoutine = createRoutine('PUBLISH_ITEM'); \ No newline at end of file +export const publishItemRoutine = createRoutine('PUBLISH_ITEM');