Skip to content

Commit

Permalink
fix: fix route
Browse files Browse the repository at this point in the history
  • Loading branch information
louisewang1 committed Jun 17, 2022
1 parent 3beb96c commit 2f42b0e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/api/itemPublish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export const publishItem = async (
axios
.get(`${API_HOST}/${buildItemPublishRoute(id, notification)}`)
.then(({ data }) => data),
);
);
8 changes: 6 additions & 2 deletions src/api/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions src/mutations/itemPublish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/mutations/itemPublish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
},
Expand Down
1 change: 0 additions & 1 deletion src/mutations/member.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ describe('Member Mutations', () => {
});

it(`Unauthorized`, async () => {

// set random data in cache
queryClient.setQueryData(CURRENT_MEMBER_KEY, MEMBER_RESPONSE);
const endpoints = [
Expand Down
3 changes: 2 additions & 1 deletion src/mutations/member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {
Expand Down
2 changes: 1 addition & 1 deletion src/routines/itemPublish.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import createRoutine from './utils';

/* eslint-disable import/prefer-default-export */
export const publishItemRoutine = createRoutine('PUBLISH_ITEM');
export const publishItemRoutine = createRoutine('PUBLISH_ITEM');

0 comments on commit 2f42b0e

Please sign in to comment.