From 279d48c8585b7b871cf3e59de37bbf86482bd112 Mon Sep 17 00:00:00 2001 From: JULLIEN Baptiste Date: Sat, 27 Apr 2024 00:35:01 +0200 Subject: [PATCH] create a page to see the course created --- frontend/src/lib/api/api.ts | 20 ++++---- frontend/src/lib/requests/requests.ts | 20 +++++++- .../routes/panel/products/course/+page.svelte | 50 +++++++++++++++++++ 3 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 frontend/src/routes/panel/products/course/+page.svelte diff --git a/frontend/src/lib/api/api.ts b/frontend/src/lib/api/api.ts index fa9605f..2615127 100644 --- a/frontend/src/lib/api/api.ts +++ b/frontend/src/lib/api/api.ts @@ -5005,13 +5005,11 @@ export const CourseApiAxiosParamCreator = function (configuration?: Configuratio return { /** * Get generated course - * @param {string} fournisseur Fournisseur name + * @param {string} [fournisseur] Fournisseur name * @param {*} [options] Override http request option. * @throws {RequiredError} */ - getCourse: async (fournisseur: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'fournisseur' is not null or undefined - assertParamExists('getCourse', 'fournisseur', fournisseur) + getCourse: async (fournisseur?: string, options: AxiosRequestConfig = {}): Promise => { const localVarPath = `/course`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); @@ -5024,6 +5022,8 @@ export const CourseApiAxiosParamCreator = function (configuration?: Configuratio const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication admin_auth required + if (fournisseur !== undefined) { localVarQueryParameter['fournisseur'] = fournisseur; } @@ -5051,11 +5051,11 @@ export const CourseApiFp = function(configuration?: Configuration) { return { /** * Get generated course - * @param {string} fournisseur Fournisseur name + * @param {string} [fournisseur] Fournisseur name * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async getCourse(fournisseur: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + async getCourse(fournisseur?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getCourse(fournisseur, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, @@ -5071,11 +5071,11 @@ export const CourseApiFactory = function (configuration?: Configuration, basePat return { /** * Get generated course - * @param {string} fournisseur Fournisseur name + * @param {string} [fournisseur] Fournisseur name * @param {*} [options] Override http request option. * @throws {RequiredError} */ - getCourse(fournisseur: string, options?: any): AxiosPromise { + getCourse(fournisseur?: string, options?: any): AxiosPromise { return localVarFp.getCourse(fournisseur, options).then((request) => request(axios, basePath)); }, }; @@ -5090,12 +5090,12 @@ export const CourseApiFactory = function (configuration?: Configuration, basePat export class CourseApi extends BaseAPI { /** * Get generated course - * @param {string} fournisseur Fournisseur name + * @param {string} [fournisseur] Fournisseur name * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof CourseApi */ - public getCourse(fournisseur: string, options?: AxiosRequestConfig) { + public getCourse(fournisseur?: string, options?: AxiosRequestConfig) { return CourseApiFp(this.configuration).getCourse(fournisseur, options).then((request) => request(this.axios, this.basePath)); } } diff --git a/frontend/src/lib/requests/requests.ts b/frontend/src/lib/requests/requests.ts index 6de5ba3..e9fa7dc 100644 --- a/frontend/src/lib/requests/requests.ts +++ b/frontend/src/lib/requests/requests.ts @@ -8,7 +8,8 @@ import { RefillsApiFactory, CarouselApiFactory, CategoriesApiFactory, - TransactionsApiFactory + TransactionsApiFactory, + CourseApiFactory, } from '$lib/api'; import { api, local_token } from '$lib/config/config'; @@ -160,4 +161,19 @@ export const cashMovementsApi = () => { } }) ); -}; \ No newline at end of file +}; + +export const CourseApi = () => { + return CourseApiFactory( + new Configuration({ + basePath: api(), + apiKey: (name: string) => { + if (name == 'X-Local-Token') { + return local_token(); + } else { + return ''; + } + } + }) + ); +} \ No newline at end of file diff --git a/frontend/src/routes/panel/products/course/+page.svelte b/frontend/src/routes/panel/products/course/+page.svelte new file mode 100644 index 0000000..b9e4e1a --- /dev/null +++ b/frontend/src/routes/panel/products/course/+page.svelte @@ -0,0 +1,50 @@ + + + + + + + + + + + {#each items as item} + + + {/each} + +
+ + Nom + + + + Nombre à acheter + +
+

+ {item.item.name} +

+
+

+ {item.amountToBuy} +

+
+