feat(packages): implement package-based business model
This commit is contained in:
@@ -14,6 +14,19 @@ export interface EventData {
|
||||
};
|
||||
}
|
||||
|
||||
export interface PackageData {
|
||||
id: number;
|
||||
name: string;
|
||||
max_photos: number;
|
||||
}
|
||||
|
||||
export interface EventPackage {
|
||||
id: number;
|
||||
used_photos: number;
|
||||
expires_at: string;
|
||||
package: PackageData;
|
||||
}
|
||||
|
||||
export interface EventStats {
|
||||
onlineGuests: number;
|
||||
tasksSolved: number;
|
||||
@@ -39,4 +52,13 @@ export async function fetchStats(slug: string): Promise<EventStats> {
|
||||
tasksSolved: json.tasksSolved ?? 0,
|
||||
latestPhotoAt: json.latestPhotoAt ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getEventPackage(slug: string): Promise<EventPackage | null> {
|
||||
const res = await fetch(`/api/v1/events/${slug}/package`);
|
||||
if (!res.ok) {
|
||||
if (res.status === 404) return null;
|
||||
throw new Error('Failed to load event package');
|
||||
}
|
||||
return await res.json();
|
||||
}
|
||||
Reference in New Issue
Block a user