diff --git a/.dockerignore b/.dockerignore index 1ca0a205..66f95ba7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -40,3 +40,5 @@ calnode.exe **/.svelte-kit **/build fly.toml + +calnode-data/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index e378b9ae..e368b642 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ data-demo/ # Environment — allow .env.example as a committed template .env .env.* +.env2 !.env.example # Go diff --git a/calnode-data/branding/banner.png b/calnode-data/branding/banner.png new file mode 100644 index 00000000..b7dd9898 Binary files /dev/null and b/calnode-data/branding/banner.png differ diff --git a/calnode-data/branding/logo.png b/calnode-data/branding/logo.png new file mode 100644 index 00000000..a4e33776 Binary files /dev/null and b/calnode-data/branding/logo.png differ diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 5a121d77..0c6ce307 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -1,367 +1,378 @@ export type User = { - booking_accent: string; - handle?: string; - id: string; - email: string; - name: string; - timezone: string; - time_format: '12h' | '24h'; - week_start: number; // 0=Sunday, 1=Monday - date_format: 'dmy' | 'mdy' | 'ymd'; - avatar_url?: string; - is_admin: boolean; - is_owner: boolean; - role: 'owner' | 'admin' | 'member'; - notify_confirmation: boolean; - notify_cancellation: boolean; - notify_reschedule: boolean; - notify_reminder: boolean; - notify_host_booking: boolean; - notify_host_cancel: boolean; - notify_host_reschedule: boolean; + booking_accent: string; + handle?: string; + id: string; + email: string; + name: string; + timezone: string; + time_format: "12h" | "24h"; + week_start: number; // 0=Sunday, 1=Monday + date_format: "dmy" | "mdy" | "ymd"; + avatar_url?: string; + is_admin: boolean; + is_owner: boolean; + role: "owner" | "admin" | "member"; + notify_confirmation: boolean; + notify_cancellation: boolean; + notify_reschedule: boolean; + notify_reminder: boolean; + notify_host_booking: boolean; + notify_host_cancel: boolean; + notify_host_reschedule: boolean; }; export type EventType = { - /** Lower first on public person/team pages; ties sort by name, then slug. */ - display_order: number; - allow_phone_call: boolean; - id: string; - slug: string; - name: string; - description?: string; - duration_minutes: number; - // How often a booking can START, independent of how long it runs. Defaults to the - // duration on create; editable so a 45-minute meeting can still be offered on the hour. - slot_interval_minutes: number; - is_active: boolean; - is_public: boolean; - /** Show already-booked times struck through on the booking page instead of hiding - * them. Off by default: the slots endpoint is public, so this makes the host's - * booked hours visible to anyone with the link. */ - show_taken_slots: boolean; - /** Who sends the booker's calendar invite. 'calendar': each host's connected calendar, - * from the host's own address. 'calnode': Calnode's own invite, from the email sender - * in Settings → Email, so no host's personal address reaches the booker. */ - invite_delivery: 'calendar' | 'calnode'; - /** Whether Calnode can currently send invites (a sender and working email). Only - * returned on the single event type GET. */ - invite_sender_ready?: boolean; - location_type: string; - location_value?: string; - buffer_before_minutes: number; - buffer_after_minutes: number; - min_notice_minutes: number; - max_future_days: number; - max_active_bookings: number; - price_cents: number; // 0 = free - currency: string; // ISO 4217, lowercase (e.g. "usd") - created_at: string; - subj_confirmation?: string; - subj_cancellation?: string; - subj_reschedule?: string; - subj_reminder?: string; - msg_confirmation?: string; - msg_cancellation?: string; - msg_reschedule?: string; - msg_reminder?: string; - /** Overrides the conversational assistant's opening chat line; unset = built-in translated default. */ - msg_greeting?: string; - reminders: number[]; // hours_before values - routing_mode: 'fixed' | 'round_robin' | 'collective'; - rr_strategy: 'even' | 'soonest' | 'priority'; - /** True when archived — hidden from the default list, is_active forced off. Reversible. */ - archived?: boolean; - /** True if the current user owns this event type; false if they only host it (read-only). */ - owned?: boolean; - /** Owner identity, returned only when the viewer is a read-only host. */ - owner_name?: string; - owner_email?: string; + /** Lower first on public person/team pages; ties sort by name, then slug. */ + display_order: number; + allow_phone_call: boolean; + id: string; + slug: string; + name: string; + description?: string; + duration_minutes: number; + // How often a booking can START, independent of how long it runs. Defaults to the + // duration on create; editable so a 45-minute meeting can still be offered on the hour. + slot_interval_minutes: number; + is_active: boolean; + is_public: boolean; + /** Show already-booked times struck through on the booking page instead of hiding + * them. Off by default: the slots endpoint is public, so this makes the host's + * booked hours visible to anyone with the link. */ + show_taken_slots: boolean; + /** Who sends the booker's calendar invite. 'calendar': each host's connected calendar, + * from the host's own address. 'calnode': Calnode's own invite, from the email sender + * in Settings → Email, so no host's personal address reaches the booker. */ + invite_delivery: "calendar" | "calnode"; + /** Whether Calnode can currently send invites (a sender and working email). Only + * returned on the single event type GET. */ + invite_sender_ready?: boolean; + location_type: string; + location_value?: string; + buffer_before_minutes: number; + buffer_after_minutes: number; + min_notice_minutes: number; + max_future_days: number; + max_active_bookings: number; + price_cents: number; // 0 = free + currency: string; // ISO 4217, lowercase (e.g. "usd") + created_at: string; + subj_confirmation?: string; + subj_cancellation?: string; + subj_reschedule?: string; + subj_reminder?: string; + msg_confirmation?: string; + msg_cancellation?: string; + msg_reschedule?: string; + msg_reminder?: string; + /** Overrides the conversational assistant's opening chat line; unset = built-in translated default. */ + msg_greeting?: string; + reminders: number[]; // hours_before values + routing_mode: "fixed" | "round_robin" | "collective"; + rr_strategy: "even" | "soonest" | "priority"; + /** True when archived — hidden from the default list, is_active forced off. Reversible. */ + archived?: boolean; + /** True if the current user owns this event type; false if they only host it (read-only). */ + owned?: boolean; + /** Owner identity, returned only when the viewer is a read-only host. */ + owner_name?: string; + owner_email?: string; }; export type EventTypeHost = { - user_id: string; - name: string; - email: string; - avatar_url?: string; - role: 'required' | 'rotation' | 'optional'; - priority: number; - archived: boolean; + user_id: string; + name: string; + email: string; + avatar_url?: string; + role: "required" | "rotation" | "optional"; + priority: number; + archived: boolean; }; export type Question = { - id: string; - event_type_id: string; - label: string; - type: 'text' | 'select' | 'checkbox'; - options?: string[]; - required: boolean; - position: number; + id: string; + event_type_id: string; + label: string; + type: "text" | "select" | "checkbox"; + options?: string[]; + required: boolean; + position: number; }; export type Booking = { - id: string; - event_type_slug: string; - start_at: string; - end_at: string; - status: 'confirmed' | 'cancelled'; - attendees: { name: string; email: string }[]; - created_at: string; - host_name?: string; // populated only in the admin "All bookings" view - location_value?: string; - /** Payment fields — present only for paid bookings (omitted when free). */ - payment_status?: 'pending' | 'paid' | 'refunded'; - amount_paid_cents?: number; - amount_paid_currency?: string; - /** The booker's RSVP to a Calnode-sent invite; absent until an answer arrives. */ - rsvp_status?: 'accepted' | 'declined' | 'tentative'; + id: string; + event_type_slug: string; + start_at: string; + end_at: string; + status: "confirmed" | "cancelled"; + attendees: { name: string; email: string }[]; + created_at: string; + host_name?: string; // populated only in the admin "All bookings" view + location_value?: string; + /** Payment fields — present only for paid bookings (omitted when free). */ + payment_status?: "pending" | "paid" | "refunded"; + amount_paid_cents?: number; + amount_paid_currency?: string; + /** The booker's RSVP to a Calnode-sent invite; absent until an answer arrives. */ + rsvp_status?: "accepted" | "declined" | "tentative"; }; export type APIKey = { - id: string; - name: string; - created_at: string; - last_used_at?: string; + id: string; + name: string; + created_at: string; + last_used_at?: string; }; export type OAuthConnection = { - id: string; - client_name: string; - created_at: string; - last_used_at?: string; - expires_at: string; + id: string; + client_name: string; + created_at: string; + last_used_at?: string; + expires_at: string; }; export type Webhook = { - id: string; - url: string; - events: string[]; - fields?: string[]; - is_active: boolean; - created_at: string; + id: string; + url: string; + events: string[]; + fields?: string[]; + is_active: boolean; + created_at: string; }; export type WebhookDelivery = { - id: string; - webhook_id: string; - event: string; - status: string; - booking_id?: string; - response_status?: number; - attempt_count: number; - last_attempted_at?: string; + id: string; + webhook_id: string; + event: string; + status: string; + booking_id?: string; + response_status?: number; + attempt_count: number; + last_attempted_at?: string; }; export type CalendarConnection = { - id: string; - provider: string; - account_email: string; - is_destination: boolean; - check_conflicts: boolean; + id: string; + provider: string; + account_email: string; + is_destination: boolean; + check_conflicts: boolean; }; export type CalendarPick = { - id: string; - name: string; - primary: boolean; - writable: boolean; // false for a read-only shared calendar: valid for conflicts, not as a write target - check_conflicts: boolean; - is_destination: boolean; + id: string; + name: string; + primary: boolean; + writable: boolean; // false for a read-only shared calendar: valid for conflicts, not as a write target + check_conflicts: boolean; + is_destination: boolean; }; export type CalendarStatus = { - connected: boolean; - configured?: boolean; - calendar_id?: string; - provider?: string; // destination provider name, when connected - providers?: string[]; // configured providers available to connect - connections?: CalendarConnection[]; // all connected calendars (many checked, one destination) - unconfigured_providers?: string[]; // providers Calnode supports but this instance has no credentials for + connected: boolean; + configured?: boolean; + calendar_id?: string; + provider?: string; // destination provider name, when connected + providers?: string[]; // configured providers available to connect + connections?: CalendarConnection[]; // all connected calendars (many checked, one destination) + unconfigured_providers?: string[]; // providers Calnode supports but this instance has no credentials for }; export type EmailSettings = { - smtp_host: string; - smtp_port: string; - smtp_user: string; - smtp_pass_set: boolean; // true when a password is stored; never returned directly - smtp_tls: boolean; - smtp_starttls: boolean; - email_from: string; - email_from_name: string; - resend_api_key_set: boolean; // true when a key is stored; never returned directly - // Which path mail actually goes out over. "SMTP fields are filled in" and "mail is - // being delivered over SMTP" can differ, so the server reports the live answer. - transport: 'none' | 'smtp' | 'resend_api'; - enabled: boolean; - /** RSVP tracking for invites Calnode sends: the Resend inbound address RSVPs are routed - * through (e.g. rsvp@reply.example.com). */ - rsvp_address: string; - resend_webhook_secret_set: boolean; // never returned directly - /** True when address, webhook secret and Resend API key are all present. */ - rsvp_tracking: boolean; - /** Where Resend must deliver email.received: this instance's BASE_URL + the inbound path. */ - rsvp_webhook_url: string; + smtp_host: string; + smtp_port: string; + smtp_user: string; + smtp_pass_set: boolean; // true when a password is stored; never returned directly + smtp_tls: boolean; + smtp_starttls: boolean; + email_from: string; + email_from_name: string; + resend_api_key_set: boolean; // true when a key is stored; never returned directly + // Which path mail actually goes out over. "SMTP fields are filled in" and "mail is + // being delivered over SMTP" can differ, so the server reports the live answer. + transport: "none" | "smtp" | "resend_api"; + enabled: boolean; + /** RSVP tracking for invites Calnode sends: the Resend inbound address RSVPs are routed + * through (e.g. rsvp@reply.example.com). */ + rsvp_address: string; + resend_webhook_secret_set: boolean; // never returned directly + /** True when address, webhook secret and Resend API key are all present. */ + rsvp_tracking: boolean; + /** Where Resend must deliver email.received: this instance's BASE_URL + the inbound path. */ + rsvp_webhook_url: string; }; export type GoogleSettings = { - client_id: string; - client_secret_set: boolean; - configured: boolean; - /** Identity host the server builds OAuth redirect URIs from. */ - base_url: string; + client_id: string; + client_secret_set: boolean; + configured: boolean; + /** Identity host the server builds OAuth redirect URIs from. */ + base_url: string; }; export type ZoomSettings = { - client_id: string; - client_secret_set: boolean; - configured: boolean; - /** Exact redirect URI to register in the Zoom Marketplace app. */ - redirect_uri: string; + client_id: string; + client_secret_set: boolean; + configured: boolean; + /** Exact redirect URI to register in the Zoom Marketplace app. */ + redirect_uri: string; }; export type ZoomStatus = { - configured: boolean; // a Zoom app is set up for the instance - connected: boolean; // the current host has connected their Zoom account + configured: boolean; // a Zoom app is set up for the instance + connected: boolean; // the current host has connected their Zoom account }; export type StripeSettings = { - publishable_key: string; - secret_key_set: boolean; - webhook_secret_set: boolean; - configured: boolean; // can take a payment AND verify the confirming webhook - /** The endpoint to register in the Stripe dashboard. */ - webhook_url: string; + publishable_key: string; + secret_key_set: boolean; + webhook_secret_set: boolean; + configured: boolean; // can take a payment AND verify the confirming webhook + /** The endpoint to register in the Stripe dashboard. */ + webhook_url: string; }; export type LLMSettings = { - enabled: boolean; - endpoint: string; - model: string; - api_key_set: boolean; - configured: boolean; - /** true when a live client is active (enabled + configured). */ - active: boolean; - /** admin "additional instructions" appended to the base prompt. */ - extra_instructions: string; - /** read-only, code-owned base system prompt (not editable). */ - base_prompt: string; + enabled: boolean; + endpoint: string; + model: string; + api_key_set: boolean; + configured: boolean; + /** true when a live client is active (enabled + configured). */ + active: boolean; + /** admin "additional instructions" appended to the base prompt. */ + extra_instructions: string; + /** read-only, code-owned base system prompt (not editable). */ + base_prompt: string; }; export type TeamMember = { - id: string; - email: string; - name: string; - handle?: string; - timezone: string; - is_admin: boolean; - is_owner: boolean; - role: 'owner' | 'admin' | 'member'; - email_login: boolean; - provider?: string; - avatar_url?: string; - created_at: string; - archived: boolean; - archived_at?: string; - archived_by?: string; - archived_by_name?: string; - teams: { id: string; name: string }[]; + id: string; + email: string; + name: string; + handle?: string; + timezone: string; + is_admin: boolean; + is_owner: boolean; + role: "owner" | "admin" | "member"; + email_login: boolean; + provider?: string; + avatar_url?: string; + created_at: string; + archived: boolean; + archived_at?: string; + archived_by?: string; + archived_by_name?: string; + teams: { id: string; name: string }[]; }; export type Team = { - id: string; - name: string; - slug: string; - created_at: string; - member_count: number; - members?: TeamMemberRef[]; + id: string; + name: string; + slug: string; + created_at: string; + member_count: number; + members?: TeamMemberRef[]; }; export type TeamMemberRef = { - id: string; - name: string; - email: string; - avatar_url?: string; - routing_priority: number; - archived: boolean; + id: string; + name: string; + email: string; + avatar_url?: string; + routing_priority: number; + archived: boolean; }; export type UpcomingBooking = { - id: string; - start_at: string; - end_at: string; - event_type_name: string; - event_type_slug: string; - attendee_name: string; - attendee_email: string; + id: string; + start_at: string; + end_at: string; + event_type_name: string; + event_type_slug: string; + attendee_name: string; + attendee_email: string; }; export type Invite = { - id: string; - email: string; - expires_at: string; - created_by: string; + id: string; + email: string; + expires_at: string; + created_by: string; }; export type AvailabilityRule = { - id: string; - event_type_id: string | null; - day_of_week: number; - start_time: string; - end_time: string; + id: string; + event_type_id: string | null; + day_of_week: number; + start_time: string; + end_time: string; }; export type AvailabilityOverride = { - id: string; - date: string; - is_available: boolean; - reason: 'day_off' | 'out_of_office' | 'custom_hours'; - start_time: string | null; - end_time: string | null; - /** Set on per-date rows that belong to a multi-day out-of-office span. */ - group_id?: string; + id: string; + date: string; + is_available: boolean; + reason: "day_off" | "out_of_office" | "custom_hours"; + start_time: string | null; + end_time: string | null; + /** Set on per-date rows that belong to a multi-day out-of-office span. */ + group_id?: string; }; async function apiFetch(path: string, opts: RequestInit = {}): Promise { - const res = await fetch(path, { - credentials: 'same-origin', - headers: { - ...(opts.body && typeof opts.body === 'string' - ? { 'Content-Type': 'application/json' } - : {}), - ...((opts.headers as Record) ?? {}) - }, - ...opts - }); - - if (res.status === 401) { - window.location.href = '/admin/login'; - throw new Error('unauthenticated'); - } - - if (res.status === 204) return null as T; - - const data = await res.json().catch(() => ({ error: res.statusText })); - if (!res.ok) { - const err = new Error(data.error ?? `HTTP ${res.status}`) as Error & { status?: number }; - err.status = res.status; - throw err; - } - return data as T; + const res = await fetch(path, { + credentials: "same-origin", + headers: { + ...(opts.body && typeof opts.body === "string" + ? { "Content-Type": "application/json" } + : {}), + ...((opts.headers as Record) ?? {}), + }, + ...opts, + }); + + if (res.status === 401) { + window.location.href = "/admin/login"; + throw new Error("unauthenticated"); + } + + if (res.status === 204) return null as T; + + const data = await res.json().catch(() => ({ error: res.statusText })); + if (!res.ok) { + const err = new Error(data.error ?? `HTTP ${res.status}`) as Error & { + status?: number; + }; + err.status = res.status; + throw err; + } + return data as T; } export const api = { - get: (path: string) => apiFetch(path), - - post: (path: string, body?: unknown) => - apiFetch(path, { method: 'POST', body: body ? JSON.stringify(body) : undefined }), - - postForm: (path: string, data: FormData) => - apiFetch(path, { method: 'POST', body: data }), - - patch: (path: string, body?: unknown) => - apiFetch(path, { method: 'PATCH', body: body ? JSON.stringify(body) : undefined }), - - put: (path: string, body?: unknown) => - apiFetch(path, { method: 'PUT', body: body ? JSON.stringify(body) : undefined }), - - del: (path: string) => apiFetch(path, { method: 'DELETE' }) + get: (path: string) => apiFetch(path), + + post: (path: string, body?: unknown) => + apiFetch(path, { + method: "POST", + body: body ? JSON.stringify(body) : undefined, + }), + + postForm: (path: string, data: FormData) => + apiFetch(path, { method: "POST", body: data }), + + patch: (path: string, body?: unknown) => + apiFetch(path, { + method: "PATCH", + body: body ? JSON.stringify(body) : undefined, + }), + + put: (path: string, body?: unknown) => + apiFetch(path, { + method: "PUT", + body: body ? JSON.stringify(body) : undefined, + }), + + del: (path: string) => apiFetch(path, { method: "DELETE" }), }; diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index 856a229d..b11a9c2a 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -243,7 +243,7 @@
- + --> - {#if version} +
@@ -285,7 +285,7 @@ - + {/if} diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index 39b88d01..a4b32964 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -277,4 +277,4 @@ -{/if} +{/if} \ No newline at end of file diff --git a/frontend/src/routes/bookings/+page.svelte b/frontend/src/routes/bookings/+page.svelte index 35debba5..f4e06103 100644 --- a/frontend/src/routes/bookings/+page.svelte +++ b/frontend/src/routes/bookings/+page.svelte @@ -535,8 +535,8 @@

Intake responses

{#if answersLoading[b.id]}

Loading…

- {:else if !answersCache[b.id] || answersCache[b.id].length === 0} -

No intake responses for this booking.

+ {:else}
{#each answersCache[b.id] as a} diff --git a/internal/booking/list.go b/internal/booking/list.go index d1067265..6e2d62bd 100644 --- a/internal/booking/list.go +++ b/internal/booking/list.go @@ -99,8 +99,6 @@ func (f ListFilter) where(includeWhen bool) (string, []any) { if f.Status != "" { conds = append(conds, "bookings.status = ?") args = append(args, f.Status) - } else { - conds = append(conds, "bookings.status != 'cancelled'") } if f.ViewerID != "" { conds = append(conds, hostsBooking) @@ -135,6 +133,9 @@ func (f ListFilter) where(includeWhen bool) (string, []any) { } args = append(args, sqlTime(f.Now)) } + if len(conds) == 0 { + return "", args + } return "WHERE " + strings.Join(conds, "\n\t\t AND "), args } diff --git a/internal/handler/teams.go b/internal/handler/teams.go index c096625b..4685b379 100644 --- a/internal/handler/teams.go +++ b/internal/handler/teams.go @@ -7,6 +7,7 @@ import ( "net/http" "strings" "time" + "unicode" "github.com/calnode/calnode/internal/db" "github.com/calnode/calnode/internal/uid" @@ -20,7 +21,7 @@ func slugify(s string) string { lastHyphen := false for _, r := range s { switch { - case (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9'): + case (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || unicode.Is(unicode.Greek, r): b.WriteRune(r) lastHyphen = false case r == ' ' || r == '-' || r == '_': diff --git a/internal/handler/templates/_shared.html b/internal/handler/templates/_shared.html index c4855008..6200c1b8 100644 --- a/internal/handler/templates/_shared.html +++ b/internal/handler/templates/_shared.html @@ -129,7 +129,6 @@ }); {{end}} - Calnode {{end}} {{define "demoNoindex"}}{{if .DemoMode}}{{end}}{{end}} diff --git a/internal/handler/templates/book.html b/internal/handler/templates/book.html index 618936b9..84a3898b 100644 --- a/internal/handler/templates/book.html +++ b/internal/handler/templates/book.html @@ -342,6 +342,7 @@

{{call .T "booking_confirmed"}}

nameEl.textContent = defaultName; } + // LOCALE (the resolved server-side locale, not the browser's own) drives these, not // [] — otherwise a visitor who picked a language via the switcher, or whose // Accept-Language differs from navigator.language, would see translated chrome next @@ -550,23 +551,12 @@

{{call .T "booking_confirmed"}}

el.classList.toggle('hidden', !show); } - let selectedPeriod = null; - function slotPeriod(slot) { - const hour = Number(new Intl.DateTimeFormat('en-GB', {timeZone: TZ, hour: 'numeric', hourCycle: 'h23'}).format(new Date(slot.start))); - return hour < 12 ? 0 : hour < 17 ? 1 : 2; - } function fillSlots(list, ds) { - // Only when this specific day lost starts to the policy - saying it on a day the - // policy did not touch would be noise attached to the wrong cause. const noticeLine = noticeDates.has(ds) ? noticeHintText() : ''; const noticeHTML = noticeLine ? `

${esc(noticeLine)}

` : ''; - // Shown whenever an external calendar check failed: the busy data behind this - // list is incomplete, and booking stays fail-closed at commit time. const degradedHTML = slotsDegraded ? `

${esc(t('calendar_degraded_notice'))}

` : ''; + if (!slotsCache.length) { - // Name the day, and the host when there is exactly one. A bare "No available times." - // never told the visitor whether another day would help, which is the whole - // complaint in #20. const dayLabel = fmtDate(pickedDate); const msg = SOLE_HOST ? BookingLogic.fmt(t('no_available_times_host'), [SOLE_HOST, dayLabel]) @@ -574,26 +564,20 @@

{{call .T "booking_confirmed"}}

list.innerHTML = `

${esc(msg)}

` + noticeHTML + degradedHTML; return; } - // Taken entries render as disabled buttons so they keep the same box and rhythm as - // bookable ones, and are announced as unavailable rather than read out as a plain - // time. `disabled` is what actually prevents picking one; the click guard below is - // the second line, not the first. - const periods = [...new Set(slotsCache.map(slotPeriod))].sort(); - if (!periods.includes(selectedPeriod)) selectedPeriod = periods[0]; - const labels = ['time_morning', 'time_afternoon', 'time_evening']; - const buttons = slotsCache.map((s, i) => ({s, i})).filter(({s}) => slotPeriod(s) === selectedPeriod).map(({s, i}) => s.taken + + // Generate the buttons (greyed-out 'taken' slots are still preserved here) + const buttons = slotsCache.map((s, i) => s.taken ? `` : `` ).join(''); - const choices = periods.map(period => ``).join(''); - list.innerHTML = `
${choices}
${buttons}
`; - // Only meaningful for opted-in event types: when every time on the day is gone, - // say so, rather than leaving a list of struck-through times to be inferred from. + + // Wrap the buttons in a scrollable container + list.innerHTML = `
${buttons}
`; + + // Append standard warnings if (slotsCache.length && !slotsCache.some(s => !s.taken)) { list.insertAdjacentHTML('beforeend', `

${t('all_times_taken')}

`); } - // Appended after a non-empty list too: a day showing 2pm onwards but nothing this - // morning is exactly the "why can't I see those times" case. if (noticeHTML) list.insertAdjacentHTML('beforeend', noticeHTML); if (degradedHTML) list.insertAdjacentHTML('beforeend', degradedHTML); } @@ -633,13 +617,6 @@

{{call .T "booking_confirmed"}}

} $('slots-list').addEventListener('click', e => { - const period = e.target.closest('[data-period]'); - if (period) { - selectedPeriod = Number(period.dataset.period); - fillSlots($('slots-list'), toDateStr(pickedDate.getFullYear(), pickedDate.getMonth(), pickedDate.getDate())); - $('slots-list').querySelector(`[data-period="${selectedPeriod}"]`).focus(); - return; - } const btn = e.target.closest('.slot-btn'); if (!btn || btn.disabled) return; pickSlot(+btn.dataset.i); @@ -950,6 +927,30 @@

{{call .T "booking_confirmed"}}

}()); {{end}} +
+ +
+ + {{template "consentBanner" .}} + + diff --git a/internal/mailer/mailer.go b/internal/mailer/mailer.go index 6bfab2e6..74fe1a67 100644 --- a/internal/mailer/mailer.go +++ b/internal/mailer/mailer.go @@ -1,6 +1,9 @@ package mailer -import "context" +import ( + "context" + /* "fmt" + "net/smtp" */) // Attachment is a file attached to an outbound email. type Attachment struct { @@ -27,3 +30,31 @@ type Mailer interface { type Noop struct{} func (n *Noop) Send(_ context.Context, _ Message) error { return nil } + +/* type loginAuth struct { + username, password string +} + +func LoginAuth(username, password string) smtp.Auth { + return &loginAuth{username, password} +} + +func (a *loginAuth) Start(server *smtp.ServerInfo) (string, []byte, error) { + // This sends: AUTH LOGIN + // The server will then prompt for the username, which your Next() method will catch. + return "LOGIN", nil, nil +} + +func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) { + if more { + switch string(fromServer) { + case "Username:", "VXNlcm5hbWU6": + return []byte(a.username), nil + case "Password:", "UGFzc3dvcmQ6": + return []byte(a.password), nil + default: + return nil, fmt.Errorf("unknown challenge: %s", string(fromServer)) + } + } + return nil, nil +} */ diff --git a/internal/mailer/smtp.go b/internal/mailer/smtp.go index 5816ce7c..31d13bd1 100644 --- a/internal/mailer/smtp.go +++ b/internal/mailer/smtp.go @@ -352,4 +352,4 @@ func base64Wrap(b []byte) string { } sb.WriteString(enc) return sb.String() -} +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 00000000..707bed4d --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "calnode", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC" +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 00000000..9b60ae17 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,9 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: {}