Skip to content

Commit

Permalink
create a page to see the course created
Browse files Browse the repository at this point in the history
  • Loading branch information
BaptTF committed Apr 26, 2024
1 parent 43c01fe commit 279d48c
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 12 deletions.
20 changes: 10 additions & 10 deletions frontend/src/lib/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<RequestArgs> => {
// verify required parameter 'fournisseur' is not null or undefined
assertParamExists('getCourse', 'fournisseur', fournisseur)
getCourse: async (fournisseur?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/course`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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<GetCourse200Response>> {
async getCourse(fournisseur?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetCourse200Response>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getCourse(fournisseur, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
Expand All @@ -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<GetCourse200Response> {
getCourse(fournisseur?: string, options?: any): AxiosPromise<GetCourse200Response> {
return localVarFp.getCourse(fournisseur, options).then((request) => request(axios, basePath));
},
};
Expand All @@ -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));
}
}
Expand Down
20 changes: 18 additions & 2 deletions frontend/src/lib/requests/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
RefillsApiFactory,
CarouselApiFactory,
CategoriesApiFactory,
TransactionsApiFactory
TransactionsApiFactory,
CourseApiFactory,
} from '$lib/api';
import { api, local_token } from '$lib/config/config';

Expand Down Expand Up @@ -160,4 +161,19 @@ export const cashMovementsApi = () => {
}
})
);
};
};

export const CourseApi = () => {
return CourseApiFactory(
new Configuration({
basePath: api(),
apiKey: (name: string) => {
if (name == 'X-Local-Token') {
return local_token();
} else {
return '';
}
}
})
);
}
50 changes: 50 additions & 0 deletions frontend/src/routes/panel/products/course/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<script lang="ts">
import { api } from '$lib/config/config';
import { CourseApi } from '$lib/requests/requests';
import type { CourseItem, Item } from '$lib/api';
let items: CourseItem[] = [];
CourseApi()
.getCourse('promocash', {
withCredentials: true
})
.then((res) => {
items = res.data.items;
});
</script>

<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
<thead class="bg-gray-50 dark:bg-slate-800">
<tr>
<th scope="col" class="px-6 py-3">
<span
class="text-center text-xs font-semibold uppercase tracking-wide text-gray-800 dark:text-gray-200"
>
Nom
</span>
</th>
<th scope="col" class="px-6 py-3">
<span
class="text-center text-xs font-semibold uppercase tracking-wide text-gray-800 dark:text-gray-200"
>
Nombre à acheter
</span>
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 dark:divide-gray-700">
{#each items as item}
<td class="h-px">
<p class="py-3 px-2 block border-gray-200 border-2 rounded-md text-sm focus:border-blue-500 focus:ring-blue-500 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400">
{item.item.name}
</p>
</td>
<td class="h-px">
<p class="py-3 px-2 block border-gray-200 border-2 rounded-md text-sm focus:border-blue-500 focus:ring-blue-500 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400">
{item.amountToBuy}
</p>
</td>
{/each}
</tbody>
</table>

0 comments on commit 279d48c

Please sign in to comment.