reworked the guest pwa, modernized start and gallery page. added share link functionality.

This commit is contained in:
Codex Agent
2025-11-10 22:25:25 +01:00
parent 1e8810ca51
commit 1cec116933
22 changed files with 1208 additions and 476 deletions

View File

@@ -134,3 +134,43 @@ export async function uploadPhoto(eventToken: string, file: File, taskId?: numbe
const json = await res.json();
return json.photo_id ?? json.id ?? json.data?.id ?? 0;
}
export async function createPhotoShareLink(eventToken: string, photoId: number): Promise<{ slug: string; url: string; expires_at?: string }> {
const headers = getCsrfHeaders();
const res = await fetch(`/api/v1/events/${encodeURIComponent(eventToken)}/photos/${photoId}/share`, {
method: 'POST',
credentials: 'include',
headers,
});
if (!res.ok) {
let payload: any = null;
try {
payload = await res.clone().json();
} catch {}
const error: UploadError = new Error(payload?.error?.message ?? 'Share link creation failed');
error.code = payload?.error?.code ?? 'share_failed';
error.status = res.status;
throw error;
}
return res.json();
}
export async function fetchPhotoShare(slug: string) {
const res = await fetch(`/api/v1/photo-shares/${encodeURIComponent(slug)}`, {
headers: { Accept: 'application/json' },
});
if (!res.ok) {
const payload = await res.json().catch(() => null);
const error: UploadError = new Error(payload?.error?.message ?? 'Share link unavailable');
error.code = payload?.error?.code ?? 'share_unavailable';
error.status = res.status;
throw error;
}
return res.json();
}