diff --git a/AquaNet/src/components/Pagination.svelte b/AquaNet/src/components/Pagination.svelte index 8e6625e0..00516087 100644 --- a/AquaNet/src/components/Pagination.svelte +++ b/AquaNet/src/components/Pagination.svelte @@ -14,7 +14,8 @@ } function updatePage(newPage: number) { - if (newPage > 0 && newPage <= totalPages) dispatch('updatePage', newPage) + const p = Math.floor(Number(newPage)) + if (!isNaN(p) && p > 0 && p <= totalPages) dispatch('updatePage', p) } function startEditing() { @@ -37,7 +38,7 @@ {#if editing} - + {:else} e.key === 'Enter' && startEditing()}> Page {page} of {totalPages} diff --git a/AquaNet/src/libs/sdk.ts b/AquaNet/src/libs/sdk.ts index a6187a65..9f2341d7 100644 --- a/AquaNet/src/libs/sdk.ts +++ b/AquaNet/src/libs/sdk.ts @@ -16,6 +16,14 @@ import type { GameName } from './scoring' export type ExportGameName = GameName | 'diva' +export interface PhotoPage { + photos: string[] + page: number + pageSize: number + total: number + totalPages: number +} + interface ExtReqInit extends RequestInit { params?: { [index: string]: string } json?: any @@ -28,7 +36,8 @@ interface ExtReqInit extends RequestInit { * @param callback Callback for modification */ export function reconstructUrl(input: URL | RequestInfo, callback: (url: URL) => URL | void): RequestInfo | URL { - let u = new URL((input instanceof Request) ? input.url : input) + const base = typeof window !== 'undefined' ? window.location.origin : 'http://localhost' + let u = new URL((input instanceof Request) ? input.url : input, base) const result = callback(u) if (result) u = result if (input instanceof Request) { @@ -232,7 +241,9 @@ export const CARD = { export const GAME = { trend: (username: string, game: GameName): Promise => post(`/api/v2/game/${game}/trend`, { username }), - photos: (): Promise => + photos: (page: number = 1, size: number = 12): Promise => + post(`/api/v2/game/mai2/my-photo`, { page, size }), + allPhotos: (): Promise => post(`/api/v2/game/mai2/my-photo`, { }), userSummary: (username: string, game: GameName): Promise => post(`/api/v2/game/${game}/user-summary`, { username }), diff --git a/AquaNet/src/pages/MaiPhoto.svelte b/AquaNet/src/pages/MaiPhoto.svelte index 70770b6b..92cfe60b 100644 --- a/AquaNet/src/pages/MaiPhoto.svelte +++ b/AquaNet/src/pages/MaiPhoto.svelte @@ -1,11 +1,80 @@ -
@@ -13,22 +82,31 @@

{t("maiphoto.title")}

- {#await GAME.photos()} + {#if loading && !photoData} - {:then photos} - {#if photos.length === 0} -
{t('maiphoto.none')}
- {/if} -
- {#each photos as photo} -
- Mai Photo -
- {/each} -
- {:catch error} + {:else if error} - {/await} + {:else if photoData} + {#if photoData.total === 0} +
{t('maiphoto.none')}
+ {:else} + {#if photoData.totalPages > 1} + + {/if} + +
+ {#each photoData.photos as photo (photo)} +
+ Mai Memorial Photo +
+ {/each} +
+ + {#if photoData.totalPages > 1} + + {/if} + {/if} + {/if}