Skip to content

Email for professionals and teams

Translate public booking pages

Hieu Nguyen (Jack)8a4474e920c8
diff --git a/src/app/book/[userId]/[eventId]/booking-detail-skeleton.tsx b/src/app/book/[userId]/[eventId]/booking-detail-skeleton.tsx
index 1ebf51f..93c2965 100644
--- a/src/app/book/[userId]/[eventId]/booking-detail-skeleton.tsx
+++ b/src/app/book/[userId]/[eventId]/booking-detail-skeleton.tsx
@@ -1,6 +1,11 @@
+"use client";
+
+import { useLanguage } from "@/components/language-provider";
+
export function BookingDetailSkeleton() {
- return <div role="status" aria-label="Loading availability" className="grid overflow-hidden rounded-t-3xl bg-white shadow-xl shadow-neutral-200/50 motion-safe:animate-pulse lg:min-h-0 lg:flex-1 lg:grid-cols-[minmax(240px,.95fr)_minmax(380px,1.65fr)_minmax(240px,.95fr)]">
- <span className="sr-only">Loading availability…</span>
+ const { t } = useLanguage();
+ return <div role="status" aria-label={t("public.loadingAvailability")} className="grid overflow-hidden rounded-t-3xl bg-white shadow-xl shadow-neutral-200/50 motion-safe:animate-pulse lg:min-h-0 lg:flex-1 lg:grid-cols-[minmax(240px,.95fr)_minmax(380px,1.65fr)_minmax(240px,.95fr)]">
+ <span className="sr-only">{t("public.loadingAvailabilityEllipsis")}</span>
<div className="space-y-6 border-b border-neutral-200 p-7 sm:p-9 lg:border-b-0 lg:border-r">
<div className="h-6 w-2/3 rounded bg-neutral-200" />
<div className="h-4 w-full rounded bg-neutral-100" />
diff --git a/src/app/book/[userId]/[eventId]/page.tsx b/src/app/book/[userId]/[eventId]/page.tsx
index 98f178a..73ddf6d 100644
--- a/src/app/book/[userId]/[eventId]/page.tsx
+++ b/src/app/book/[userId]/[eventId]/page.tsx
@@ -4,17 +4,20 @@ import { useEffect, useMemo, useState } from "react";
import Link from "next/link";
import { useParams } from "next/navigation";
import { ArrowLeft, CalendarDays, Check, ChevronLeft, ChevronRight, Clock3, Globe2, MapPin, Users } from "lucide-react";
+import { useLanguage } from "@/components/language-provider";
+import { LanguageSelector } from "@/components/language-selector";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { useBranding } from "@/components/branding-provider";
import { RouteLoadingBar } from "@/components/route-loading-bar";
-import { getUserTimeZone } from "@/lib/time/utils";
+import { getDisplayLocale, getUserTimeZone } from "@/lib/time/utils";
import type { BookingSlot, PublicBookingEvent } from "../types";
import { bookingTimeZones, calendarDays, formatCalendarDate, localDateForSlot, moveMonth, readBookingPageSelection, submitPublicBooking, writeBookingPageSelection } from "./utils";
import { BookingDetailSkeleton } from "./booking-detail-skeleton";
export default function PublicBookingEventPage() {
+ const { t } = useLanguage();
const branding = useBranding();
const params = useParams();
const userId = typeof params.userId === "string" ? params.userId : undefined;
@@ -85,9 +88,9 @@ export default function PublicBookingEventPage() {
setEvent(data.event);
setHostName(data.hostName);
setSlots(data.slots);
- }).catch(() => { if (active) setError("This meeting is unavailable."); }).finally(() => { if (active) setLoading(false); });
+ }).catch(() => { if (active) setError(t("public.unavailable")); }).finally(() => { if (active) setLoading(false); });
return () => { active = false; };
- }, [endpoint, userId]);
+ }, [endpoint, userId, t]);
async function book() {
if (!selectedSlot) return;
@@ -97,14 +100,14 @@ export default function PublicBookingEventPage() {
await submitPublicBooking(endpoint, selectedSlot.startsAt, name, email, guestEmails, notes);
setDone(true);
} catch (cause) {
- setError(cause instanceof Error ? cause.message : "Could not book this time. Please try again.");
+ setError(cause instanceof Error ? cause.message : t("public.bookFailed"));
} finally { setSubmitting(false); }
}
return <main className="page-transition-enter min-h-dvh bg-[#f6f8fc] p-4 text-neutral-900 max-sm:px-0 max-sm:pb-0 sm:px-6 lg:h-dvh lg:overflow-hidden lg:pb-0">
<div className="mx-auto max-w-[1500px] lg:flex lg:h-full lg:min-h-0 lg:flex-col">
{loading && <RouteLoadingBar />}
- {selectedSlot && !done ? <button type="button" onClick={() => { setSelectedSlot(null); setError(""); writeBookingPageSelection(selectedDate, null, timeZone, true); }} className="mb-5 inline-flex items-center gap-2 self-start text-sm text-neutral-600 hover:text-blue-700 max-sm:ml-4"><ArrowLeft className="h-4 w-4" />Back to calendar</button> : <Link href={username ? `/c/${username}` : `/book/${userId}`} className="mb-5 inline-flex items-center gap-2 self-start text-sm text-neutral-600 hover:text-blue-700 max-sm:ml-4"><ArrowLeft className="h-4 w-4" />All meetings</Link>}
+ {selectedSlot && !done ? <button type="button" onClick={() => { setSelectedSlot(null); setError(""); writeBookingPageSelection(selectedDate, null, timeZone, true); }} className="mb-5 inline-flex items-center gap-2 self-start text-sm text-neutral-600 hover:text-blue-700 max-sm:ml-4"><ArrowLeft className="h-4 w-4" />{t("public.backToCalendar")}</button> : <Link href={username ? `/c/${username}` : `/book/${userId}`} className="mb-5 inline-flex items-center gap-2 self-start text-sm text-neutral-600 hover:text-blue-700 max-sm:ml-4"><ArrowLeft className="h-4 w-4" />{t("public.allMeetings")}</Link>}
{loading ? <BookingDetailSkeleton /> : !event ? <p className="rounded-2xl bg-white p-8 text-sm text-neutral-600 shadow-sm">{error}</p> :
<div className={`page-transition-enter grid overflow-hidden rounded-t-3xl bg-white shadow-xl shadow-neutral-200/50 lg:min-h-0 lg:flex-1 ${selectedSlot || done ? "lg:grid-cols-[minmax(260px,1fr)_minmax(420px,2fr)]" : "lg:grid-cols-[minmax(240px,.95fr)_minmax(380px,1.65fr)_minmax(240px,.95fr)]"}`}>
<aside className="min-w-0 border-b border-neutral-200 p-7 max-sm:p-5 sm:p-9 lg:min-h-0 lg:overflow-y-auto lg:border-b-0 flex flex-col border-r">
@@ -113,15 +116,16 @@ export default function PublicBookingEventPage() {
{event.description && <p className="mt-2 whitespace-pre-wrap text-sm leading-6 text-neutral-600">{event.description}</p>}
<div className="mt-4 space-y-5 text-sm font-medium text-neutral-600 border-t border-neutral-100 pt-4">
- <p className="flex items-start gap-3"><Clock3 size={18} className="shrink-0 text-neutral-600" />{event.durationMinutes} min</p>
+ <p className="flex items-start gap-3"><Clock3 size={18} className="shrink-0 text-neutral-600" />{t("public.minutes", { count: event.durationMinutes })}</p>
{event.location && <p className="flex items-start gap-3"><MapPin size={18} className="shrink-0 text-neutral-600" />{event.location}</p>}
- {selectedSlot && <><p className="flex items-start gap-3"><CalendarDays size={18} className="shrink-0 text-neutral-600" /><span>{new Intl.DateTimeFormat(undefined, { hour: "numeric", minute: "2-digit", hourCycle: "h23", timeZone }).format(new Date(selectedSlot.startsAt))} – {new Intl.DateTimeFormat(undefined, { hour: "numeric", minute: "2-digit", hourCycle: "h23", timeZone }).format(new Date(selectedSlot.endsAt))}, {new Intl.DateTimeFormat(undefined, { weekday: "long", month: "long", day: "numeric", year: "numeric", timeZone }).format(new Date(selectedSlot.startsAt))}</span></p><p className="flex items-start gap-3"><Globe2 size={18} className="shrink-0 text-neutral-600" />{timeZone.replaceAll("_", " ")}</p></>}
+ {selectedSlot && <><p className="flex items-start gap-3"><CalendarDays size={18} className="shrink-0 text-neutral-600" /><span>{new Intl.DateTimeFormat(getDisplayLocale(), { hour: "numeric", minute: "2-digit", hourCycle: "h23", timeZone }).format(new Date(selectedSlot.startsAt))} – {new Intl.DateTimeFormat(getDisplayLocale(), { hour: "numeric", minute: "2-digit", hourCycle: "h23", timeZone }).format(new Date(selectedSlot.endsAt))}, {new Intl.DateTimeFormat(getDisplayLocale(), { weekday: "long", month: "long", day: "numeric", year: "numeric", timeZone }).format(new Date(selectedSlot.startsAt))}</span></p><p className="flex items-start gap-3"><Globe2 size={18} className="shrink-0 text-neutral-600" />{timeZone.replaceAll("_", " ")}</p></>}
{hostName && <p className="flex items-start gap-3"><Users size={18} className="shrink-0 text-neutral-600" /><span>{hostName}</span></p>}
</div>
<span className="flex-1 max-sm:hidden" />
+ <div className="mb-4 max-w-48"><LanguageSelector /></div>
<div className="flex min-w-0 items-center gap-3 max-sm:order-first max-sm:mb-5">
<img src={branding.iconUrl} width={24} height={24} alt={branding.appName || "Mailflare"} />
@@ -129,33 +133,33 @@ export default function PublicBookingEventPage() {
<span className="truncate font-semibold">{branding.appName}</span>
</div>
</aside>
- {done ? <section className="flex min-h-0 flex-col items-center justify-center px-8 py-20 text-center"><div className="mb-5 flex h-14 w-14 items-center justify-center rounded-full bg-green-100 text-green-700"><Check className="h-7 w-7" /></div><h2 className="text-2xl font-semibold">Meeting booked</h2><p className="mt-3 text-sm text-neutral-500">Your meeting is scheduled for {selectedSlot && new Intl.DateTimeFormat(undefined, { dateStyle: "full", timeStyle: "short", timeZone }).format(new Date(selectedSlot.startsAt))}.</p></section> : selectedSlot ?
+ {done ? <section className="flex min-h-0 flex-col items-center justify-center px-8 py-20 text-center"><div className="mb-5 flex h-14 w-14 items-center justify-center rounded-full bg-green-100 text-green-700"><Check className="h-7 w-7" /></div><h2 className="text-2xl font-semibold">{t("public.booked")}</h2><p className="mt-3 text-sm text-neutral-500">{t("public.scheduledFor", { when: selectedSlot ? new Intl.DateTimeFormat(getDisplayLocale(), { dateStyle: "full", timeStyle: "short", timeZone }).format(new Date(selectedSlot.startsAt)) : "" })}</p></section> : selectedSlot ?
<form onSubmit={(formEvent) => { formEvent.preventDefault(); void book(); }} className="page-transition-enter min-h-0 space-y-6 overflow-y-auto p-7 max-sm:p-5 sm:p-10">
- <h2 className="text-2xl font-medium">Enter Details</h2>
- <label className="block text-sm font-medium text-neutral-700">Name <span aria-hidden="true">*</span><Input required value={name} onChange={(input) => setName(input.target.value)} maxLength={120} autoComplete="name" className="mt-2" /></label>
- <label className="block text-sm font-medium text-neutral-700">Email <span aria-hidden="true">*</span><Input required type="email" value={email} onChange={(input) => setEmail(input.target.value)} maxLength={254} autoComplete="email" className="mt-2" /></label>
- {showGuests ? <label className="block text-sm font-medium text-neutral-700">Guest emails <span className="font-normal text-neutral-500">(comma separated)</span><Input type="text" value={guestEmails} onChange={(input) => setGuestEmails(input.target.value)} placeholder="[email protected]" className="mt-2" /></label> : <Button type="button" variant="outline" onClick={() => setShowGuests(true)} className="rounded-full text-blue-700">Add guests</Button>}
- <label className="block text-sm font-medium text-neutral-700">Please share anything that will help prepare for our meeting.<Textarea value={notes} onChange={(input) => setNotes(input.target.value)} maxLength={2000} rows={4} className="mt-2 resize-y" /></label>
+ <h2 className="text-2xl font-medium">{t("public.enterDetails")}</h2>
+ <label className="block text-sm font-medium text-neutral-700">{t("public.name")} <span aria-hidden="true">*</span><Input required value={name} onChange={(input) => setName(input.target.value)} maxLength={120} autoComplete="name" className="mt-2" /></label>
+ <label className="block text-sm font-medium text-neutral-700">{t("public.email")} <span aria-hidden="true">*</span><Input required type="email" value={email} onChange={(input) => setEmail(input.target.value)} maxLength={254} autoComplete="email" className="mt-2" /></label>
+ {showGuests ? <label className="block text-sm font-medium text-neutral-700">{t("public.guestEmails")} <span className="font-normal text-neutral-500">{t("public.commaSeparated")}</span><Input type="text" value={guestEmails} onChange={(input) => setGuestEmails(input.target.value)} placeholder="[email protected]" className="mt-2" /></label> : <Button type="button" variant="outline" onClick={() => setShowGuests(true)} className="rounded-full text-blue-700">{t("public.addGuests")}</Button>}
+ <label className="block text-sm font-medium text-neutral-700">{t("public.notes")}<Textarea value={notes} onChange={(input) => setNotes(input.target.value)} maxLength={2000} rows={4} className="mt-2 resize-y" /></label>
{error && <p role="alert" className="text-sm text-red-600">{error}</p>}
- <Button type="submit" disabled={submitting || !name.trim() || !email.trim()} className="h-11 rounded-full bg-blue-600 px-7 text-sm font-medium hover:bg-blue-700">{submitting ? "Booking…" : "Schedule Event"}</Button>
+ <Button type="submit" disabled={submitting || !name.trim() || !email.trim()} className="h-11 rounded-full bg-blue-600 px-7 text-sm font-medium hover:bg-blue-700">{submitting ? t("public.booking") : t("public.schedule")}</Button>
</form> : <>
<section className="page-transition-enter min-w-0 border-b border-neutral-200 lg:min-h-0 lg:overflow-y-auto">
<div className="mx-auto md:mt-8 my-2 flex max-w-[440px] items-center justify-between gap-3 px-5"><h3 className="text-lg font-semibold flex-1">{formatCalendarDate(`${visibleMonth}-01`, { month: "long", year: "numeric" })}</h3>
- <button type="button" aria-label="Previous month" disabled={!firstMonth || moveMonth(visibleMonth, -1) < firstMonth} onClick={() => setMonth(moveMonth(visibleMonth, -1))} className="flex h-9 w-9 items-center justify-center rounded-md border border-neutral-200 text-blue-600 hover:bg-blue-50 disabled:cursor-not-allowed disabled:opacity-30"><ChevronLeft className="h-5 w-5" /></button>
- <button type="button" aria-label="Next month" disabled={!lastMonth || moveMonth(visibleMonth, 1) > lastMonth} onClick={() => setMonth(moveMonth(visibleMonth, 1))} className="flex h-9 w-9 items-center justify-center rounded-md border border-neutral-200 text-blue-600 hover:bg-blue-50 disabled:cursor-not-allowed disabled:opacity-30"><ChevronRight className="h-5 w-5" /></button>
+ <button type="button" aria-label={t("public.prevMonth")} disabled={!firstMonth || moveMonth(visibleMonth, -1) < firstMonth} onClick={() => setMonth(moveMonth(visibleMonth, -1))} className="flex h-9 w-9 items-center justify-center rounded-md border border-neutral-200 text-blue-600 hover:bg-blue-50 disabled:cursor-not-allowed disabled:opacity-30"><ChevronLeft className="h-5 w-5" /></button>
+ <button type="button" aria-label={t("public.nextMonth")} disabled={!lastMonth || moveMonth(visibleMonth, 1) > lastMonth} onClick={() => setMonth(moveMonth(visibleMonth, 1))} className="flex h-9 w-9 items-center justify-center rounded-md border border-neutral-200 text-blue-600 hover:bg-blue-50 disabled:cursor-not-allowed disabled:opacity-30"><ChevronRight className="h-5 w-5" /></button>
</div>
- <div className="mx-auto mt-6 grid max-w-[440px] grid-cols-7 max-sm:px-5 text-center text-sm text-neutral-400"><span>Mo</span><span>Tu</span><span>We</span><span>Th</span><span>Fr</span><span>Sa</span><span>Su</span></div>
- <div className="mx-auto mt-2 mb-6 grid max-w-[440px] grid-cols-7 max-sm:px-5">{calendarDays(visibleMonth).map((date, index) => <div key={date || `blank-${index}`} className="aspect-square min-w-0">{date && <button type="button" disabled={!slotsByDate.has(date) && date !== todayDate} onClick={() => { setSelectedDate(date); setError(""); writeBookingPageSelection(date, null, timeZone); }} aria-label={`${formatCalendarDate(date, { weekday: "long", month: "long", day: "numeric", year: "numeric" })}${date === todayDate ? ", today" : ""}${slotsByDate.has(date) ? `, ${slotsByDate.get(date)?.length} available times` : ", no available times"}`} aria-current={date === todayDate ? "date" : undefined} aria-pressed={selectedDate === date} className={`flex h-full w-full items-center justify-center rounded-lg text-base ${selectedDate === date ? "bg-blue-600 text-white" : slotsByDate.has(date) || date === todayDate ? "text-blue-700 hover:bg-blue-50" : "cursor-not-allowed text-neutral-400"}`}><span className={`relative flex h-10 w-10 items-center justify-center rounded-full ${selectedDate === date ? "font-semibold" : slotsByDate.has(date) ? "bg-blue-50 font-medium" : ""} ${date === todayDate && selectedDate !== date ? "ring-2 ring-blue-300 ring-offset-2" : ""}`}>{Number(date.slice(-2))}{date === todayDate && selectedDate === date && <span aria-hidden="true" className="absolute bottom-1 h-1 w-1 rounded-full bg-white" />}</span></button>}</div>)}
+ <div className="mx-auto mt-6 grid max-w-[440px] grid-cols-7 max-sm:px-5 text-center text-sm text-neutral-400">{t("public.weekdayHeads").split("|").map((head) => <span key={head}>{head}</span>)}</div>
+ <div className="mx-auto mt-2 mb-6 grid max-w-[440px] grid-cols-7 max-sm:px-5">{calendarDays(visibleMonth).map((date, index) => <div key={date || `blank-${index}`} className="aspect-square min-w-0">{date && <button type="button" disabled={!slotsByDate.has(date) && date !== todayDate} onClick={() => { setSelectedDate(date); setError(""); writeBookingPageSelection(date, null, timeZone); }} aria-label={`${formatCalendarDate(date, { weekday: "long", month: "long", day: "numeric", year: "numeric" })}${date === todayDate ? t("public.today") : ""}${slotsByDate.has(date) ? t("public.availableTimes", { count: slotsByDate.get(date)?.length }) : t("public.noTimesDay")}`} aria-current={date === todayDate ? "date" : undefined} aria-pressed={selectedDate === date} className={`flex h-full w-full items-center justify-center rounded-lg text-base ${selectedDate === date ? "bg-blue-600 text-white" : slotsByDate.has(date) || date === todayDate ? "text-blue-700 hover:bg-blue-50" : "cursor-not-allowed text-neutral-400"}`}><span className={`relative flex h-10 w-10 items-center justify-center rounded-full ${selectedDate === date ? "font-semibold" : slotsByDate.has(date) ? "bg-blue-50 font-medium" : ""} ${date === todayDate && selectedDate !== date ? "ring-2 ring-blue-300 ring-offset-2" : ""}`}>{Number(date.slice(-2))}{date === todayDate && selectedDate === date && <span aria-hidden="true" className="absolute bottom-1 h-1 w-1 rounded-full bg-white" />}</span></button>}</div>)}
</div>
<div className="flex min-w-0 items-center gap-2 w-full pl-3 pr-2 max-sm:px-5 text-sm text-neutral-600 focus-within:border-blue-600 max-w-[440px] my-4 mx-auto">
<Globe2 aria-hidden="true" className="h-4 w-4 shrink-0" />
- <label htmlFor="booking-time-zone" className="shrink-0 whitespace-nowrap">Time zone</label>
+ <label htmlFor="booking-time-zone" className="shrink-0 whitespace-nowrap">{t("public.timeZone")}</label>
<select id="booking-time-zone" value={timeZone} onChange={(input) => { const nextToday = localDateForSlot({ startsAt: new Date().toISOString(), endsAt: "", localDate: "", time: "" }, input.target.value); setTimeZone(input.target.value); setSelectedDate(nextToday); setMonth(nextToday.slice(0, 7)); writeBookingPageSelection(nextToday, null, input.target.value); }} className="ml-auto h-9 min-w-0 max-w-full flex-1 truncate border-0 bg-transparent px-1 text-sm text-neutral-700 shadow-none outline-none text-right">{timeZones.map((zone) => <option key={zone} value={zone}>{zone.replaceAll("_", " ")}</option>)}</select>
</div>
- {slots.length === 0 && <p className="mt-6 text-sm text-neutral-500">No times are available in the next 60 days.</p>}
+ {slots.length === 0 && <p className="mt-6 text-sm text-neutral-500">{t("public.noTimes60")}</p>}
</section>
- {selectedDate && <section key={selectedDate} className="page-transition-enter flex min-h-0 flex-col p-7 max-sm:p-5 sm:p-9 lg:overflow-hidden"><h3 className="mb-6 shrink-0 text-lg font-semibold">{formatCalendarDate(selectedDate, { weekday: "long", month: "short", day: "numeric" })}</h3><div className="min-h-0 max-h-[50dvh] flex-1 space-y-3 overflow-y-auto pr-1 lg:max-h-none">{(slotsByDate.get(selectedDate) ?? []).length === 0 ? <p className="text-sm text-neutral-500">No times are available on this date. Choose another highlighted date.</p> : (slotsByDate.get(selectedDate) ?? []).map((slot) => <button type="button" key={slot.startsAt} onClick={() => { setSelectedSlot(slot); setError(""); writeBookingPageSelection(selectedDate, slot.startsAt, timeZone); }} className="w-full rounded-md border border-neutral-300 bg-white px-4 py-3 text-center text-sm font-medium text-blue-700 hover:border-blue-500 hover:bg-blue-50">{new Intl.DateTimeFormat(undefined, { hour: "numeric", minute: "2-digit", hour12: true, timeZone }).format(new Date(slot.startsAt))}</button>)}</div></section>}
+ {selectedDate && <section key={selectedDate} className="page-transition-enter flex min-h-0 flex-col p-7 max-sm:p-5 sm:p-9 lg:overflow-hidden"><h3 className="mb-6 shrink-0 text-lg font-semibold">{formatCalendarDate(selectedDate, { weekday: "long", month: "short", day: "numeric" })}</h3><div className="min-h-0 max-h-[50dvh] flex-1 space-y-3 overflow-y-auto pr-1 lg:max-h-none">{(slotsByDate.get(selectedDate) ?? []).length === 0 ? <p className="text-sm text-neutral-500">{t("public.noTimesDate")}</p> : (slotsByDate.get(selectedDate) ?? []).map((slot) => <button type="button" key={slot.startsAt} onClick={() => { setSelectedSlot(slot); setError(""); writeBookingPageSelection(selectedDate, slot.startsAt, timeZone); }} className="w-full rounded-md border border-neutral-300 bg-white px-4 py-3 text-center text-sm font-medium text-blue-700 hover:border-blue-500 hover:bg-blue-50">{new Intl.DateTimeFormat(getDisplayLocale(), { hour: "numeric", minute: "2-digit", hour12: true, timeZone }).format(new Date(slot.startsAt))}</button>)}</div></section>}
</>}
</div>}
</div>
diff --git a/src/app/book/[userId]/[eventId]/utils.ts b/src/app/book/[userId]/[eventId]/utils.ts
index 24a2c80..ab71134 100644
--- a/src/app/book/[userId]/[eventId]/utils.ts
+++ b/src/app/book/[userId]/[eventId]/utils.ts
@@ -1,3 +1,5 @@
+import { getDisplayLocale } from "@/lib/time/utils";
+import { defaultTranslator } from "@/lib/i18n/utils";
import type { BookingSlot } from "../types";
import { isValidTimeZone } from "@/lib/time/utils";
import type { BookingPageSelection } from "./types";
@@ -46,7 +48,7 @@ export function moveMonth(month: string, offset: number): string {
}
export function formatCalendarDate(date: string, options: Intl.DateTimeFormatOptions): string {
- return new Intl.DateTimeFormat(undefined, { ...options, timeZone: "UTC" }).format(new Date(`${date}T12:00:00Z`));
+ return new Intl.DateTimeFormat(getDisplayLocale(), { ...options, timeZone: "UTC" }).format(new Date(`${date}T12:00:00Z`));
}
export function bookingTimeZones(eventTimeZone: string, selectedTimeZone: string): string[] {
@@ -57,5 +59,5 @@ export function bookingTimeZones(eventTimeZone: string, selectedTimeZone: string
export async function submitPublicBooking(endpoint: string, startsAt: string, name: string, email: string, guestEmails: string, notes: string): Promise<void> {
const response = await fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ startsAt, name, email, guestEmails, notes }) });
const data = await response.json() as { error?: string };
- if (!response.ok) throw new Error(data.error ?? "Could not book this time.");
+ if (!response.ok) throw new Error(data.error ?? defaultTranslator("public.bookFailedShort"));
}
diff --git a/src/app/book/[userId]/booking-list-skeleton.tsx b/src/app/book/[userId]/booking-list-skeleton.tsx
index cdba172..16f97cd 100644
--- a/src/app/book/[userId]/booking-list-skeleton.tsx
+++ b/src/app/book/[userId]/booking-list-skeleton.tsx
@@ -1,6 +1,11 @@
+"use client";
+
+import { useLanguage } from "@/components/language-provider";
+
export function BookingListSkeleton() {
- return <div role="status" aria-label="Loading meetings" className="space-y-3">
- <span className="sr-only">Loading meetings…</span>
+ const { t } = useLanguage();
+ return <div role="status" aria-label={t("public.loadingMeetings")} className="space-y-3">
+ <span className="sr-only">{t("public.loadingMeetingsEllipsis")}</span>
{[0, 1, 2].map((item) => <div key={item} className="rounded-2xl bg-white p-5 motion-safe:animate-pulse">
<div className="h-5 w-2/3 rounded bg-neutral-200" />
<div className="mt-4 h-3 w-5/6 rounded bg-neutral-100" />
diff --git a/src/app/book/[userId]/page.tsx b/src/app/book/[userId]/page.tsx
index 97a6d31..0a306e0 100644
--- a/src/app/book/[userId]/page.tsx
+++ b/src/app/book/[userId]/page.tsx
@@ -4,12 +4,15 @@ import { useEffect, useState } from "react";
import Link from "next/link";
import { useParams } from "next/navigation";
import { ArrowRight, Clock3, MapPin } from "lucide-react";
+import { useLanguage } from "@/components/language-provider";
+import { LanguageSelector } from "@/components/language-selector";
import { useBranding } from "@/components/branding-provider";
import { RouteLoadingBar } from "@/components/route-loading-bar";
import type { PublicBookingEvent } from "./types";
import { BookingListSkeleton } from "./booking-list-skeleton";
export default function PublicBookingListPage() {
+ const { t } = useLanguage();
const branding = useBranding();
const params = useParams();
const userId = typeof params.userId === "string" ? params.userId : undefined;
@@ -24,15 +27,16 @@ export default function PublicBookingListPage() {
void fetch(`/api/public/booking?${query}`).then(async (response) => {
if (!response.ok) throw new Error();
return response.json() as Promise<{ name: string; events: PublicBookingEvent[] }>;
- }).then((data) => { if (active) { setName(data.name); setEvents(data.events); } }).catch(() => { if (active) setError("This booking page is unavailable."); }).finally(() => { if (active) setLoading(false); });
+ }).then((data) => { if (active) { setName(data.name); setEvents(data.events); } }).catch(() => { if (active) setError(t("public.listUnavailable")); }).finally(() => { if (active) setLoading(false); });
return () => { active = false; };
- }, [query]);
+ }, [query, t]);
return <main className="page-transition-enter flex min-h-dvh flex-col bg-[#f6f8fc] p-4 lg:pt-12 text-neutral-900">
{loading && <RouteLoadingBar />}
<div className="mx-auto flex w-full max-w-2xl flex-1 flex-col">
- <div className="mb-7"><h1 className="text-2xl md:text-3xl font-semibold">Book a meeting{name ? ` with ${name}` : ""}</h1><p className="mt-2 text-sm text-neutral-500">Choose a meeting to see available times.</p></div>
- {loading ? <BookingListSkeleton /> : error ? <p className="rounded-2xl border border-neutral-200 bg-white p-6 text-sm text-neutral-600 shadow-sm">{error}</p> : events.length === 0 ? <p className="rounded-2xl border border-neutral-200 bg-white p-6 text-sm text-neutral-600">No meetings are available to book right now.</p> : <div className="page-transition-enter space-y-3">{events.map((event) => <Link key={event.id} href={username ? `/c/${username}/${event.slug}` : `/book/${userId}/${event.id}`} className="group flex items-center gap-4 rounded-2xl bg-white p-5 transition-colors"><div className="min-w-0 flex-1"><h2 className="font-semibold group-hover:text-blue-700">{event.name}</h2>{event.description && <p className="mt-1 line-clamp-2 whitespace-pre-wrap text-sm text-neutral-600">{event.description}</p>}<p className="mt-2 flex flex-wrap gap-x-4 gap-y-1 text-sm text-neutral-500"><span className="inline-flex items-center gap-1"><Clock3 className="h-4 w-4" />{event.durationMinutes} minutes</span>{event.location && <span className="inline-flex items-center gap-1"><MapPin className="h-4 w-4" />{event.location}</span>}</p></div><ArrowRight className="h-5 w-5 text-neutral-400 group-hover:text-blue-700" /></Link>)}</div>}
- <div className="mt-auto flex min-w-0 items-center gap-3 pt-10 text-neutral-700">
+ <div className="mb-7"><h1 className="text-2xl md:text-3xl font-semibold">{name ? t("public.bookMeetingWith", { name }) : t("public.bookMeeting")}</h1><p className="mt-2 text-sm text-neutral-500">{t("public.chooseMeeting")}</p></div>
+ {loading ? <BookingListSkeleton /> : error ? <p className="rounded-2xl border border-neutral-200 bg-white p-6 text-sm text-neutral-600 shadow-sm">{error}</p> : events.length === 0 ? <p className="rounded-2xl border border-neutral-200 bg-white p-6 text-sm text-neutral-600">{t("public.noMeetings")}</p> : <div className="page-transition-enter space-y-3">{events.map((event) => <Link key={event.id} href={username ? `/c/${username}/${event.slug}` : `/book/${userId}/${event.id}`} className="group flex items-center gap-4 rounded-2xl bg-white p-5 transition-colors"><div className="min-w-0 flex-1"><h2 className="font-semibold group-hover:text-blue-700">{event.name}</h2>{event.description && <p className="mt-1 line-clamp-2 whitespace-pre-wrap text-sm text-neutral-600">{event.description}</p>}<p className="mt-2 flex flex-wrap gap-x-4 gap-y-1 text-sm text-neutral-500"><span className="inline-flex items-center gap-1"><Clock3 className="h-4 w-4" />{t("public.minutesLong", { count: event.durationMinutes })}</span>{event.location && <span className="inline-flex items-center gap-1"><MapPin className="h-4 w-4" />{event.location}</span>}</p></div><ArrowRight className="h-5 w-5 text-neutral-400 group-hover:text-blue-700" /></Link>)}</div>}
+ <div className="mt-auto flex min-w-0 flex-wrap items-center justify-between gap-3 pt-10 text-neutral-700">
+ <div className="w-44"><LanguageSelector /></div>
<img src={branding.iconUrl} width={24} height={24} alt={branding.appName || "Mailflare"} />
<span className="truncate font-semibold">{branding.appName}</span>
</div>
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index fedda3d..f943b26 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -1626,5 +1626,41 @@
"booking.editor.more": "More",
"booking.editor.create": "Create",
"booking.loading": "Loading bookings",
- "booking.loadingEllipsis": "Loading bookings…"
+ "booking.loadingEllipsis": "Loading bookings…",
+ "public.unavailable": "This meeting is unavailable.",
+ "public.bookFailed": "Could not book this time. Please try again.",
+ "public.bookFailedShort": "Could not book this time.",
+ "public.backToCalendar": "Back to calendar",
+ "public.allMeetings": "All meetings",
+ "public.minutes": "{count} min",
+ "public.booked": "Meeting booked",
+ "public.scheduledFor": "Your meeting is scheduled for {when}.",
+ "public.enterDetails": "Enter Details",
+ "public.name": "Name",
+ "public.email": "Email",
+ "public.guestEmails": "Guest emails",
+ "public.commaSeparated": "(comma separated)",
+ "public.addGuests": "Add guests",
+ "public.notes": "Please share anything that will help prepare for our meeting.",
+ "public.booking": "Booking…",
+ "public.schedule": "Schedule Event",
+ "public.prevMonth": "Previous month",
+ "public.nextMonth": "Next month",
+ "public.weekdayHeads": "Mo|Tu|We|Th|Fr|Sa|Su",
+ "public.today": ", today",
+ "public.availableTimes": ", {count} available times",
+ "public.noTimesDay": ", no available times",
+ "public.timeZone": "Time zone",
+ "public.noTimes60": "No times are available in the next 60 days.",
+ "public.noTimesDate": "No times are available on this date. Choose another highlighted date.",
+ "public.listUnavailable": "This booking page is unavailable.",
+ "public.bookMeeting": "Book a meeting",
+ "public.bookMeetingWith": "Book a meeting with {name}",
+ "public.chooseMeeting": "Choose a meeting to see available times.",
+ "public.noMeetings": "No meetings are available to book right now.",
+ "public.minutesLong": "{count} minutes",
+ "public.loadingAvailability": "Loading availability",
+ "public.loadingAvailabilityEllipsis": "Loading availability…",
+ "public.loadingMeetings": "Loading meetings",
+ "public.loadingMeetingsEllipsis": "Loading meetings…"
}
diff --git a/src/lib/i18n/pt-BR.json b/src/lib/i18n/pt-BR.json
index c82c4f1..fe20633 100644
--- a/src/lib/i18n/pt-BR.json
+++ b/src/lib/i18n/pt-BR.json
@@ -1626,5 +1626,41 @@
"booking.editor.more": "Mais",
"booking.editor.create": "Criar",
"booking.loading": "Carregando agendamentos",
- "booking.loadingEllipsis": "Carregando agendamentos…"
+ "booking.loadingEllipsis": "Carregando agendamentos…",
+ "public.unavailable": "Esta reunião não está disponível.",
+ "public.bookFailed": "Não foi possível agendar este horário. Tente novamente.",
+ "public.bookFailedShort": "Não foi possível agendar este horário.",
+ "public.backToCalendar": "Voltar ao calendário",
+ "public.allMeetings": "Todas as reuniões",
+ "public.minutes": "{count} min",
+ "public.booked": "Reunião agendada",
+ "public.scheduledFor": "Sua reunião está agendada para {when}.",
+ "public.enterDetails": "Informe os dados",
+ "public.name": "Nome",
+ "public.email": "E-mail",
+ "public.guestEmails": "E-mails dos convidados",
+ "public.commaSeparated": "(separados por vírgula)",
+ "public.addGuests": "Adicionar convidados",
+ "public.notes": "Compartilhe qualquer informação que ajude a preparar nossa reunião.",
+ "public.booking": "Agendando…",
+ "public.schedule": "Agendar evento",
+ "public.prevMonth": "Mês anterior",
+ "public.nextMonth": "Próximo mês",
+ "public.weekdayHeads": "Seg|Ter|Qua|Qui|Sex|Sáb|Dom",
+ "public.today": ", hoje",
+ "public.availableTimes": ", {count} horários disponíveis",
+ "public.noTimesDay": ", sem horários disponíveis",
+ "public.timeZone": "Fuso horário",
+ "public.noTimes60": "Nenhum horário disponível nos próximos 60 dias.",
+ "public.noTimesDate": "Nenhum horário disponível nesta data. Escolha outra data destacada.",
+ "public.listUnavailable": "Esta página de agendamento não está disponível.",
+ "public.bookMeeting": "Agendar uma reunião",
+ "public.bookMeetingWith": "Agendar uma reunião com {name}",
+ "public.chooseMeeting": "Escolha uma reunião para ver os horários disponíveis.",
+ "public.noMeetings": "Nenhuma reunião disponível para agendar no momento.",
+ "public.minutesLong": "{count} minutos",
+ "public.loadingAvailability": "Carregando disponibilidade",
+ "public.loadingAvailabilityEllipsis": "Carregando disponibilidade…",
+ "public.loadingMeetings": "Carregando reuniões",
+ "public.loadingMeetingsEllipsis": "Carregando reuniões…"
}