Skip to content

Commit

Permalink
馃毀(frontend) useProducts with generated api client
Browse files Browse the repository at this point in the history
  • Loading branch information
rlecellier committed Feb 24, 2023
1 parent 0a4b2d4 commit f401adc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/frontend/js/hooks/useProduct.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { defineMessages } from 'react-intl';
import { Product } from 'types/Joanie';
import { useResource, UseResourcesProps } from 'hooks/useResources';
import { Product } from 'api/joanie/gen';
import { joanieApi } from 'api/joanie';
import { useJoanieApi } from 'data/JoanieApiProvider';
import { ResourcesQuery, useResource, UseResourcesProps } from 'hooks/useResources';

const messages = defineMessages({
errorGet: {
Expand All @@ -21,7 +22,15 @@ const messages = defineMessages({
*/
const props: UseResourcesProps<Product> = {
queryKey: ['products'],
apiInterface: () => useJoanieApi().products,
apiInterface: () => ({
get: async (filters?: ResourcesQuery) => {
if (filters?.id) {
return joanieApi.products.productsRead(filters?.id);
}
// FIXME: openapi schema doesn't contain productsList
useJoanieApi().products.get(filters);
},
}),
messages,
};

Expand Down

0 comments on commit f401adc

Please sign in to comment.