Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openfun/richie
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f401adc4aed114730f37d5d31fa83e4784a88233
Choose a base ref
..
head repository: openfun/richie
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a49e6ef38e7e997507a44eb0237a783adaf00ed7
Choose a head ref
Showing with 13 additions and 4 deletions.
  1. +5 −0 src/frontend/js/api/joanie/gen/services/ProductsService.ts
  2. +8 −4 src/frontend/js/hooks/useProduct.ts
5 changes: 5 additions & 0 deletions src/frontend/js/api/joanie/gen/services/ProductsService.ts
Original file line number Diff line number Diff line change
@@ -13,18 +13,23 @@ export class ProductsService {
/**
* API ViewSet for all interactions with products.
* @param id primary key for the record as UUID
* @param course
* @returns Product
* @throws ApiError
*/
public productsRead(
id: string,
course?: string,
): CancelablePromise<Product> {
return this.httpRequest.request({
method: 'GET',
url: '/products/{id}/',
path: {
'id': id,
},
query: {
'course': course,
},
});
}

12 changes: 8 additions & 4 deletions src/frontend/js/hooks/useProduct.ts
Original file line number Diff line number Diff line change
@@ -17,17 +17,21 @@ const messages = defineMessages({
},
});

interface UseProductReadQuery extends ResourcesQuery {
course?: string;
}

/**
* Joanie Api hook to retrieve a product through its id.
*/
const props: UseResourcesProps<Product> = {
queryKey: ['products'],
apiInterface: () => ({
get: async (filters?: ResourcesQuery) => {
if (filters?.id) {
return joanieApi.products.productsRead(filters?.id);
get: async (filters?: UseProductReadQuery) => {
const { id, course } = filters || {};
if (id) {
return joanieApi.products.productsRead(id, course);
}
// FIXME: openapi schema doesn't contain productsList
useJoanieApi().products.get(filters);
},
}),