From 295c0028828890ce6e6c0d12da3ae56519315058 Mon Sep 17 00:00:00 2001 From: Alan Daniel Date: Thu, 26 Mar 2026 17:37:01 -0400 Subject: [PATCH] format --- .../[slug]/availability/route.ts | 10 ++------ .../api-v2/hubspot-meetings/[slug]/route.ts | 10 ++------ apps/www/app/api-v2/hubspot-meetings/mock.ts | 5 +++- .../hubspot-meeting/CalendarPicker.tsx | 24 +++++++++++++++---- .../sections/hubspot-meeting/Confirmation.tsx | 8 ++++++- .../src/go/sections/hubspot-meeting/api.ts | 10 ++++---- .../src/go/sections/hubspot-meeting/types.ts | 9 ++++++- .../sections/hubspot-meeting/useScheduler.ts | 22 +++++++++++------ 8 files changed, 63 insertions(+), 35 deletions(-) diff --git a/apps/www/app/api-v2/hubspot-meetings/[slug]/availability/route.ts b/apps/www/app/api-v2/hubspot-meetings/[slug]/availability/route.ts index a8014d021f7..1718da6f679 100644 --- a/apps/www/app/api-v2/hubspot-meetings/[slug]/availability/route.ts +++ b/apps/www/app/api-v2/hubspot-meetings/[slug]/availability/route.ts @@ -5,10 +5,7 @@ import { getMockAvailability, shouldUseMock } from '../../mock' const HUBSPOT_BASE = 'https://api.hubspot.com/scheduler/v3/meetings/meeting-links/book/availability-page' -export async function GET( - request: NextRequest, - { params }: { params: Promise<{ slug: string }> } -) { +export async function GET(request: NextRequest, { params }: { params: Promise<{ slug: string }> }) { const { searchParams } = new URL(request.url) const timezone = searchParams.get('timezone') || 'America/New_York' @@ -30,10 +27,7 @@ export async function GET( if (!res.ok) { const text = await res.text() - return NextResponse.json( - { error: 'HubSpot API error', detail: text }, - { status: res.status } - ) + return NextResponse.json({ error: 'HubSpot API error', detail: text }, { status: res.status }) } const data = await res.json() diff --git a/apps/www/app/api-v2/hubspot-meetings/[slug]/route.ts b/apps/www/app/api-v2/hubspot-meetings/[slug]/route.ts index eeff09734ba..318f9559601 100644 --- a/apps/www/app/api-v2/hubspot-meetings/[slug]/route.ts +++ b/apps/www/app/api-v2/hubspot-meetings/[slug]/route.ts @@ -4,10 +4,7 @@ import { getMockBookingInfo, shouldUseMock } from '../mock' const HUBSPOT_BASE = 'https://api.hubspot.com/scheduler/v3/meetings/meeting-links/book' -export async function GET( - request: NextRequest, - { params }: { params: Promise<{ slug: string }> } -) { +export async function GET(request: NextRequest, { params }: { params: Promise<{ slug: string }> }) { const { searchParams } = new URL(request.url) const timezone = searchParams.get('timezone') || 'America/New_York' const monthOffset = parseInt(searchParams.get('monthOffset') || '0', 10) @@ -30,10 +27,7 @@ export async function GET( if (!res.ok) { const text = await res.text() - return NextResponse.json( - { error: 'HubSpot API error', detail: text }, - { status: res.status } - ) + return NextResponse.json({ error: 'HubSpot API error', detail: text }, { status: res.status }) } const data = await res.json() diff --git a/apps/www/app/api-v2/hubspot-meetings/mock.ts b/apps/www/app/api-v2/hubspot-meetings/mock.ts index ef2402c6a20..dfe8acb90f2 100644 --- a/apps/www/app/api-v2/hubspot-meetings/mock.ts +++ b/apps/www/app/api-v2/hubspot-meetings/mock.ts @@ -10,7 +10,10 @@ export function shouldUseMock(): boolean { } /** Generate mock time slots for the next 30 days, excluding weekends */ -function generateMockSlots(timezone: string, monthOffset: number): Record> { +function generateMockSlots( + timezone: string, + monthOffset: number +): Record> { const now = new Date() const target = new Date(now.getFullYear(), now.getMonth() + monthOffset, 1) const daysInMonth = new Date(target.getFullYear(), target.getMonth() + 1, 0).getDate() diff --git a/packages/marketing/src/go/sections/hubspot-meeting/CalendarPicker.tsx b/packages/marketing/src/go/sections/hubspot-meeting/CalendarPicker.tsx index bf84a61d7a3..75a64fcd0c9 100644 --- a/packages/marketing/src/go/sections/hubspot-meeting/CalendarPicker.tsx +++ b/packages/marketing/src/go/sections/hubspot-meeting/CalendarPicker.tsx @@ -67,7 +67,9 @@ export default function CalendarPicker({ disabled={!hasPrev} className={cn( 'p-2 rounded-md text-foreground-lighter transition-colors', - hasPrev ? 'hover:bg-surface-300/50 hover:text-foreground' : 'opacity-30 cursor-not-allowed' + hasPrev + ? 'hover:bg-surface-300/50 hover:text-foreground' + : 'opacity-30 cursor-not-allowed' )} aria-label="Previous month" > @@ -80,7 +82,9 @@ export default function CalendarPicker({ disabled={!hasNext} className={cn( 'p-2 rounded-md text-foreground-lighter transition-colors', - hasNext ? 'hover:bg-surface-300/50 hover:text-foreground' : 'opacity-30 cursor-not-allowed' + hasNext + ? 'hover:bg-surface-300/50 hover:text-foreground' + : 'opacity-30 cursor-not-allowed' )} aria-label="Next month" > @@ -133,7 +137,13 @@ export default function CalendarPicker({ function ChevronLeftIcon() { return ( - + ) } @@ -141,7 +151,13 @@ function ChevronLeftIcon() { function ChevronRightIcon() { return ( - + ) } diff --git a/packages/marketing/src/go/sections/hubspot-meeting/Confirmation.tsx b/packages/marketing/src/go/sections/hubspot-meeting/Confirmation.tsx index 324efc119b2..f6665c73209 100644 --- a/packages/marketing/src/go/sections/hubspot-meeting/Confirmation.tsx +++ b/packages/marketing/src/go/sections/hubspot-meeting/Confirmation.tsx @@ -30,7 +30,13 @@ export default function Confirmation({ confirmation, timezone }: ConfirmationPro return (
- + { +export async function fetchAvailability(slug: string, timezone: string): Promise { const params = new URLSearchParams({ timezone }) let res: Response try { diff --git a/packages/marketing/src/go/sections/hubspot-meeting/types.ts b/packages/marketing/src/go/sections/hubspot-meeting/types.ts index 91b160b4b0a..3c411a60750 100644 --- a/packages/marketing/src/go/sections/hubspot-meeting/types.ts +++ b/packages/marketing/src/go/sections/hubspot-meeting/types.ts @@ -68,4 +68,11 @@ export interface BookingConfirmation { isOffline: boolean } -export type SchedulerStep = 'loading' | 'date-select' | 'time-select' | 'form' | 'submitting' | 'confirmed' | 'error' +export type SchedulerStep = + | 'loading' + | 'date-select' + | 'time-select' + | 'form' + | 'submitting' + | 'confirmed' + | 'error' diff --git a/packages/marketing/src/go/sections/hubspot-meeting/useScheduler.ts b/packages/marketing/src/go/sections/hubspot-meeting/useScheduler.ts index 3a31174ccb6..d61f8fdbcf6 100644 --- a/packages/marketing/src/go/sections/hubspot-meeting/useScheduler.ts +++ b/packages/marketing/src/go/sections/hubspot-meeting/useScheduler.ts @@ -1,7 +1,13 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { bookMeeting, fetchBookingInfo } from './api' -import type { BookingConfirmation, BookingInfo, BookingRequest, SchedulerStep, TimeSlot } from './types' +import type { + BookingConfirmation, + BookingInfo, + BookingRequest, + SchedulerStep, + TimeSlot, +} from './types' /** How many months to prefetch (current + 3 ahead) */ const MONTHS_TO_FETCH = 4 @@ -59,9 +65,7 @@ export function useScheduler(slug: string, enabled = true) { setState((s) => ({ ...s, step: 'loading', error: null })) const results = await Promise.all( - Array.from({ length: MONTHS_TO_FETCH }, (_, i) => - fetchBookingInfo(slug, effectiveTz, i) - ) + Array.from({ length: MONTHS_TO_FETCH }, (_, i) => fetchBookingInfo(slug, effectiveTz, i)) ) const cache: Record = {} @@ -69,8 +73,7 @@ export function useScheduler(slug: string, enabled = true) { cache[i] = results[i] } - const defaultDuration = - results[0]?.customParams?.availableDurations?.[0] ?? 1800000 + const defaultDuration = results[0]?.customParams?.availableDurations?.[0] ?? 1800000 setMonthCache(cache) setState((s) => ({ @@ -134,7 +137,12 @@ export function useScheduler(slug: string, enabled = true) { }, []) const submitBooking = useCallback( - async (form: { firstName: string; lastName: string; email: string; guestEmails?: string[] }) => { + async (form: { + firstName: string + lastName: string + email: string + guestEmails?: string[] + }) => { if (!state.selectedSlot) return setState((s) => ({ ...s, step: 'submitting' }))