domaino/app-admin/src/routes/+layout.server.ts
agent e29eaaa8e8 Show prices in the shop currency (STRIPE_CURRENCY), not hard-coded EUR
formatPrice always formatted EUR, so the public shop, checkout, basket
and order confirmation showed € even when Stripe charged another
currency. It now takes a currency; both apps pass STRIPE_CURRENCY to the
blocks as layout data `currency` (like `timezone`), so one setting drives
what Stripe charges and every price shown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qq6FzyGitv5gDZEcCHDGoo
2026-10-25 14:48:12 +00:00

25 lines
869 B
TypeScript

import { env } from '$env/dynamic/private';
import { defaultColors } from '$lib/types';
import { shopCurrency } from '$shared/calendar';
import type { LayoutServerLoad } from './$types';
async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
try {
const record = await pb.collection('globals').getFirstListItem(pb.filter('key = {:key}', { key }));
return record.data || fallback;
} catch {
return fallback;
}
}
export const load: LayoutServerLoad = async ({ locals }) => {
const colors = await getGlobal(locals.pb, 'colors', defaultColors);
return {
user: locals.user,
colors,
// Admin dates/times are entered and shown in the site's timezone, and
// prices in the shop currency — same settings the booking emails use.
timezone: env.SITE_TIMEZONE || 'Europe/Oslo',
currency: shopCurrency(env.STRIPE_CURRENCY)
};
};