Skip to content

Commit f401adc

Browse files
committed
🚧(frontend) useProducts with generated api client
1 parent 0a4b2d4 commit f401adc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/frontend/js/hooks/useProduct.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { defineMessages } from 'react-intl';
2-
import { Product } from 'types/Joanie';
3-
import { useResource, UseResourcesProps } from 'hooks/useResources';
2+
import { Product } from 'api/joanie/gen';
3+
import { joanieApi } from 'api/joanie';
44
import { useJoanieApi } from 'data/JoanieApiProvider';
5+
import { ResourcesQuery, useResource, UseResourcesProps } from 'hooks/useResources';
56

67
const messages = defineMessages({
78
errorGet: {
@@ -21,7 +22,15 @@ const messages = defineMessages({
2122
*/
2223
const props: UseResourcesProps<Product> = {
2324
queryKey: ['products'],
24-
apiInterface: () => useJoanieApi().products,
25+
apiInterface: () => ({
26+
get: async (filters?: ResourcesQuery) => {
27+
if (filters?.id) {
28+
return joanieApi.products.productsRead(filters?.id);
29+
}
30+
// FIXME: openapi schema doesn't contain productsList
31+
useJoanieApi().products.get(filters);
32+
},
33+
}),
2534
messages,
2635
};
2736

0 commit comments

Comments
 (0)