Skip to content

Commit

Permalink
fix: fix parameters for get categories
Browse files Browse the repository at this point in the history
  • Loading branch information
louisewang1 committed Nov 28, 2021
1 parent 981b3c9 commit a9e4a1a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/api/category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getCategoryTypes = async ({ API_HOST }: QueryClientConfig) => {
return res.json();
};

export const getCategories = async (typeId: UUID[], { API_HOST }: QueryClientConfig) => {
export const getCategories = async ({ API_HOST }: QueryClientConfig, typeId?: UUID[], ) => {
console.log(typeId);
console.log(buildGetCategoriesRoute(typeId));
const res = await fetch(`${API_HOST}/${buildGetCategoriesRoute(typeId)}`, DEFAULT_GET).then(
Expand Down
2 changes: 1 addition & 1 deletion src/api/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const buildRestoreItemsRoute = (ids: UUID[]) =>
)}`;

export const GET_CATEGORY_TYPES_ROUTE = `${ITEMS_ROUTE}/category-types`
export const buildGetCategoriesRoute = (ids: UUID[]) =>
export const buildGetCategoriesRoute = (ids?: UUID[]) =>
`${ITEMS_ROUTE}/categories?${qs.stringify(
{ type: ids },
{ arrayFormat: 'repeat' }
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export default (queryConfig: QueryClientConfig) => {
});

// get categories
const useCategories = (typeId: UUID[]) =>
const useCategories = (typeId?: UUID[]) =>
useQuery({
queryKey: buildCategoriesKey(typeId),
queryFn: () => Api.getCategories(typeId, queryConfig).then((data) => List(data)),
queryFn: () => Api.getCategories(queryConfig, typeId).then((data) => List(data)),
...defaultOptions,
});

Expand Down

0 comments on commit a9e4a1a

Please sign in to comment.