diff --git a/src/lib/api/schemas.gen.ts b/src/lib/api/schemas.gen.ts index 69fd063..8dbf7e7 100644 --- a/src/lib/api/schemas.gen.ts +++ b/src/lib/api/schemas.gen.ts @@ -1,5 +1,25 @@ // This file is auto-generated by @hey-api/openapi-ts +export const $DrawMethod = { + properties: { + data: { + type: 'string' + }, + draw_method_id: { + type: 'string' + }, + method: { + enum: ['first_n', 'chance'], + type: 'string' + }, + name: { + type: 'string' + } + }, + required: ['draw_method_id', 'name', 'method', 'data'], + type: 'object' +} as const; + export const $ErrorResponse = { properties: { code: { @@ -51,6 +71,12 @@ export const $FieldConfig = { export const $Game = { properties: { + google_sheet_id: { + type: 'string' + }, + google_sheet_tab_name: { + type: 'string' + }, id: { type: 'string' }, @@ -62,6 +88,13 @@ export const $Game = { type: 'object' } as const; +export const $GetDrawMethodsResponse = { + items: { + '$ref': '#/definitions/DrawMethod' + }, + type: 'array' +} as const; + export const $GetGameResponse = { '$ref': '#/definitions/Game' } as const; @@ -188,6 +221,9 @@ export const $Prize = { id: { type: 'string' }, + image_url: { + type: 'string' + }, name: { type: 'string' } @@ -201,6 +237,9 @@ export const $PublicPrize = { description: { type: 'string' }, + image_url: { + type: 'string' + }, name: { type: 'string' } @@ -231,7 +270,7 @@ export const $User = { type: 'string' } }, - required: ['id', 'game_id', 'email', 'address', 'phone', 'additional_fields'], + required: ['id', 'game_id', 'additional_fields'], type: 'object' } as const; diff --git a/src/lib/api/services.gen.ts b/src/lib/api/services.gen.ts index 689125a..6e57f01 100644 --- a/src/lib/api/services.gen.ts +++ b/src/lib/api/services.gen.ts @@ -1,10 +1,15 @@ // This file is auto-generated by @hey-api/openapi-ts import { createClient, createConfig, type Options } from '@hey-api/client-fetch'; -import type { GetGamesError, GetGamesResponse2, GetGameData, GetGameError, GetGameResponse2, GetParticipationMethodsData, GetParticipationMethodsError, GetParticipationMethodsResponse2, GetPrizesData, GetPrizesError, GetPrizesResponse2, GetUsersData, GetUsersError, GetUsersResponse2, GetUserData, GetUserError, GetUserResponse2, GetWonPrizesData, GetWonPrizesError, GetWonPrizesResponse2 } from './types.gen'; +import type { GetDrawMethodsData, GetDrawMethodsError, GetDrawMethodsResponse2, GetGamesError, GetGamesResponse2, GetGameData, GetGameError, GetGameResponse2, GetParticipationMethodsData, GetParticipationMethodsError, GetParticipationMethodsResponse2, GetPrizesData, GetPrizesError, GetPrizesResponse2, GetUsersData, GetUsersError, GetUsersResponse2, GetUserData, GetUserError, GetUserResponse2, GetWonPrizesData, GetWonPrizesError, GetWonPrizesResponse2 } from './types.gen'; export const client = createClient(createConfig()); +export const getDrawMethods = (options?: Options) => { return (options?.client ?? client).get({ + ...options, + url: '/draw-methods' +}); }; + export const getGames = (options?: Options) => { return (options?.client ?? client).get({ ...options, url: '/games' diff --git a/src/lib/api/types.gen.ts b/src/lib/api/types.gen.ts index 3d11481..5a87a18 100644 --- a/src/lib/api/types.gen.ts +++ b/src/lib/api/types.gen.ts @@ -1,5 +1,12 @@ // This file is auto-generated by @hey-api/openapi-ts +export type DrawMethod = { + data: string; + draw_method_id: string; + method: 'first_n' | 'chance'; + name: string; +}; + export type ErrorResponse = { code: string; error: string; @@ -21,10 +28,14 @@ export type FieldConfig = { }; export type Game = { + google_sheet_id?: string; + google_sheet_tab_name?: string; id: string; name: string; }; +export type GetDrawMethodsResponse = Array; + export type GetGameResponse = Game; export type GetGamesResponse = Array; @@ -72,11 +83,13 @@ export type Prize = { description: string; gameId: string; id: string; + image_url?: string; name: string; }; export type PublicPrize = { description: string; + image_url?: string; name: string; }; @@ -84,11 +97,11 @@ export type User = { additional_fields: { [key: string]: unknown; }; - address: string; - email: string; + address?: string; + email?: string; game_id: string; id: string; - phone: string; + phone?: string; }; export type WonPrize = { @@ -97,6 +110,17 @@ export type WonPrize = { user: User; }; +export type GetDrawMethodsData = { + query?: { + gameId?: string; + participationMethodId?: string; + }; +}; + +export type GetDrawMethodsResponse2 = GetDrawMethodsResponse; + +export type GetDrawMethodsError = ErrorResponse; + export type GetGamesResponse2 = GetGamesResponse; export type GetGamesError = ErrorResponse; @@ -164,6 +188,29 @@ export type GetWonPrizesResponse2 = GetWonPrizesResponse; export type GetWonPrizesError = ErrorResponse; export type $OpenApiTs = { + '/draw-methods': { + get: { + req: GetDrawMethodsData; + res: { + /** + * GetDrawMethodsResponse + */ + '200': GetDrawMethodsResponse; + /** + * ErrorResponse + */ + '400': ErrorResponse; + /** + * ErrorResponse + */ + '403': ErrorResponse; + /** + * ErrorResponse + */ + '500': ErrorResponse; + }; + }; + }; '/games': { get: { res: { diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 58e8ca8..ce1589c 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -65,26 +65,29 @@ Dashboard - - - Prizes - - - - Won Prizes - - - - Users - - - - Participation Methods - - - - Draw Methods - + {#if data.selectedGameId} + + + Prizes + + + + Won Prizes + + + + Users + + + + Participation Methods + + + + Draw Methods + + {/if} diff --git a/src/routes/games/[gameId]/draw-methods/+page.server.ts b/src/routes/games/[gameId]/draw-methods/+page.server.ts new file mode 100644 index 0000000..7843be9 --- /dev/null +++ b/src/routes/games/[gameId]/draw-methods/+page.server.ts @@ -0,0 +1,7 @@ +import type { PageServerLoad } from './$types'; +import { getDrawMethods } from '$lib/api'; + +export const load: PageServerLoad = async () => { + const res = await getDrawMethods(); + return { drawMethods: res.data! }; +}; \ No newline at end of file diff --git a/src/routes/games/[gameId]/draw-methods/+page.svelte b/src/routes/games/[gameId]/draw-methods/+page.svelte new file mode 100644 index 0000000..ee88664 --- /dev/null +++ b/src/routes/games/[gameId]/draw-methods/+page.svelte @@ -0,0 +1,11 @@ + + +Draw Methods + + \ No newline at end of file diff --git a/src/routes/games/[gameId]/draw-methods/DataTable.svelte b/src/routes/games/[gameId]/draw-methods/DataTable.svelte new file mode 100644 index 0000000..c434c9f --- /dev/null +++ b/src/routes/games/[gameId]/draw-methods/DataTable.svelte @@ -0,0 +1,67 @@ + + +
+ + + {#each $headerRows as headerRow} + + + {#each headerRow.cells as cell (cell.id)} + + + + + + {/each} + + + {/each} + + + {#each $pageRows as row (row.id)} + + + {#each row.cells as cell (cell.id)} + + + + + + {/each} + + + {/each} + + +
\ No newline at end of file diff --git a/src/routes/games/[gameId]/participation-methods/EditParticipationMethod.svelte b/src/routes/games/[gameId]/participation-methods/EditParticipationMethod.svelte index a6a0931..f3566eb 100644 --- a/src/routes/games/[gameId]/participation-methods/EditParticipationMethod.svelte +++ b/src/routes/games/[gameId]/participation-methods/EditParticipationMethod.svelte @@ -15,7 +15,7 @@ - + Edit {participationMethod.name} @@ -32,6 +32,10 @@ User Fields +
+ Participation Fields + +