/* global React */ const { useState, useEffect, useMemo } = React; function ContactPage({ navigate }) { const today = new Date(); today.setHours(0,0,0,0); const [viewMonth, setViewMonth] = useState(new Date(today.getFullYear(), today.getMonth(), 1)); const [selDate, setSelDate] = useState(null); const [selSlot, setSelSlot] = useState(null); const [booked, setBooked] = useState(false); const [form, setForm] = useState({ name: "", email: "", company: "", topic: "Process automation", notes: "" }); // generate days const days = useMemo(() => { const first = new Date(viewMonth.getFullYear(), viewMonth.getMonth(), 1); const startDow = (first.getDay() + 6) % 7; // monday-first const daysInMonth = new Date(viewMonth.getFullYear(), viewMonth.getMonth()+1, 0).getDate(); const cells = []; for (let i = 0; i < startDow; i++) cells.push(null); for (let d = 1; d <= daysInMonth; d++) { const date = new Date(viewMonth.getFullYear(), viewMonth.getMonth(), d); const dow = date.getDay(); const isPast = date < today; const isWeekend = dow === 0 || dow === 6; const hasSlot = !isPast && !isWeekend; cells.push({ date, hasSlot, disabled: isPast || isWeekend }); } while (cells.length % 7 !== 0) cells.push(null); return cells; }, [viewMonth]); const slots = useMemo(() => { if (!selDate) return []; // pseudo-random availability per day const seed = selDate.getDate() + selDate.getMonth(); const all = ["09:00","09:30","10:00","10:30","11:00","11:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30"]; return all.map((s, i) => ({ time: s, taken: ((i * (seed+3)) % 5) === 0 })); }, [selDate]); const monthLabel = viewMonth.toLocaleString("en-US", { month: "long", year: "numeric" }); const dows = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]; function shiftMonth(dir) { const next = new Date(viewMonth.getFullYear(), viewMonth.getMonth()+dir, 1); if (next < new Date(today.getFullYear(), today.getMonth(), 1)) return; setViewMonth(next); setSelDate(null); setSelSlot(null); } function confirm() { if (!selDate || !selSlot) return; setBooked(true); } function reset() { setBooked(false); setSelDate(null); setSelSlot(null); } return (
Pick a 30-minute slot. We'll send a calendar invite and a short prep doc so the call is useful from minute one.
{selDate.toLocaleDateString("en-US", { weekday:"long", month:"long", day:"numeric" })} at {selSlot} (GMT+8)
Calendar invite on its way to {form.email}.