Add deterministic daily weather brief

This commit is contained in:
zv
2026-06-11 20:27:10 +02:00
parent 47a292b26e
commit 49265e7c51
16 changed files with 590 additions and 60 deletions

View File

@@ -12,7 +12,14 @@ export async function fetchVapidPublicKey(signal?: AbortSignal) {
return response.json() as Promise<VapidKeyResponse>;
}
export async function savePushSubscription(subscription: PushSubscription, province: Province, language: Language) {
interface SavePushSubscriptionOptions {
morningBriefEnabled?: boolean;
latitude?: number | null;
longitude?: number | null;
locationName?: string | null;
}
export async function savePushSubscription(subscription: PushSubscription, province: Province, language: Language, options: SavePushSubscriptionOptions = {}) {
const response = await fetch("/api/notifications/subscriptions", {
method: "POST",
headers: { "content-type": "application/json" },
@@ -21,6 +28,10 @@ export async function savePushSubscription(subscription: PushSubscription, provi
province,
language,
enabled: true,
morningBriefEnabled: options.morningBriefEnabled === true,
latitude: options.latitude ?? null,
longitude: options.longitude ?? null,
locationName: options.locationName ?? null,
}),
});
if (!response.ok) throw new Error("Unable to save push subscription.");