Compare commits
No commits in common. "19b8bb121f23f42c3185006444a323c37b48b84c" and "de8d29beb4eb52867eb94df39a20ef0d20232d09" have entirely different histories.
19b8bb121f
...
de8d29beb4
12 changed files with 65 additions and 4035 deletions
|
|
@ -6,9 +6,6 @@
|
||||||
STRIPE_SECRET_KEY=sk_test_...
|
STRIPE_SECRET_KEY=sk_test_...
|
||||||
PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
|
PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
|
||||||
STRIPE_WEBHOOK_SECRET=whsec_...
|
STRIPE_WEBHOOK_SECRET=whsec_...
|
||||||
# Shop currency (ISO 4217, e.g. eur, nok): what Stripe charges in and what
|
|
||||||
# every price on the site, in the admin and in booking emails is shown in.
|
|
||||||
# Item prices are entered in this currency.
|
|
||||||
STRIPE_CURRENCY=eur
|
STRIPE_CURRENCY=eur
|
||||||
|
|
||||||
# Shared by PocketBase and the public app so the public app can record
|
# Shared by PocketBase and the public app so the public app can record
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ To add an email block type: add to `EmailBlockType` in `packages/shared/src/type
|
||||||
- Create/edit forms open in `$lib/admin/Modal.svelte`; destructive submits use `confirmSubmit()` from `$lib/admin/confirm` (returning `false` from a handler does not cancel).
|
- Create/edit forms open in `$lib/admin/Modal.svelte`; destructive submits use `confirmSubmit()` from `$lib/admin/confirm` (returning `false` from a handler does not cancel).
|
||||||
- Server actions wrap PocketBase writes in `attempt()` from `$lib/server/actions` so failures show as an error banner, not a 500.
|
- Server actions wrap PocketBase writes in `attempt()` from `$lib/server/actions` so failures show as an error banner, not a 500.
|
||||||
- Editors with unsaved state use `use:enhance` + `warnOnUnsavedChanges()`.
|
- Editors with unsaved state use `use:enhance` + `warnOnUnsavedChanges()`.
|
||||||
- **Dates, times and prices shown to people** use `DISPLAY_LOCALE` (`en-GB`: day-month-year, 24-hour clock) and the helpers in `$shared/calendar` (`formatInstant`, `formatPrice` with the shop `currency`, `formatDateTime`) — never `toLocale*(undefined)`, which renders US formats on the server. Booking times on the public site are shown in `SITE_TIMEZONE` too (layout data `timezone`, read by blocks via `page.data.timezone`). Native `<input type="date">` fields follow the visitor's browser language and can't be changed from the page.
|
- **Dates, times and prices shown to people** use `DISPLAY_LOCALE` (`en-GB`: day-month-year, 24-hour clock) and the helpers in `$shared/calendar` (`formatInstant`, `formatPrice`, `formatDateTime`) — never `toLocale*(undefined)`, which renders US formats on the server. Booking times on the public site are shown in `SITE_TIMEZONE` too (layout data `timezone`, read by blocks via `page.data.timezone`). Native `<input type="date">` fields follow the visitor's browser language and can't be changed from the page.
|
||||||
- **Dates/times in admin**: entered and displayed in `SITE_TIMEZONE` (layout data `timezone`), via `toZonedDatetimeInput`, `zonedInputToIso`, `formatDateTime` in `$shared/calendar`. Never `new Date(localInput)` on the server — the container runs in UTC.
|
- **Dates/times in admin**: entered and displayed in `SITE_TIMEZONE` (layout data `timezone`), via `toZonedDatetimeInput`, `zonedInputToIso`, `formatDateTime` in `$shared/calendar`. Never `new Date(localInput)` on the server — the container runs in UTC.
|
||||||
- **Prose**: `.prose-wellness` class for rich text content styling
|
- **Prose**: `.prose-wellness` class for rich text content styling
|
||||||
|
|
||||||
|
|
@ -185,7 +185,6 @@ cd app-public && npm run build
|
||||||
- `PUBLIC_SITE_URL` — public site URL used by the admin app for cross-subdomain preview links (`<scheme>://www.${DOMAIN}<port>`).
|
- `PUBLIC_SITE_URL` — public site URL used by the admin app for cross-subdomain preview links (`<scheme>://www.${DOMAIN}<port>`).
|
||||||
- `SMTP_HOST`, `SMTP_PORT`, `SMTP_USER`, `SMTP_PASS`, `EMAIL_FROM`, `EMAIL_FROM_NAME` — Brevo SMTP relay for booking emails (both apps). Empty `SMTP_HOST` = log emails instead of sending.
|
- `SMTP_HOST`, `SMTP_PORT`, `SMTP_USER`, `SMTP_PASS`, `EMAIL_FROM`, `EMAIL_FROM_NAME` — Brevo SMTP relay for booking emails (both apps). Empty `SMTP_HOST` = log emails instead of sending.
|
||||||
- `SITE_TIMEZONE` — IANA timezone for booking times in emails (default `Europe/Oslo`).
|
- `SITE_TIMEZONE` — IANA timezone for booking times in emails (default `Europe/Oslo`).
|
||||||
- `STRIPE_CURRENCY` — shop currency (ISO 4217, default `eur`; e.g. `nok`). One setting for what Stripe charges and how prices are shown: PocketBase, both apps' layout data (`currency`, read by blocks via `page.data.currency`) and booking emails. Format prices with `formatPrice(amount, currency)` from `$shared/calendar` — never hard-code a currency.
|
|
||||||
- Secrets (Stripe, `INTERNAL_API_SECRET`, SMTP) are read from a root-level `.env` next to `docker-compose.yml`; see `.env.example`.
|
- Secrets (Stripe, `INTERNAL_API_SECRET`, SMTP) are read from a root-level `.env` next to `docker-compose.yml`; see `.env.example`.
|
||||||
- `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET` → PocketBase only. `INTERNAL_API_SECRET` → PocketBase and app-public (booking-email status). No app gets PocketBase superuser credentials.
|
- `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET` → PocketBase only. `INTERNAL_API_SECRET` → PocketBase and app-public (booking-email status). No app gets PocketBase superuser credentials.
|
||||||
- Shop listings are public data, loaded anonymously by `loadShopData()` in `packages/shared/src/server/shop.ts` (public layout and admin `/preview`; slots via `GET /api/shop/slots`); if a Shop block has nothing to show it says "Nothing is available".
|
- Shop listings are public data, loaded anonymously by `loadShopData()` in `packages/shared/src/server/shop.ts` (public layout and admin `/preview`; slots via `GET /api/shop/slots`); if a Shop block has nothing to show it says "Nothing is available".
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { env } from '$env/dynamic/private';
|
import { env } from '$env/dynamic/private';
|
||||||
import { defaultColors } from '$lib/types';
|
import { defaultColors } from '$lib/types';
|
||||||
import { shopCurrency } from '$shared/calendar';
|
|
||||||
import type { LayoutServerLoad } from './$types';
|
import type { LayoutServerLoad } from './$types';
|
||||||
|
|
||||||
async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
||||||
|
|
@ -20,6 +19,6 @@ export const load: LayoutServerLoad = async ({ locals }) => {
|
||||||
// Admin dates/times are entered and shown in the site's timezone, and
|
// Admin dates/times are entered and shown in the site's timezone, and
|
||||||
// prices in the shop currency — same settings the booking emails use.
|
// prices in the shop currency — same settings the booking emails use.
|
||||||
timezone: env.SITE_TIMEZONE || 'Europe/Oslo',
|
timezone: env.SITE_TIMEZONE || 'Europe/Oslo',
|
||||||
currency: shopCurrency(env.STRIPE_CURRENCY)
|
currency: (env.STRIPE_CURRENCY || 'eur').toUpperCase()
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import type { HeaderGlobal } from '$lib/types';
|
import type { HeaderGlobal } from '$lib/types';
|
||||||
import { getBasketContext } from '$lib/basket.svelte';
|
import { getBasketContext } from '$lib/basket.svelte';
|
||||||
import { DEFAULT_CURRENCY, formatPrice } from '$shared/calendar';
|
import { formatPrice } from '$shared/calendar';
|
||||||
|
|
||||||
let { header } = $props<{ header: HeaderGlobal }>();
|
let { header } = $props<{ header: HeaderGlobal }>();
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
return href === '/' ? path === '/' : path === href || path.startsWith(href + '/');
|
return href === '/' ? path === '/' : path === href || path.startsWith(href + '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatTotal = (amount: number) => formatPrice(amount, page.data.currency ?? DEFAULT_CURRENCY);
|
const formatTotal = formatPrice;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#snippet basketIcon()}
|
{#snippet basketIcon()}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { defaultColors, defaultFooter, defaultHeader } from '$lib/types';
|
||||||
import type { ItemRecord, SlotRecord } from '$lib/types';
|
import type { ItemRecord, SlotRecord } from '$lib/types';
|
||||||
import { BASKET_COOKIE, getBasket } from '$lib/server/shop';
|
import { BASKET_COOKIE, getBasket } from '$lib/server/shop';
|
||||||
import { loadShopData } from '$shared/server/shop';
|
import { loadShopData } from '$shared/server/shop';
|
||||||
import { DEFAULT_TIMEZONE, shopCurrency } from '$shared/calendar';
|
import { DEFAULT_TIMEZONE } from '$shared/calendar';
|
||||||
import { env } from '$env/dynamic/private';
|
import { env } from '$env/dynamic/private';
|
||||||
import type { LayoutServerLoad } from './$types';
|
import type { LayoutServerLoad } from './$types';
|
||||||
|
|
||||||
|
|
@ -44,8 +44,6 @@ export const load: LayoutServerLoad = async ({ locals, cookies, url }) => {
|
||||||
|
|
||||||
// Booking times are shown in the studio's timezone, wherever the visitor is.
|
// Booking times are shown in the studio's timezone, wherever the visitor is.
|
||||||
const timezone = env.SITE_TIMEZONE || DEFAULT_TIMEZONE;
|
const timezone = env.SITE_TIMEZONE || DEFAULT_TIMEZONE;
|
||||||
// Prices are shown in the currency Stripe charges in.
|
|
||||||
const currency = shopCurrency(env.STRIPE_CURRENCY);
|
|
||||||
|
|
||||||
return { header, footer, colors, user: locals.user, basket, items, slots, timezone, currency };
|
return { header, footer, colors, user: locals.user, basket, items, slots, timezone };
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,12 @@
|
||||||
<div class="text-sm text-charcoal/60">{formatSlotDate(line.start)}</div>
|
<div class="text-sm text-charcoal/60">{formatSlotDate(line.start)}</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<span>{formatPrice(line.price * line.quantity, data.currency)}</span>
|
<span>{formatPrice(line.price * line.quantity)}</span>
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
<div class="mt-4 flex justify-between border-t border-charcoal/10 pt-4 font-bold">
|
<div class="mt-4 flex justify-between border-t border-charcoal/10 pt-4 font-bold">
|
||||||
<span>Total</span><span>{formatPrice(data.order.total, data.currency)}</span>
|
<span>Total</span><span>{formatPrice(data.order.total)}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
# Site backups
|
|
||||||
|
|
||||||
CMS export files (the format of admin → **Backup** → Export). Import one in
|
|
||||||
admin → Backup → Import. Import **upserts by slug/key**: pages and site
|
|
||||||
design (header, footer, colours) with the same slug are overwritten, other
|
|
||||||
pages are left alone, and every image is uploaded again as a new media record.
|
|
||||||
|
|
||||||
| File | What it is |
|
|
||||||
| --- | --- |
|
|
||||||
| `cms-export-2026-08-19.json` | Earlier hand-built version of the site (pages `home`, `about`, `book`). |
|
|
||||||
| `evashafik-copy.json` | The current evashafik.com (Tilda) moved over as it is, page for page. |
|
|
||||||
| `evashafik-enhanced.json` | The same content, restructured to turn visitors into bookings, with the events calendar and online booking/payment. |
|
|
||||||
|
|
||||||
Both evashafik files were built from evashafik.com on 2026-10-25, text verbatim
|
|
||||||
and the original photos (resized to max 1600 px). They keep the old URLs
|
|
||||||
(`/aboutme`, `/sessions`, `/myprograms`, `/blog`, and the three article slugs),
|
|
||||||
so existing links and search results keep working.
|
|
||||||
|
|
||||||
## `evashafik-copy.json`
|
|
||||||
|
|
||||||
Pages: `home`, `aboutme`, `sessions`, `myprograms`, `blog`, the three
|
|
||||||
articles, and `book`.
|
|
||||||
|
|
||||||
What could not be copied one to one:
|
|
||||||
|
|
||||||
- **Booking popup** ("Book a Session — Just type your contacts"): the CMS has
|
|
||||||
no contact form, so *Book Now* goes to `/book`, which uses the CMS's Shop and
|
|
||||||
Checkout blocks instead.
|
|
||||||
- **Newsletter sign-up** ("Want to stay connected?"): left out. There is
|
|
||||||
no mailing-list backend behind it in the CMS.
|
|
||||||
- **Footer contacts**: the live site shows none, so the footer has none. Add an
|
|
||||||
email/phone under Site design.
|
|
||||||
- The live "Trauma and the brain" section of *Reclaim your pleasure and joy!*
|
|
||||||
contains leftover Tilda placeholder text ("Each type of visual aid…"). The
|
|
||||||
copy keeps it because the live page shows it. The enhanced version removes it.
|
|
||||||
|
|
||||||
## `evashafik-enhanced.json`
|
|
||||||
|
|
||||||
Same text and photos, plus:
|
|
||||||
|
|
||||||
- **Events**: new `/events` page and an "Upcoming workshops & events" calendar
|
|
||||||
on the home page. Both show what is entered under admin → Events (none are
|
|
||||||
included, so nothing invented goes live).
|
|
||||||
- **Booking and payment**: Shop blocks on `/sessions` (timed sessions) and
|
|
||||||
`/myprograms` (programme packages), and Shop + Checkout on `/book`.
|
|
||||||
- **Conversion**: a single "Book a session" call to action in the header, hero
|
|
||||||
and at the end of every page. Also a trust strip (10+ years, thousands of
|
|
||||||
clients, 1500 h Shiatsu training), "Who I work with" cards, testimonials
|
|
||||||
higher up and repeated near the booking points, a three-step "How it works",
|
|
||||||
and an FAQ. The FAQ answers come only from what the site already says
|
|
||||||
(boundaries, no intercourse, the first session is a talk, prices). Each
|
|
||||||
article ends with a booking prompt and "Read next".
|
|
||||||
Both versions fix obvious typos ("Complete Cirсle" with a Cyrillic с, "Cirle",
|
|
||||||
"advansed") and the broken "More about sessions" link (`http://`), which now
|
|
||||||
goes to `/sessions`.
|
|
||||||
|
|
||||||
### After importing: services to create (admin → Services & products)
|
|
||||||
|
|
||||||
Shop blocks list services, which are not part of an export. Until these exist
|
|
||||||
they show "Nothing is available". Prices are from the live site.
|
|
||||||
|
|
||||||
| Name | Type | Duration | Price (NOK) |
|
|
||||||
| --- | --- | --- | --- |
|
|
||||||
| Individual session, 60 min | bookable time | 60 | 2000 |
|
|
||||||
| Individual session, 90 min | bookable time | 90 | 2500 |
|
|
||||||
| Individual session, 120 min | bookable time | 120 | 3000 |
|
|
||||||
| Individual session, 150 min | bookable time | 150 | 3500 |
|
|
||||||
| Individual session, 180 min | bookable time | 180 | 4000 |
|
|
||||||
| Complete Circle (4 sessions) | product | | 10000 |
|
|
||||||
| Master Lover for singles (3 sessions) | product | | 7500 |
|
|
||||||
| Master Lover for couples (3 sessions) | product | | 7500 |
|
|
||||||
| The Art of Intimate Touch (3 sessions) | product | | 7500 |
|
|
||||||
|
|
||||||
Then generate time slots for the sessions under admin → Slots.
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -5,7 +5,7 @@
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import { DEFAULT_NOTES_HINT, DEFAULT_PRIVACY_NOTICE, type BasketLine, type CheckoutBlockData } from '$shared/types';
|
import { DEFAULT_NOTES_HINT, DEFAULT_PRIVACY_NOTICE, type BasketLine, type CheckoutBlockData } from '$shared/types';
|
||||||
import { getBasketContext } from '$shared/basket.svelte';
|
import { getBasketContext } from '$shared/basket.svelte';
|
||||||
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, formatInstant, formatPrice } from '$shared/calendar';
|
import { DEFAULT_TIMEZONE, formatInstant, formatPrice } from '$shared/calendar';
|
||||||
import { loadStripe } from '$shared/stripe-client';
|
import { loadStripe } from '$shared/stripe-client';
|
||||||
import type { Stripe, StripeElements, StripePaymentElement } from '@stripe/stripe-js';
|
import type { Stripe, StripeElements, StripePaymentElement } from '@stripe/stripe-js';
|
||||||
|
|
||||||
|
|
@ -43,15 +43,12 @@
|
||||||
lastSig = sig;
|
lastSig = sig;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Prices in the shop currency (STRIPE_CURRENCY, via layout data).
|
|
||||||
const currency = $derived<string>(page.data.currency ?? DEFAULT_CURRENCY);
|
|
||||||
|
|
||||||
const payLabel = $derived(
|
const payLabel = $derived(
|
||||||
payState === 'confirming'
|
payState === 'confirming'
|
||||||
? 'Confirming…'
|
? 'Confirming…'
|
||||||
: payState === 'creating'
|
: payState === 'creating'
|
||||||
? 'Preparing payment…'
|
? 'Preparing payment…'
|
||||||
: `Pay ${formatPrice(basket.total, currency)}`
|
: `Pay ${formatPrice(basket.total)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const timezone = $derived<string>(page.data.timezone ?? DEFAULT_TIMEZONE);
|
const timezone = $derived<string>(page.data.timezone ?? DEFAULT_TIMEZONE);
|
||||||
|
|
@ -348,7 +345,7 @@
|
||||||
{#if line.lineType === 'slot' && line.slotStart}
|
{#if line.lineType === 'slot' && line.slotStart}
|
||||||
<p class="text-sm text-fg-body/70">{formatSlotTime(line.slotStart)}</p>
|
<p class="text-sm text-fg-body/70">{formatSlotTime(line.slotStart)}</p>
|
||||||
{/if}
|
{/if}
|
||||||
<p class="text-sm text-fg-body/70">{formatPrice(line.itemPrice ?? 0, currency)}</p>
|
<p class="text-sm text-fg-body/70">{formatPrice(line.itemPrice ?? 0)}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Products, and places in a group session (capacity > 1); the server checks what's left. -->
|
<!-- Products, and places in a group session (capacity > 1); the server checks what's left. -->
|
||||||
|
|
@ -377,7 +374,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<p class="w-20 shrink-0 text-right font-medium">
|
<p class="w-20 shrink-0 text-right font-medium">
|
||||||
{formatPrice((line.itemPrice ?? 0) * line.quantity, currency)}
|
{formatPrice((line.itemPrice ?? 0) * line.quantity)}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|
@ -397,7 +394,7 @@
|
||||||
<div class="mt-6 rounded-2xl border border-charcoal/10 bg-white p-5">
|
<div class="mt-6 rounded-2xl border border-charcoal/10 bg-white p-5">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<span class="text-fg-body/70">Subtotal</span>
|
<span class="text-fg-body/70">Subtotal</span>
|
||||||
<span class="font-serif text-xl font-bold">{formatPrice(basket.total, currency)}</span>
|
<span class="font-serif text-xl font-bold">{formatPrice(basket.total)}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -508,7 +505,7 @@
|
||||||
disabled={payState === 'confirming'}
|
disabled={payState === 'confirming'}
|
||||||
onclick={confirmPayment}
|
onclick={confirmPayment}
|
||||||
>
|
>
|
||||||
{payState === 'confirming' ? 'Confirming…' : `Confirm payment — ${formatPrice(basket.total, currency)}`}
|
{payState === 'confirming' ? 'Confirming…' : `Confirm payment — ${formatPrice(basket.total)}`}
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import type { BasketLine, ShopBlockData, ItemRecord, SlotRecord } from '$shared/types';
|
import type { BasketLine, ShopBlockData, ItemRecord, SlotRecord } from '$shared/types';
|
||||||
import { getBasketContext } from '$shared/basket.svelte';
|
import { getBasketContext } from '$shared/basket.svelte';
|
||||||
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, addMonths, createCalendarMonth, formatInstant, formatPrice, startOfMonth, zonedDateKey } from '$shared/calendar';
|
import { DEFAULT_TIMEZONE, addMonths, createCalendarMonth, formatInstant, formatPrice, startOfMonth, zonedDateKey } from '$shared/calendar';
|
||||||
import { formatDateKey } from '$shared/slots';
|
import { formatDateKey } from '$shared/slots';
|
||||||
|
|
||||||
let { data = {}, items = [], slots = [] } = $props<{
|
let { data = {}, items = [], slots = [] } = $props<{
|
||||||
|
|
@ -32,7 +32,6 @@
|
||||||
const MONTHS_SHOWN = 2;
|
const MONTHS_SHOWN = 2;
|
||||||
const weekdayLetters = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
|
const weekdayLetters = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
|
||||||
const timezone = $derived<string>(page.data.timezone ?? DEFAULT_TIMEZONE);
|
const timezone = $derived<string>(page.data.timezone ?? DEFAULT_TIMEZONE);
|
||||||
const currency = $derived<string>(page.data.currency ?? DEFAULT_CURRENCY);
|
|
||||||
|
|
||||||
let visibleItems: ItemRecord[] = $derived.by(() => {
|
let visibleItems: ItemRecord[] = $derived.by(() => {
|
||||||
let result: ItemRecord[] = items;
|
let result: ItemRecord[] = items;
|
||||||
|
|
@ -235,7 +234,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="mt-auto flex flex-wrap items-center gap-x-3 gap-y-1 pt-3">
|
<div class="mt-auto flex flex-wrap items-center gap-x-3 gap-y-1 pt-3">
|
||||||
<span class="text-lg font-semibold text-sage-dark">{formatPrice(item.price, currency)}</span>
|
<span class="text-lg font-semibold text-sage-dark">{formatPrice(item.price)}</span>
|
||||||
{#if isService && item.duration != null}
|
{#if isService && item.duration != null}
|
||||||
<span class="text-xs text-charcoal/60">{item.duration} min</span>
|
<span class="text-xs text-charcoal/60">{item.duration} min</span>
|
||||||
{:else if !isService && item.stock != null && item.stock > 0 && item.stock <= 5}
|
{:else if !isService && item.stock != null && item.stock > 0 && item.stock <= 5}
|
||||||
|
|
|
||||||
|
|
@ -58,25 +58,8 @@ export const DISPLAY_LOCALE = 'en-GB';
|
||||||
/** Fallback when no SITE_TIMEZONE reaches the page. */
|
/** Fallback when no SITE_TIMEZONE reaches the page. */
|
||||||
export const DEFAULT_TIMEZONE = 'Europe/Oslo';
|
export const DEFAULT_TIMEZONE = 'Europe/Oslo';
|
||||||
|
|
||||||
/** Fallback when no shop currency reaches the page. */
|
export function formatPrice(amount: number) {
|
||||||
export const DEFAULT_CURRENCY = 'EUR';
|
return new Intl.NumberFormat(DISPLAY_LOCALE, { style: 'currency', currency: 'EUR' }).format(amount);
|
||||||
|
|
||||||
/**
|
|
||||||
* The shop currency as an ISO 4217 code, from STRIPE_CURRENCY ('nok' → 'NOK').
|
|
||||||
* One setting for what Stripe charges and what every price shows.
|
|
||||||
*/
|
|
||||||
export function shopCurrency(value: string | undefined) {
|
|
||||||
return (value || DEFAULT_CURRENCY).toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A price in the shop currency (layout data `currency`). */
|
|
||||||
export function formatPrice(amount: number, currency = DEFAULT_CURRENCY) {
|
|
||||||
try {
|
|
||||||
return new Intl.NumberFormat(DISPLAY_LOCALE, { style: 'currency', currency }).format(amount);
|
|
||||||
} catch {
|
|
||||||
// Not a currency code Intl knows (a typo in STRIPE_CURRENCY).
|
|
||||||
return `${amount.toFixed(2)} ${currency}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Format an instant in `timeZone` with the display locale. */
|
/** Format an instant in `timeZone` with the display locale. */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue