feat(frontend): implement interactive invitation SPA and admin dashboard

- Add React 18 + Vite + Typescript application architecture with
  basename /birthday
- Implement invitation experience with golden bokeh particle canvas adn
  countdown timer
- Build Colombian phone validated RSVP flow with optimistic submission
  state machine
- Add Authelia-protected admin dashboard with live RSVP table and
  configuration editor
- Embed self-hosted display and Montserrat fonts without external CDN
  dependencies
- Include self-contained Biome linter configuration with parent VCS root
  resolution
- Update project roadmap reflecting completion of phases 2, 3 and 4
This commit is contained in:
kiskaadee committed 2026-09-30 23:38:18 -05:00
1 parent 6f9026a5e6
commit d4ae37fef8
34 files changed
+4653 -26

No files matched your search

+27 -26
View File
@@ -25,38 +25,39 @@
## Phase 2 — Frontend Scaffolding
- [ ] Vite + React + TypeScript setup
- [ ] React Router with `basename=/birthday`
- [ ] API client (`/birthday/api/*`)
- [ ] Config loading state (`CONFIG_LOADING` → `INVITATION` | `CONFIG_ERROR`)
- [ ] Self-hosted font files (display script + Montserrat)
- [ ] CSS Modules setup and global styles
- [ ] TypeScript interfaces for config and API responses
- [x] Vite + React + TypeScript setup
- [x] React Router with `basename=/birthday`
- [x] API client (`/birthday/api/*`)
- [x] Config loading state (`CONFIG_LOADING` → `INVITATION` | `CONFIG_ERROR`)
- [x] Self-hosted font files (display script + Montserrat)
- [x] CSS Modules setup and global styles
- [x] TypeScript interfaces for config and API responses
## Phase 3 — Guest Experience
- [ ] Invitation hero section (fixed aspect ratio)
- [ ] Canvas 2D particle background (golden bokeh)
- [ ] RSVP CTA with smooth scroll transition
- [ ] RSVP form with client-side validation (Colombian phone format)
- [ ] Submission state machine (`SUBMITTING` → `SUCCESS` | `DUPLICATE` | `ERROR`)
- [ ] Confirmation section: personalized message
- [ ] Countdown timer (timezone-aware, `NOS VEMOS EN DD:HH:MM:SS`)
- [ ] Map preview (circular static image, link to `mapUrl`)
- [ ] Venue info (compact name + address)
- [ ] `sessionStorage` post-RSVP state preservation
- [ ] Accessibility (semantic HTML, keyboard nav, aria-live, focus states)
- [ ] `prefers-reduced-motion` support (static particles)
- [ ] Responsive behavior (mobile-first, desktop stage)
- [x] Invitation hero section (fixed aspect ratio)
- [x] Canvas 2D particle background (golden bokeh)
- [x] RSVP CTA with smooth scroll transition
- [x] RSVP form with client-side validation (Colombian phone format)
- [x] Submission state machine (`SUBMITTING` → `SUCCESS` | `DUPLICATE` | `ERROR`)
- [x] Confirmation section: personalized message
- [x] Countdown timer (timezone-aware, `NOS VEMOS EN DD:HH:MM:SS`)
- [x] Map preview (circular static image, link to `mapUrl`)
- [x] Venue info (compact name + address)
- [x] `sessionStorage` post-RSVP state preservation
- [x] Accessibility (semantic HTML, keyboard nav, aria-live, focus states)
- [x] `prefers-reduced-motion` support (static particles)
- [x] Responsive behavior (mobile-first, desktop stage)
## Phase 4 — Admin Dashboard
- [ ] Admin layout shell (header, navigation)
- [ ] RSVP table with total count
- [ ] Search/filter RSVPs
- [ ] CSV export download button
- [ ] Config editor form (flat fields, Pydantic-validated)
- [ ] Text preview of invitation content
- [x] Admin layout shell (header, navigation)
- [x] RSVP table with total count
- [x] Search/filter RSVPs
- [x] CSV export download button
- [x] Config editor form (flat fields, Pydantic-validated)
- [x] Text preview of invitation content
## Phase 5 — Infrastructure & Deployment
+34
View File
@@ -0,0 +1,34 @@
{
"$schema": "https://biomejs.dev/schemas/2.5.14/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true,
"root": ".."
},
"files": {
"ignoreUnknown": true,
"includes": ["src/**", "vite.config.ts"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 90
},
"linter": {
"enabled": true,
"rules": {
"preset": "recommended",
"correctness": {
"useExhaustiveDependencies": "warn"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"semicolons": "always"
}
}
}
+14
View File
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/birthday/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="theme-color" content="#0a0a0a" />
<title>Birthday Party — Invitación</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
+1834
View File
File diff suppressed because it is too large. Load diff
+26
View File
@@ -0,0 +1,26 @@
{
"name": "bdinvite-frontend",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"preview": "vite preview",
"lint": "biome check .",
"lint:fix": "biome check --write .",
"format": "biome format --write ."
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.2"
},
"devDependencies": {
"@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.2",
"typescript": "^5.6.2",
"vite": "^5.4.8"
}
}
Binary file not shown.
+27
View File
@@ -0,0 +1,27 @@
import { BrowserRouter, Navigate, Route, Routes } from "react-router-dom";
import { AdminLayout } from "./admin/AdminLayout";
import { ConfigEditor } from "./admin/ConfigEditor";
import { RsvpTable } from "./admin/RsvpTable";
import { Invitation } from "./invitation/Invitation";
export function App() {
return (
<BrowserRouter basename="/birthday">
<Routes>
{/* Guest Public Route */}
<Route path="/" element={<Invitation />} />
{/* Authelia-Protected Admin Dashboard */}
<Route path="/admin" element={<AdminLayout />}>
<Route index element={<RsvpTable />} />
<Route path="config" element={<ConfigEditor />} />
</Route>
{/* Catch-all fallback */}
<Route path="*" element={<Navigate to="/" replace />} />
</Routes>
</BrowserRouter>
);
}
export default App;
+106
View File
@@ -0,0 +1,106 @@
import { Link, NavLink, Outlet } from "react-router-dom";
export function AdminLayout() {
return (
<div
style={{
minHeight: "100vh",
backgroundColor: "#0f0f10",
color: "#f0f0f0",
fontFamily: "var(--font-body)",
}}
>
{/* Admin Navigation Bar */}
<header
style={{
borderBottom: "1px solid rgba(255, 255, 255, 0.1)",
backgroundColor: "#161618",
padding: "1rem 1.8rem",
display: "flex",
alignItems: "center",
justifyContent: "space-between",
flexWrap: "wrap",
gap: "1rem",
}}
>
<div style={{ display: "flex", alignItems: "center", gap: "0.8rem" }}>
<span style={{ fontSize: "1.4rem" }}>🎂</span>
<h1
style={{
fontSize: "1.1rem",
fontWeight: 600,
letterSpacing: "0.08em",
color: "#ffffff",
textTransform: "uppercase",
}}
>
Panel de Control · Invitación
</h1>
</div>
<nav style={{ display: "flex", alignItems: "center", gap: "1.4rem" }}>
<NavLink
to="/admin"
end
style={({ isActive }) => ({
color: isActive ? "var(--color-gold-light)" : "rgba(255, 255, 255, 0.7)",
textDecoration: "none",
fontSize: "0.88rem",
fontWeight: 500,
borderBottom: isActive
? "2px solid var(--color-gold)"
: "2px solid transparent",
paddingBottom: "0.25rem",
transition: "all 0.2s ease",
})}
>
Respuestas
</NavLink>
<NavLink
to="/admin/config"
style={({ isActive }) => ({
color: isActive ? "var(--color-gold-light)" : "rgba(255, 255, 255, 0.7)",
textDecoration: "none",
fontSize: "0.88rem",
fontWeight: 500,
borderBottom: isActive
? "2px solid var(--color-gold)"
: "2px solid transparent",
paddingBottom: "0.25rem",
transition: "all 0.2s ease",
})}
>
Configuración
</NavLink>
<Link
to="/"
target="_blank"
rel="noopener noreferrer"
style={{
color: "rgba(255, 255, 255, 0.5)",
textDecoration: "none",
fontSize: "0.82rem",
display: "inline-flex",
alignItems: "center",
gap: "0.3rem",
}}
>
<span>Ver Pública</span>
<span>↗</span>
</Link>
</nav>
</header>
{/* Main Admin Content Container */}
<div
style={{
maxWidth: "1000px",
margin: "0 auto",
padding: "2rem 1.5rem",
}}
>
<Outlet />
</div>
</div>
);
}
+374
View File
@@ -0,0 +1,374 @@
import { type FormEvent, useEffect, useState } from "react";
import { fetchAdminConfig, updateAdminConfig } from "../api/client";
import { Button } from "../components/Button";
import { Field } from "../components/Field";
import { Spinner } from "../components/Spinner";
import type { InvitationConfig } from "../types/config";
export function ConfigEditor() {
const [formData, setFormData] = useState<InvitationConfig | null>(null);
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const [feedback, setFeedback] = useState<{
type: "success" | "error";
msg: string;
} | null>(null);
useEffect(() => {
async function load() {
try {
const data = await fetchAdminConfig();
setFormData(data);
} catch (err) {
setFeedback({
type: "error",
msg: err instanceof Error ? err.message : "Error al cargar la configuración.",
});
} finally {
setLoading(false);
}
}
load();
}, []);
function handleChange(field: keyof InvitationConfig, value: string) {
if (!formData) return;
setFormData({ ...formData, [field]: value });
}
async function handleSubmit(e: FormEvent) {
e.preventDefault();
if (!formData || saving) return;
setSaving(true);
setFeedback(null);
try {
const { id, updated_at, ...cleanPayload } = formData;
const updated = await updateAdminConfig(cleanPayload);
setFormData(updated);
setFeedback({ type: "success", msg: "¡Configuración guardada exitosamente!" });
} catch (err) {
setFeedback({
type: "error",
msg: err instanceof Error ? err.message : "Error al guardar.",
});
} finally {
setSaving(false);
}
}
if (loading) {
return (
<div style={{ padding: "4rem", textAlign: "center" }}>
<Spinner size={32} />
</div>
);
}
if (!formData) {
return (
<div style={{ color: "var(--color-error)", padding: "2rem" }}>
{feedback?.msg || "No se pudo cargar la configuración."}
</div>
);
}
return (
<div style={{ display: "grid", gridTemplateColumns: "1fr", gap: "2.5rem" }}>
<div>
<h2
style={{
fontSize: "1.4rem",
fontWeight: 600,
color: "#ffffff",
marginBottom: "0.4rem",
}}
>
Editar Contenido de la Invitación
</h2>
<p
style={{
fontSize: "0.88rem",
color: "rgba(255, 255, 255, 0.6)",
marginBottom: "1.8rem",
}}
>
Los cambios guardados se reflejan inmediatamente en la invitación pública.
</p>
{feedback && (
<div
style={{
padding: "0.9rem 1.2rem",
borderRadius: "4px",
marginBottom: "1.8rem",
backgroundColor:
feedback.type === "success"
? "rgba(46, 204, 113, 0.15)"
: "var(--color-error-bg)",
border: `1px solid ${feedback.type === "success" ? "#2ecc71" : "var(--color-error)"}`,
color: feedback.type === "success" ? "#2ecc71" : "#ff8b80",
fontSize: "0.88rem",
}}
>
{feedback.msg}
</div>
)}
<form onSubmit={handleSubmit}>
<div
style={{
display: "grid",
gridTemplateColumns: "repeat(auto-fit, minmax(280px, 1fr))",
gap: "1rem",
}}
>
<Field
label="Título Principal"
value={formData.title}
onChange={(e) => handleChange("title", e.target.value)}
required
/>
<Field
label="Nombre del Homenajeado(a)"
value={formData.honoree_name}
onChange={(e) => handleChange("honoree_name", e.target.value)}
required
/>
</div>
<Field
label="Texto de Invitación"
value={formData.invitation_text}
onChange={(e) => handleChange("invitation_text", e.target.value)}
required
/>
<div
style={{
display: "grid",
gridTemplateColumns: "repeat(auto-fit, minmax(180px, 1fr))",
gap: "1rem",
}}
>
<Field
label="Fecha del Evento (YYYY-MM-DD)"
value={formData.event_date}
onChange={(e) => handleChange("event_date", e.target.value)}
required
/>
<Field
label="Hora del Evento (HH:MM)"
value={formData.event_time}
onChange={(e) => handleChange("event_time", e.target.value)}
required
/>
<Field
label="Zona Horaria IANA"
value={formData.event_timezone}
onChange={(e) => handleChange("event_timezone", e.target.value)}
required
/>
</div>
<div
style={{
display: "grid",
gridTemplateColumns: "repeat(auto-fit, minmax(280px, 1fr))",
gap: "1rem",
}}
>
<Field
label="Nombre del Lugar"
value={formData.address_name}
onChange={(e) => handleChange("address_name", e.target.value)}
required
/>
<Field
label="Enlace a Google Maps (map_url)"
value={formData.map_url}
onChange={(e) => handleChange("map_url", e.target.value)}
required
/>
</div>
<div style={{ marginBottom: "1.4rem" }}>
<label
htmlFor="address_lines"
style={{
display: "block",
fontSize: "0.72rem",
fontWeight: 500,
letterSpacing: "0.15em",
textTransform: "uppercase",
color: "var(--color-text-muted)",
marginBottom: "0.45rem",
}}
>
Dirección (una línea por renglón)
</label>
<textarea
id="address_lines"
rows={3}
value={formData.address_lines}
onChange={(e) => handleChange("address_lines", e.target.value)}
style={{
width: "100%",
padding: "0.85rem 1rem",
backgroundColor: "rgba(255, 255, 255, 0.05)",
border: "1px solid var(--color-gold-border)",
borderRadius: "4px",
color: "var(--color-text)",
fontSize: "0.95rem",
outline: "none",
}}
/>
</div>
<Field
label="URL de Imagen Previa del Mapa (map_preview_url)"
value={formData.map_preview_url}
onChange={(e) => handleChange("map_preview_url", e.target.value)}
required
/>
<div
style={{
display: "grid",
gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))",
gap: "1rem",
}}
>
<Field
label="Encabezado del Formulario"
value={formData.rsvp_heading}
onChange={(e) => handleChange("rsvp_heading", e.target.value)}
required
/>
<Field
label="Texto del Botón CTA Inicial"
value={formData.rsvp_cta}
onChange={(e) => handleChange("rsvp_cta", e.target.value)}
required
/>
<Field
label="Texto del Botón de Envío"
value={formData.submit_label}
onChange={(e) => handleChange("submit_label", e.target.value)}
required
/>
</div>
<div
style={{
display: "grid",
gridTemplateColumns: "repeat(auto-fit, minmax(250px, 1fr))",
gap: "1rem",
}}
>
<Field
label="Mensaje de Confirmación Éxito"
value={formData.msg_success}
onChange={(e) => handleChange("msg_success", e.target.value)}
required
/>
<Field
label="Saludo de Éxito ({name})"
value={formData.msg_success_greeting}
onChange={(e) => handleChange("msg_success_greeting", e.target.value)}
required
/>
</div>
<Field
label="Mensaje para Teléfono Duplicado"
value={formData.msg_duplicate}
onChange={(e) => handleChange("msg_duplicate", e.target.value)}
required
/>
<div style={{ marginTop: "2rem" }}>
<Button type="submit" variant="primary" disabled={saving}>
{saving ? "Guardando..." : "Guardar Cambios"}
</Button>
</div>
</form>
</div>
{/* Live Plain-Text Preview Section */}
<div
style={{
borderTop: "1px solid rgba(255, 255, 255, 0.1)",
paddingTop: "2rem",
}}
>
<h3
style={{
fontSize: "1.1rem",
fontWeight: 600,
color: "var(--color-gold-light)",
textTransform: "uppercase",
letterSpacing: "0.1em",
marginBottom: "1rem",
}}
>
Vista Previa de Composición (Texto)
</h3>
<div
style={{
backgroundColor: "#161618",
border: "1px solid rgba(255, 255, 255, 0.08)",
borderRadius: "6px",
padding: "1.8rem",
lineHeight: 1.8,
fontSize: "0.92rem",
maxWidth: "500px",
}}
>
<p style={{ fontSize: "1.5rem", fontWeight: 700, color: "#ffffff" }}>
{formData.title}
</p>
<p
style={{
letterSpacing: "0.15em",
textTransform: "uppercase",
color: "rgba(255, 255, 255, 0.6)",
}}
>
{formData.invitation_text}
</p>
<p
style={{
fontSize: "1.3rem",
color: "var(--color-gold-light)",
margin: "0.6rem 0",
}}
>
{formData.honoree_name}
</p>
<p style={{ color: "#ffffff" }}>
📅 {formData.event_date} · ⏰ {formData.event_time} ({formData.event_timezone}
)
</p>
<p style={{ color: "#ffffff", marginTop: "0.4rem" }}>
📍 {formData.address_name} — {formData.address_lines.replace(/\n/g, ", ")}
</p>
<div
style={{
marginTop: "1rem",
paddingTop: "0.8rem",
borderTop: "1px dashed rgba(255, 255, 255, 0.15)",
}}
>
<p style={{ color: "var(--color-gold)" }}>CTA: {formData.rsvp_cta}</p>
<p style={{ color: "var(--color-text-dim)", fontSize: "0.82rem" }}>
Éxito: "{formData.msg_success}"{" "}
{formData.msg_success_greeting.replace("{name}", "[Nombre]")}
</p>
</div>
</div>
</div>
</div>
);
}
+245
View File
@@ -0,0 +1,245 @@
import { useCallback, useEffect, useState } from "react";
import { fetchAdminRsvps, getExportCsvUrl } from "../api/client";
import { Button } from "../components/Button";
import { Spinner } from "../components/Spinner";
import type { RSVPAdminItem } from "../types/config";
export function RsvpTable() {
const [rsvps, setRsvps] = useState<RSVPAdminItem[]>([]);
const [count, setCount] = useState<number>(0);
const [search, setSearch] = useState<string>("");
const [loading, setLoading] = useState<boolean>(true);
const [error, setError] = useState<string | null>(null);
const loadData = useCallback(async (searchTerm = "") => {
setLoading(true);
setError(null);
try {
const data = await fetchAdminRsvps(searchTerm);
setRsvps(data.rsvps);
setCount(data.count);
} catch (err) {
setError(err instanceof Error ? err.message : "Error al cargar las respuestas.");
} finally {
setLoading(false);
}
}, []);
useEffect(() => {
loadData(search);
}, [search, loadData]);
function formatDate(isoStr: string) {
if (!isoStr) return "—";
try {
const d = new Date(isoStr);
return d.toLocaleDateString("es-CO", {
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
});
} catch {
return isoStr;
}
}
function formatPhone(phone: string) {
if (phone.length === 10) {
return `${phone.slice(0, 3)} ${phone.slice(3, 6)} ${phone.slice(6)}`;
}
return phone;
}
return (
<div>
{/* Top action bar: Count, Search, Export */}
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "space-between",
flexWrap: "wrap",
gap: "1.2rem",
marginBottom: "1.8rem",
}}
>
<div>
<h2 style={{ fontSize: "1.4rem", fontWeight: 600, color: "#ffffff" }}>
Asistentes Confirmados
</h2>
<p
style={{
fontSize: "0.88rem",
color: "rgba(255, 255, 255, 0.6)",
marginTop: "0.2rem",
}}
>
Total de registros:{" "}
<strong style={{ color: "var(--color-gold-light)" }}>{count}</strong>
</p>
</div>
<div
style={{ display: "flex", alignItems: "center", gap: "1rem", flexWrap: "wrap" }}
>
<input
type="search"
placeholder="Buscar por nombre, tel..."
value={search}
onChange={(e) => setSearch(e.target.value)}
style={{
padding: "0.6rem 1rem",
borderRadius: "4px",
backgroundColor: "rgba(255, 255, 255, 0.08)",
border: "1px solid rgba(255, 255, 255, 0.2)",
color: "#ffffff",
fontSize: "0.88rem",
outline: "none",
minWidth: "220px",
}}
/>
<a
href={getExportCsvUrl()}
download="rsvps.csv"
style={{ textDecoration: "none" }}
>
<Button
variant="outline"
style={{ padding: "0.6rem 1.2rem", fontSize: "0.75rem" }}
>
Descargar CSV ⤓
</Button>
</a>
</div>
</div>
{error && (
<div
style={{
padding: "1rem",
backgroundColor: "var(--color-error-bg)",
border: "1px solid var(--color-error)",
borderRadius: "4px",
color: "#ff8b80",
marginBottom: "1.5rem",
fontSize: "0.88rem",
}}
>
{error}
</div>
)}
{/* Table container */}
<div
style={{
backgroundColor: "#161618",
borderRadius: "6px",
border: "1px solid rgba(255, 255, 255, 0.08)",
overflowX: "auto",
}}
>
<table
style={{
width: "100%",
borderCollapse: "collapse",
textAlign: "left",
fontSize: "0.88rem",
}}
>
<thead>
<tr
style={{
borderBottom: "1px solid rgba(255, 255, 255, 0.12)",
backgroundColor: "rgba(255, 255, 255, 0.03)",
color: "rgba(255, 255, 255, 0.6)",
fontSize: "0.75rem",
letterSpacing: "0.1em",
textTransform: "uppercase",
}}
>
<th style={{ padding: "0.9rem 1.2rem" }}>Nombre</th>
<th style={{ padding: "0.9rem 1.2rem" }}>Teléfono</th>
<th style={{ padding: "0.9rem 1.2rem" }}>Correo</th>
<th style={{ padding: "0.9rem 1.2rem" }}>Fecha de Registro</th>
</tr>
</thead>
<tbody>
{loading ? (
<tr>
<td colSpan={4} style={{ padding: "3rem", textAlign: "center" }}>
<Spinner size={28} />
</td>
</tr>
) : rsvps.length === 0 ? (
<tr>
<td
colSpan={4}
style={{
padding: "3rem",
textAlign: "center",
color: "rgba(255, 255, 255, 0.5)",
}}
>
{search
? "No se encontraron coincidencias."
: "Aún no hay confirmaciones registradas."}
</td>
</tr>
) : (
rsvps.map((row) => (
<tr
key={row.id}
style={{
borderBottom: "1px solid rgba(255, 255, 255, 0.06)",
transition: "background-color 0.15s ease",
}}
onMouseEnter={(e) => {
e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.04)";
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = "transparent";
}}
>
<td
style={{
padding: "0.9rem 1.2rem",
fontWeight: 500,
color: "#ffffff",
}}
>
{row.name}
</td>
<td
style={{ padding: "0.9rem 1.2rem", color: "var(--color-gold-light)" }}
>
{formatPhone(row.phone)}
</td>
<td
style={{
padding: "0.9rem 1.2rem",
color: "rgba(255, 255, 255, 0.7)",
}}
>
{row.email || "—"}
</td>
<td
style={{
padding: "0.9rem 1.2rem",
color: "rgba(255, 255, 255, 0.5)",
fontSize: "0.8rem",
}}
>
{formatDate(row.created_at)}
</td>
</tr>
))
)}
</tbody>
</table>
</div>
</div>
);
}
+88
View File
@@ -0,0 +1,88 @@
import type {
InvitationConfig,
RSVPApiResult,
RSVPListResponse,
RSVPRequest,
} from "../types/config";
const BASE_API = "/birthday/api";
export async function fetchConfig(): Promise<InvitationConfig> {
const res = await fetch(`${BASE_API}/config`, {
headers: { Accept: "application/json" },
});
if (!res.ok) {
throw new Error(`Failed to load config: HTTP ${res.status}`);
}
return res.json();
}
export async function submitRsvp(data: RSVPRequest): Promise<RSVPApiResult> {
try {
const res = await fetch(`${BASE_API}/rsvp`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(data),
});
const json = await res.json();
return json as RSVPApiResult;
} catch {
return { result: "ERROR" };
}
}
export async function fetchAdminRsvps(search?: string): Promise<RSVPListResponse> {
const url = new URL(`${BASE_API}/admin/rsvps`, window.location.origin);
if (search?.trim()) {
url.searchParams.set("search", search.trim());
}
const res = await fetch(url.toString(), {
headers: { Accept: "application/json" },
});
if (!res.ok) {
throw new Error(`Error fetching admin RSVPs: HTTP ${res.status}`);
}
return res.json();
}
export async function fetchAdminConfig(): Promise<InvitationConfig> {
const res = await fetch(`${BASE_API}/admin/config`, {
headers: { Accept: "application/json" },
});
if (!res.ok) {
throw new Error(`Error fetching admin config: HTTP ${res.status}`);
}
return res.json();
}
export async function updateAdminConfig(
config: Omit<InvitationConfig, "id" | "updated_at">,
): Promise<InvitationConfig> {
const res = await fetch(`${BASE_API}/admin/config`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(config),
});
if (!res.ok) {
const errorJson = await res.json().catch(() => null);
const msg = errorJson?.errors
? Object.values(errorJson.errors).join(", ")
: `HTTP ${res.status}`;
throw new Error(`Error saving configuration: ${msg}`);
}
return res.json();
}
export function getExportCsvUrl(): string {
return `${BASE_API}/admin/export`;
}
+54
View File
@@ -0,0 +1,54 @@
import type { ButtonHTMLAttributes } from "react";
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: "primary" | "secondary" | "outline";
fullWidth?: boolean;
}
export function Button({
children,
variant = "primary",
fullWidth = false,
disabled,
style,
...props
}: ButtonProps) {
const isPrimary = variant === "primary";
const isOutline = variant === "outline";
return (
<button
disabled={disabled}
style={{
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
padding: "0.85rem 1.8rem",
fontSize: "0.85rem",
fontWeight: 600,
letterSpacing: "0.18em",
textTransform: "uppercase",
borderRadius: "4px",
border: isOutline
? "1px solid var(--color-gold)"
: isPrimary
? "1px solid var(--color-gold)"
: "1px solid rgba(255, 255, 255, 0.2)",
backgroundColor: isPrimary
? "var(--color-gold)"
: isOutline
? "transparent"
: "rgba(255, 255, 255, 0.08)",
color: isPrimary ? "#0a0a0a" : "var(--color-text)",
opacity: disabled ? 0.6 : 1,
cursor: disabled ? "not-allowed" : "pointer",
transition: "all 0.2s ease",
width: fullWidth ? "100%" : "auto",
...style,
}}
{...props}
>
{children}
</button>
);
}
+92
View File
@@ -0,0 +1,92 @@
import type { InputHTMLAttributes } from "react";
interface FieldProps extends InputHTMLAttributes<HTMLInputElement> {
label: string;
error?: string;
hint?: string;
}
export function Field({ label, id, error, hint, disabled, style, ...props }: FieldProps) {
const inputId = id || `field-${label.toLowerCase().replace(/\s+/g, "-")}`;
const errorId = `${inputId}-error`;
const hintId = `${inputId}-hint`;
return (
<div style={{ marginBottom: "1.4rem", width: "100%", textAlign: "left" }}>
<label
htmlFor={inputId}
style={{
display: "block",
fontSize: "0.72rem",
fontWeight: 500,
letterSpacing: "0.15em",
textTransform: "uppercase",
color: "var(--color-text-muted)",
marginBottom: "0.45rem",
}}
>
{label}
</label>
<input
id={inputId}
disabled={disabled}
aria-invalid={Boolean(error)}
aria-describedby={error ? errorId : hint ? hintId : undefined}
style={{
width: "100%",
padding: "0.85rem 1rem",
backgroundColor: "rgba(255, 255, 255, 0.05)",
border: error
? "1px solid var(--color-error)"
: "1px solid var(--color-gold-border)",
borderRadius: "4px",
color: "var(--color-text)",
fontSize: "0.95rem",
outline: "none",
transition: "border-color 0.2s ease, box-shadow 0.2s ease",
...style,
}}
onFocus={(e) => {
if (!error) {
e.currentTarget.style.borderColor = "var(--color-gold-border-focus)";
e.currentTarget.style.boxShadow = "0 0 0 2px rgba(212, 168, 67, 0.15)";
}
}}
onBlur={(e) => {
if (!error) {
e.currentTarget.style.borderColor = "var(--color-gold-border)";
e.currentTarget.style.boxShadow = "none";
}
}}
{...props}
/>
{hint && !error && (
<span
id={hintId}
style={{
display: "block",
fontSize: "0.72rem",
color: "var(--color-text-dim)",
marginTop: "0.3rem",
}}
>
{hint}
</span>
)}
{error && (
<span
id={errorId}
role="alert"
style={{
display: "block",
fontSize: "0.75rem",
color: "var(--color-error)",
marginTop: "0.35rem",
}}
>
{error}
</span>
)}
</div>
);
}
+23
View File
@@ -0,0 +1,23 @@
export function Spinner({ size = 24 }: { size?: number }) {
return (
<div
style={{
display: "inline-block",
width: size,
height: size,
border: "2px solid rgba(212, 168, 67, 0.25)",
borderTopColor: "var(--color-gold)",
borderRadius: "50%",
animation: "spin 0.8s linear infinite",
}}
aria-label="Cargando..."
role="status"
>
<style>{`
@keyframes spin {
to { transform: rotate(360deg); }
}
`}</style>
</div>
);
}
+30
View File
@@ -0,0 +1,30 @@
import { useCallback, useEffect, useState } from "react";
import { fetchConfig } from "../api/client";
import type { InvitationConfig } from "../types/config";
export type ConfigStatus = "loading" | "success" | "error";
export function useConfig() {
const [config, setConfig] = useState<InvitationConfig | null>(null);
const [status, setStatus] = useState<ConfigStatus>("loading");
const [error, setError] = useState<string | null>(null);
const load = useCallback(async () => {
setStatus("loading");
setError(null);
try {
const data = await fetchConfig();
setConfig(data);
setStatus("success");
} catch (err) {
setError(err instanceof Error ? err.message : "Error al cargar la configuración");
setStatus("error");
}
}, []);
useEffect(() => {
load();
}, [load]);
return { config, status, error, reload: load };
}
+127
View File
@@ -0,0 +1,127 @@
import { useEffect, useState } from "react";
export type CountdownState = "counting" | "in_progress" | "finished";
export interface CountdownResult {
days: string;
hours: string;
minutes: string;
seconds: string;
state: CountdownState;
}
/**
* Calculates UTC epoch milliseconds for a local datetime in a specified IANA timezone.
*/
function getTargetUtcMillis(dateStr: string, timeStr: string, timeZone: string): number {
try {
const [year, month, day] = dateStr.split("-").map(Number);
const [hours, minutes] = timeStr.split(":").map(Number);
// Initial guess as UTC
const utcGuess = new Date(Date.UTC(year, month - 1, day, hours, minutes, 0));
const dtf = new Intl.DateTimeFormat("en-US", {
timeZone,
year: "numeric",
month: "numeric",
day: "numeric",
hour: "numeric",
minute: "numeric",
second: "numeric",
hour12: false,
});
const parts = dtf.formatToParts(utcGuess);
const p: Record<string, number> = {};
for (const part of parts) {
if (part.type !== "literal") {
p[part.type] = Number(part.value);
}
}
const asLocalInTz = Date.UTC(
p.year,
p.month - 1,
p.day,
p.hour === 24 ? 0 : p.hour,
p.minute,
p.second,
);
const offset = asLocalInTz - utcGuess.getTime();
return utcGuess.getTime() - offset;
} catch {
// Fallback if timezone is unparseable
return new Date(`${dateStr}T${timeStr}:00`).getTime();
}
}
export function useCountdown(
eventDate: string,
eventTime: string,
eventTimezone: string,
): CountdownResult {
const [result, setResult] = useState<CountdownResult>({
days: "00",
hours: "00",
minutes: "00",
seconds: "00",
state: "counting",
});
useEffect(() => {
if (!eventDate || !eventTime) return;
const targetTime = getTargetUtcMillis(
eventDate,
eventTime,
eventTimezone || "America/Bogota",
);
// Typical party duration window: 6 hours
const eventDurationMs = 6 * 60 * 60 * 1000;
function update() {
const now = Date.now();
const diff = targetTime - now;
if (diff > 0) {
const totalSeconds = Math.floor(diff / 1000);
const days = Math.floor(totalSeconds / (3600 * 24));
const hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
const minutes = Math.floor((totalSeconds % 3600) / 60);
const seconds = totalSeconds % 60;
setResult({
days: String(days).padStart(2, "0"),
hours: String(hours).padStart(2, "0"),
minutes: String(minutes).padStart(2, "0"),
seconds: String(seconds).padStart(2, "0"),
state: "counting",
});
} else if (Math.abs(diff) < eventDurationMs) {
setResult({
days: "00",
hours: "00",
minutes: "00",
seconds: "00",
state: "in_progress",
});
} else {
setResult({
days: "00",
hours: "00",
minutes: "00",
seconds: "00",
state: "finished",
});
}
}
update();
const interval = setInterval(update, 1000);
return () => clearInterval(interval);
}, [eventDate, eventTime, eventTimezone]);
return result;
}
+127
View File
@@ -0,0 +1,127 @@
import { useEffect, useState } from "react";
import { submitRsvp } from "../api/client";
const SESSION_STORAGE_KEY = "bdinvite:rsvp-submitted";
export type RsvpFormState = "idle" | "submitting" | "success" | "duplicate" | "error";
export interface FormErrors {
name?: string;
phone?: string;
email?: string;
}
export function useRsvpForm() {
const [name, setName] = useState("");
const [phone, setPhone] = useState("");
const [email, setEmail] = useState("");
const [confirmedName, setConfirmedName] = useState("");
const [formState, setFormState] = useState<RsvpFormState>("idle");
const [errors, setErrors] = useState<FormErrors>({});
// Check sessionStorage on mount for existing submission in this session
useEffect(() => {
try {
const stored = sessionStorage.getItem(SESSION_STORAGE_KEY);
if (stored) {
const parsed = JSON.parse(stored);
if (parsed?.name) {
setConfirmedName(parsed.name);
setFormState("success");
}
}
} catch {
// Ignore sessionStorage read errors
}
}, []);
function validate(): boolean {
const newErrors: FormErrors = {};
const cleanName = name.trim();
if (!cleanName) {
newErrors.name = "Por favor, ingresa tu nombre completo.";
}
// Colombian mobile format: 10 digits starting with 3, optionally +57
const digits = phone.replace(/\D/g, "");
let normalized = digits;
if (normalized.startsWith("57") && normalized.length === 12) {
normalized = normalized.slice(2);
}
if (normalized.length !== 10 || !normalized.startsWith("3")) {
newErrors.phone =
"Ingresa un número móvil válido de 10 dígitos (ej: 300 123 4567).";
}
if (email?.trim()) {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email.trim())) {
newErrors.email = "Ingresa un correo electrónico válido.";
}
}
setErrors(newErrors);
return Object.keys(newErrors).length === 0;
}
async function submit() {
if (!validate()) return;
setFormState("submitting");
// Clean phone
let digits = phone.replace(/\D/g, "");
if (digits.startsWith("57") && digits.length === 12) {
digits = digits.slice(2);
}
const payload = {
name: name.trim(),
phone: digits,
email: email.trim() || null,
};
const result = await submitRsvp(payload);
if (result.result === "SUCCESS") {
setConfirmedName(result.name);
setFormState("success");
try {
sessionStorage.setItem(
SESSION_STORAGE_KEY,
JSON.stringify({ name: result.name, timestamp: Date.now() }),
);
} catch {
// Ignore storage write issues
}
} else if (result.result === "DUPLICATE") {
setFormState("duplicate");
} else if (result.result === "VALIDATION_ERROR") {
setFormState("idle");
setErrors(result.errors);
} else {
setFormState("error");
}
}
function retry() {
setFormState("idle");
}
return {
name,
setName,
phone,
setPhone,
email,
setEmail,
confirmedName,
formState,
errors,
submit,
retry,
};
}
+155
View File
@@ -0,0 +1,155 @@
import type { CountdownState } from "../hooks/useCountdown";
interface CountdownProps {
days: string;
hours: string;
minutes: string;
seconds: string;
state: CountdownState;
label?: string;
inProgressLabel?: string;
finishedLabel?: string;
}
export function Countdown({
days,
hours,
minutes,
seconds,
state,
label = "NOS VEMOS EN",
inProgressLabel = "EVENTO EN CURSO",
finishedLabel = "EVENTO FINALIZADO",
}: CountdownProps) {
if (state === "in_progress") {
return (
<div style={{ textAlign: "center", margin: "1.8rem 0" }}>
<p
style={{
fontSize: "1.1rem",
fontWeight: 600,
letterSpacing: "0.2em",
color: "var(--color-gold-light)",
textTransform: "uppercase",
}}
>
{inProgressLabel}
</p>
</div>
);
}
if (state === "finished") {
return (
<div style={{ textAlign: "center", margin: "1.8rem 0" }}>
<p
style={{
fontSize: "0.95rem",
fontWeight: 500,
letterSpacing: "0.18em",
color: "var(--color-text-dim)",
textTransform: "uppercase",
}}
>
{finishedLabel}
</p>
</div>
);
}
return (
<div style={{ textAlign: "center", margin: "1.8rem 0" }}>
<p
style={{
fontSize: "0.78rem",
fontWeight: 600,
letterSpacing: "0.25em",
color: "var(--color-gold-light)",
textTransform: "uppercase",
marginBottom: "0.75rem",
}}
>
{label}
</p>
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
gap: "0.6rem",
fontSize: "1.8rem",
fontWeight: 300,
letterSpacing: "0.08em",
fontVariantNumeric: "tabular-nums",
color: "var(--color-text)",
}}
>
<div style={{ textAlign: "center" }}>
<span>{days}</span>
<span
style={{
display: "block",
fontSize: "0.58rem",
letterSpacing: "0.15em",
color: "var(--color-text-dim)",
marginTop: "0.2rem",
}}
>
DÍAS
</span>
</div>
<span style={{ color: "var(--color-gold)", opacity: 0.7, marginTop: "-0.8rem" }}>
:
</span>
<div style={{ textAlign: "center" }}>
<span>{hours}</span>
<span
style={{
display: "block",
fontSize: "0.58rem",
letterSpacing: "0.15em",
color: "var(--color-text-dim)",
marginTop: "0.2rem",
}}
>
HORAS
</span>
</div>
<span style={{ color: "var(--color-gold)", opacity: 0.7, marginTop: "-0.8rem" }}>
:
</span>
<div style={{ textAlign: "center" }}>
<span>{minutes}</span>
<span
style={{
display: "block",
fontSize: "0.58rem",
letterSpacing: "0.15em",
color: "var(--color-text-dim)",
marginTop: "0.2rem",
}}
>
MIN
</span>
</div>
<span style={{ color: "var(--color-gold)", opacity: 0.7, marginTop: "-0.8rem" }}>
:
</span>
<div style={{ textAlign: "center" }}>
<span>{seconds}</span>
<span
style={{
display: "block",
fontSize: "0.58rem",
letterSpacing: "0.15em",
color: "var(--color-text-dim)",
marginTop: "0.2rem",
}}
>
SEG
</span>
</div>
</div>
</div>
);
}
+157
View File
@@ -0,0 +1,157 @@
import { useRef } from "react";
import { Button } from "../components/Button";
import { Spinner } from "../components/Spinner";
import { useConfig } from "../hooks/useConfig";
import { useRsvpForm } from "../hooks/useRsvpForm";
import { InvitationHero } from "./InvitationHero";
import { ParticleBackground } from "./ParticleBackground";
import { RsvpForm } from "./RsvpForm";
import { RsvpResult } from "./RsvpResult";
export function Invitation() {
const { config, status, error, reload } = useConfig();
const rsvpForm = useRsvpForm();
const rsvpSectionRef = useRef<HTMLDivElement | null>(null);
function scrollToRsvp() {
if (rsvpSectionRef.current) {
rsvpSectionRef.current.scrollIntoView({ behavior: "smooth" });
}
}
// 1. Loading Configuration State
if (status === "loading") {
return (
<main
style={{
minHeight: "100vh",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
gap: "1.2rem",
backgroundColor: "var(--color-bg)",
}}
>
<Spinner size={36} />
<p
style={{
fontSize: "0.82rem",
letterSpacing: "0.2em",
color: "var(--color-text-muted)",
textTransform: "uppercase",
}}
>
Cargando invitación...
</p>
</main>
);
}
// 2. Configuration Error State
if (status === "error" || !config) {
return (
<main
style={{
minHeight: "100vh",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
padding: "2rem",
textAlign: "center",
backgroundColor: "var(--color-bg)",
}}
>
<h2
style={{
fontSize: "1.3rem",
fontWeight: 600,
letterSpacing: "0.15em",
color: "var(--color-gold-light)",
textTransform: "uppercase",
marginBottom: "1rem",
}}
>
No pudimos cargar la invitación
</h2>
<p
style={{
fontSize: "0.92rem",
color: "var(--color-text-muted)",
marginBottom: "2rem",
maxWidth: "360px",
lineHeight: 1.6,
}}
>
{error || "Por favor, verifica tu conexión e inténtalo nuevamente."}
</p>
<Button variant="primary" onClick={reload}>
REINTENTAR
</Button>
</main>
);
}
// 3. Loaded Invitation Page Flow
return (
<div style={{ position: "relative", minHeight: "100vh" }}>
{/* Background ambient particle canvas */}
<ParticleBackground />
<main
style={{
position: "relative",
zIndex: 1,
width: "100%",
maxWidth: "480px",
margin: "0 auto",
boxShadow: "0 0 50px rgba(0, 0, 0, 0.8)",
backgroundColor: "rgba(10, 10, 10, 0.85)",
backdropFilter: "blur(2px)",
}}
>
{/* Section 1: Invitation Hero */}
<InvitationHero config={config} onCtaClick={scrollToRsvp} />
{/* Section 2: RSVP / Confirmation Flow */}
<div
id="rsvp-section"
ref={rsvpSectionRef}
style={{
minHeight: "80vh",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
padding: "2.5rem 1.8rem 4rem 1.8rem",
borderTop: "1px solid var(--color-gold-border)",
position: "relative",
}}
>
{rsvpForm.formState === "idle" || rsvpForm.formState === "submitting" ? (
<RsvpForm
config={config}
name={rsvpForm.name}
setName={rsvpForm.setName}
phone={rsvpForm.phone}
setPhone={rsvpForm.setPhone}
email={rsvpForm.email}
setEmail={rsvpForm.setEmail}
formState={rsvpForm.formState}
errors={rsvpForm.errors}
onSubmit={rsvpForm.submit}
/>
) : (
<RsvpResult
formState={rsvpForm.formState}
confirmedName={rsvpForm.confirmedName}
config={config}
onRetry={rsvpForm.retry}
/>
)}
</div>
</main>
</div>
);
}
+175
View File
@@ -0,0 +1,175 @@
import type { InvitationConfig } from "../types/config";
import { RsvpCta } from "./RsvpCta";
interface InvitationHeroProps {
config: InvitationConfig;
onCtaClick: () => void;
}
export function InvitationHero({ config, onCtaClick }: InvitationHeroProps) {
// Parse date into Month, Day, and Day of Week
const [year, monthNum, dayNum] = config.event_date.split("-").map(Number);
const dateObj = new Date(year, (monthNum || 1) - 1, dayNum || 1);
const monthsEs = [
"ENE",
"FEB",
"MAR",
"ABR",
"MAY",
"JUN",
"JUL",
"AGO",
"SEP",
"OCT",
"NOV",
"DIC",
];
const daysEs = [
"DOMINGO",
"LUNES",
"MARTES",
"MIÉRCOLES",
"JUEVES",
"VIERNES",
"SÁBADO",
];
const monthStr = monthsEs[(monthNum || 1) - 1] || "OCT";
const dayNameStr = daysEs[dateObj.getDay()] || "VIERNES";
const dayStr = String(dayNum || 28);
// Format 24h time to 12h AM/PM if applicable
const [hStr, mStr] = config.event_time.split(":");
let formattedTime = config.event_time;
if (hStr) {
const h = parseInt(hStr, 10);
const m = mStr || "00";
const ampm = h >= 12 ? "PM" : "AM";
const h12 = h % 12 || 12;
formattedTime = `${h12}:${m} ${ampm}`;
}
return (
<section
style={{
width: "100%",
maxWidth: "480px",
minHeight: "100vh",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "space-between",
padding: "3.5rem 1.8rem 2.5rem 1.8rem",
textAlign: "center",
margin: "0 auto",
position: "relative",
zIndex: 1,
}}
>
{/* 1. Header: Script Birthday Party */}
<div style={{ marginTop: "1rem" }}>
<h1
style={{
fontFamily: "var(--font-display)",
fontSize: "clamp(3.2rem, 12vw, 4.4rem)",
fontWeight: 400,
lineHeight: 1.15,
color: "var(--color-text)",
textShadow: "0 2px 20px rgba(212, 168, 67, 0.35)",
}}
>
{config.title || "Birthday Party"}
</h1>
</div>
{/* 2. Invitation wording & Honoree name */}
<div style={{ margin: "2rem 0" }}>
<p
style={{
fontSize: "0.78rem",
fontWeight: 400,
letterSpacing: "0.24em",
textTransform: "uppercase",
color: "var(--color-text-muted)",
lineHeight: 1.8,
maxWidth: "320px",
margin: "0 auto",
}}
>
{config.invitation_text}
</p>
<h2
style={{
fontFamily: "var(--font-display)",
fontSize: "clamp(2.6rem, 10vw, 3.6rem)",
fontWeight: 400,
color: "var(--color-gold-light)",
marginTop: "1.4rem",
textShadow: "0 2px 18px rgba(212, 168, 67, 0.4)",
}}
>
{config.honoree_name}
</h2>
</div>
{/* 3. Event metadata date block */}
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
gap: "1.2rem",
margin: "1.5rem 0",
fontSize: "0.88rem",
letterSpacing: "0.18em",
color: "var(--color-text)",
textTransform: "uppercase",
}}
>
<span style={{ fontWeight: 500, minWidth: "75px" }}>{dayNameStr}</span>
{/* Divider & Day Box */}
<div
style={{
borderLeft: "1px solid rgba(255, 255, 255, 0.25)",
borderRight: "1px solid rgba(255, 255, 255, 0.25)",
padding: "0 1.2rem",
textAlign: "center",
}}
>
<span
style={{
display: "block",
fontSize: "0.68rem",
letterSpacing: "0.2em",
color: "var(--color-text-muted)",
marginBottom: "0.15rem",
}}
>
{monthStr}
</span>
<span
style={{
display: "block",
fontSize: "1.7rem",
fontWeight: 700,
lineHeight: 1,
letterSpacing: "0.05em",
}}
>
{dayStr}
</span>
</div>
<span style={{ fontWeight: 500, minWidth: "75px" }}>{formattedTime}</span>
</div>
{/* 4. RSVP Call to action */}
<div style={{ marginBottom: "1rem" }}>
<RsvpCta label={config.rsvp_cta} onClick={onCtaClick} />
</div>
</section>
);
}
+123
View File
@@ -0,0 +1,123 @@
import { useState } from "react";
interface MapPreviewProps {
previewUrl: string;
mapUrl: string;
venueName: string;
}
export function MapPreview({ previewUrl, mapUrl, venueName }: MapPreviewProps) {
const [imgError, setImgError] = useState(false);
const [isHovered, setIsHovered] = useState(false);
return (
<div style={{ textAlign: "center", margin: "1.6rem 0" }}>
<a
href={mapUrl}
target="_blank"
rel="noopener noreferrer"
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
onFocus={() => setIsHovered(true)}
onBlur={() => setIsHovered(false)}
style={{
display: "inline-block",
textDecoration: "none",
color: "inherit",
outline: "none",
}}
aria-label={`Ver ubicación de ${venueName} en Google Maps`}
>
<div
style={{
width: "140px",
height: "140px",
margin: "0 auto",
borderRadius: "50%",
overflow: "hidden",
border: `1.5px solid ${isHovered ? "var(--color-gold-border-focus)" : "var(--color-gold-border)"}`,
boxShadow: isHovered
? "0 6px 24px rgba(0, 0, 0, 0.7), 0 0 20px rgba(212, 168, 67, 0.3)"
: "0 4px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(212, 168, 67, 0.15)",
transform: isHovered ? "scale(1.06)" : "scale(1)",
transition:
"transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease",
position: "relative",
backgroundColor: "#1a1a1a",
}}
>
{!imgError && previewUrl ? (
<img
src={previewUrl}
alt={`Mapa de ${venueName}`}
onError={() => setImgError(true)}
style={{
width: "100%",
height: "100%",
objectFit: "cover",
display: "block",
filter: "contrast(1.1) brightness(0.9)",
}}
/>
) : (
<div
style={{
width: "100%",
height: "100%",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
color: "var(--color-gold)",
backgroundColor: "#151515",
padding: "0.5rem",
}}
>
<svg
width="28"
height="28"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
role="img"
aria-label="Icono de mapa"
>
<title>Icono de mapa</title>
<path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z" />
<circle cx="12" cy="10" r="3" />
</svg>
<span
style={{
fontSize: "0.65rem",
letterSpacing: "0.1em",
marginTop: "0.3rem",
color: "var(--color-text-muted)",
}}
>
MAPA
</span>
</div>
)}
</div>
<span
style={{
display: "inline-block",
fontSize: "0.74rem",
fontWeight: 600,
letterSpacing: "0.22em",
color: "var(--color-gold-light)",
textTransform: "uppercase",
marginTop: "0.9rem",
transition: "color 0.2s ease",
}}
>
VER UBICACIÓN ↗
</span>
</a>
</div>
);
}
@@ -0,0 +1,166 @@
import { useEffect, useRef } from "react";
interface Particle {
x: number;
y: number;
radius: number;
baseOpacity: number;
blur: number;
goldR: number;
goldG: number;
goldB: number;
vx: number;
vy: number;
twinkleSpeed: number;
twinklePhase: number;
}
export function ParticleBackground() {
const canvasRef = useRef<HTMLCanvasElement | null>(null);
useEffect(() => {
const canvas = canvasRef.current;
if (!canvas) return;
const ctx = canvas.getContext("2d");
if (!ctx) return;
let animationFrameId: number;
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let width = canvas.width;
let height = canvas.height;
const prefersReducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)",
).matches;
const particleCount = width > 768 ? 120 : 80;
const particles: Particle[] = [];
function createParticle(): Particle {
const bias = Math.random();
let x = 0;
let y = 0;
if (bias < 0.4) {
// Upper-left quadrant
x = Math.random() * width * 0.55;
y = Math.random() * height * 0.45;
} else if (bias < 0.8) {
// Lower-right quadrant
x = width * 0.45 + Math.random() * width * 0.55;
y = height * 0.55 + Math.random() * height * 0.45;
} else {
// Sparse center
x = Math.random() * width;
y = Math.random() * height;
}
// Golden hues: amber, champagne, warm gold
const goldPalette = [
{ r: 212, g: 168, b: 67 }, // Classic gold #d4a843
{ r: 240, g: 214, b: 138 }, // Light gold #f0d68a
{ r: 255, g: 223, b: 140 }, // Bright champagne
{ r: 180, g: 140, b: 50 }, // Deep amber
];
const color = goldPalette[Math.floor(Math.random() * goldPalette.length)];
return {
x,
y,
radius: 1.5 + Math.random() * 5.5,
baseOpacity: 0.15 + Math.random() * 0.55,
blur: 2 + Math.random() * 8,
goldR: color.r,
goldG: color.g,
goldB: color.b,
vx: (Math.random() - 0.5) * 0.25,
vy: (Math.random() - 0.5) * 0.25,
twinkleSpeed: 0.006 + Math.random() * 0.018,
twinklePhase: Math.random() * Math.PI * 2,
};
}
for (let i = 0; i < particleCount; i++) {
particles.push(createParticle());
}
function renderFrame() {
if (!ctx) return;
ctx.clearRect(0, 0, width, height);
for (const p of particles) {
p.twinklePhase += p.twinkleSpeed;
const currentOpacity = Math.max(
0.05,
p.baseOpacity + Math.sin(p.twinklePhase) * 0.25,
);
ctx.save();
ctx.beginPath();
ctx.arc(p.x, p.y, p.radius, 0, Math.PI * 2);
// Soft bokeh glow
ctx.shadowBlur = p.blur;
ctx.shadowColor = `rgba(${p.goldR}, ${p.goldG}, ${p.goldB}, ${currentOpacity})`;
ctx.fillStyle = `rgba(${p.goldR}, ${p.goldG}, ${p.goldB}, ${currentOpacity})`;
ctx.fill();
ctx.restore();
if (!prefersReducedMotion) {
p.x += p.vx;
p.y += p.vy;
// Wrap edges
if (p.x < -10) p.x = width + 10;
if (p.x > width + 10) p.x = -10;
if (p.y < -10) p.y = height + 10;
if (p.y > height + 10) p.y = -10;
}
}
if (!prefersReducedMotion) {
animationFrameId = requestAnimationFrame(renderFrame);
}
}
// Initial render
renderFrame();
function handleResize() {
if (!canvas) return;
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
width = canvas.width;
height = canvas.height;
if (prefersReducedMotion) {
renderFrame();
}
}
window.addEventListener("resize", handleResize);
return () => {
window.removeEventListener("resize", handleResize);
if (animationFrameId) {
cancelAnimationFrame(animationFrameId);
}
};
}, []);
return (
<canvas
ref={canvasRef}
style={{
position: "fixed",
top: 0,
left: 0,
width: "100%",
height: "100%",
pointerEvents: "none",
zIndex: 0,
}}
/>
);
}
+66
View File
@@ -0,0 +1,66 @@
interface RsvpCtaProps {
label: string;
onClick: () => void;
}
export function RsvpCta({ label, onClick }: RsvpCtaProps) {
return (
<button
type="button"
onClick={onClick}
style={{
display: "inline-flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
background: "none",
border: "none",
color: "var(--color-gold-light)",
cursor: "pointer",
padding: "0.8rem 1.4rem",
borderRadius: "8px",
outline: "none",
transition: "all 0.25s ease",
}}
onFocus={(e) => {
e.currentTarget.style.boxShadow = "0 0 0 2px var(--color-gold-border-focus)";
}}
onBlur={(e) => {
e.currentTarget.style.boxShadow = "none";
}}
aria-label={`${label} — Desplazarse al formulario de confirmación`}
>
<span
style={{
fontSize: "0.75rem",
fontWeight: 600,
letterSpacing: "0.26em",
textTransform: "uppercase",
marginBottom: "0.5rem",
transition: "letter-spacing 0.2s ease, color 0.2s ease",
}}
>
{label}
</span>
<span
style={{
fontSize: "1.2rem",
lineHeight: 1,
animation: "bounceSoft 2s infinite ease-in-out",
}}
aria-hidden="true"
>
↓
</span>
<style>{`
@keyframes bounceSoft {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(5px); }
}
@media (prefers-reduced-motion: reduce) {
span { animation: none !important; }
}
`}</style>
</button>
);
}
+113
View File
@@ -0,0 +1,113 @@
import type { FormEvent } from "react";
import { Button } from "../components/Button";
import { Field } from "../components/Field";
import { Spinner } from "../components/Spinner";
import type { FormErrors, RsvpFormState } from "../hooks/useRsvpForm";
import type { InvitationConfig } from "../types/config";
interface RsvpFormProps {
config: InvitationConfig;
name: string;
setName: (v: string) => void;
phone: string;
setPhone: (v: string) => void;
email: string;
setEmail: (v: string) => void;
formState: RsvpFormState;
errors: FormErrors;
onSubmit: () => void;
}
export function RsvpForm({
config,
name,
setName,
phone,
setPhone,
email,
setEmail,
formState,
errors,
onSubmit,
}: RsvpFormProps) {
const isSubmitting = formState === "submitting";
function handleSubmit(e: FormEvent) {
e.preventDefault();
if (!isSubmitting) {
onSubmit();
}
}
return (
<form
onSubmit={handleSubmit}
style={{
width: "100%",
maxWidth: "400px",
margin: "0 auto",
padding: "1.5rem 0",
}}
noValidate
>
<h3
style={{
fontFamily: "var(--font-display)",
fontSize: "2.8rem",
fontWeight: 400,
color: "var(--color-gold-light)",
textAlign: "center",
marginBottom: "2rem",
textShadow: "0 2px 14px rgba(212, 168, 67, 0.3)",
}}
>
{config.rsvp_heading || "¿Nos vemos?"}
</h3>
<Field
label="Nombre Completo"
placeholder="Tu nombre y apellido"
value={name}
onChange={(e) => setName(e.target.value)}
disabled={isSubmitting}
error={errors.name}
required
/>
<Field
label="Teléfono (Móvil)"
placeholder="300 123 4567"
type="tel"
value={phone}
onChange={(e) => setPhone(e.target.value)}
disabled={isSubmitting}
hint="Número colombiano de 10 dígitos (ej: 300 123 4567)"
error={errors.phone}
required
/>
<Field
label="Correo Electrónico (Opcional)"
placeholder="ejemplo@correo.com"
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
disabled={isSubmitting}
error={errors.email}
/>
<div style={{ marginTop: "2rem", textAlign: "center" }}>
<Button type="submit" variant="primary" fullWidth disabled={isSubmitting}>
{isSubmitting ? (
<span style={{ display: "inline-flex", alignItems: "center", gap: "0.6rem" }}>
<Spinner size={16} />
<span>ENVIANDO...</span>
</span>
) : (
config.submit_label || "TE VEO AHÍ"
)}
</Button>
</div>
</form>
);
}
+228
View File
@@ -0,0 +1,228 @@
import { Button } from "../components/Button";
import { useCountdown } from "../hooks/useCountdown";
import type { RsvpFormState } from "../hooks/useRsvpForm";
import type { InvitationConfig } from "../types/config";
import { Countdown } from "./Countdown";
import { MapPreview } from "./MapPreview";
import { VenueInfo } from "./VenueInfo";
interface RsvpResultProps {
formState: RsvpFormState;
confirmedName: string;
config: InvitationConfig;
onRetry: () => void;
}
export function RsvpResult({
formState,
confirmedName,
config,
onRetry,
}: RsvpResultProps) {
const countdown = useCountdown(
config.event_date,
config.event_time,
config.event_timezone,
);
if (formState === "duplicate") {
return (
<div
style={{
width: "100%",
maxWidth: "420px",
margin: "0 auto",
padding: "2.5rem 1.5rem",
textAlign: "center",
}}
role="alert"
>
<h3
style={{
fontFamily: "var(--font-display)",
fontSize: "3.2rem",
fontWeight: 400,
color: "var(--color-gold-light)",
marginBottom: "1rem",
textShadow: "0 2px 14px rgba(212, 168, 67, 0.3)",
}}
>
¡Ups!
</h3>
<p
style={{
fontSize: "0.92rem",
lineHeight: 1.7,
color: "var(--color-text-muted)",
marginBottom: "2rem",
}}
>
{config.msg_duplicate ||
"Parece que ya tenemos tus datos registrados. Si necesitas modificar tu información, ponte en contacto con nosotros."}
</p>
<Button variant="outline" onClick={onRetry}>
VOLVER AL FORMULARIO
</Button>
</div>
);
}
if (formState === "error") {
return (
<div
style={{
width: "100%",
maxWidth: "420px",
margin: "0 auto",
padding: "2.5rem 1.5rem",
textAlign: "center",
}}
role="alert"
>
<h3
style={{
fontSize: "1.2rem",
fontWeight: 600,
letterSpacing: "0.15em",
color: "var(--color-error)",
marginBottom: "1rem",
textTransform: "uppercase",
}}
>
Algo salió mal
</h3>
<p
style={{
fontSize: "0.92rem",
lineHeight: 1.7,
color: "var(--color-text-muted)",
marginBottom: "2rem",
}}
>
{config.msg_error ||
"No pudimos registrar tu asistencia. Inténtalo nuevamente."}
</p>
<Button variant="primary" onClick={onRetry}>
INTENTAR DE NUEVO
</Button>
</div>
);
}
// Success Confirmation State
const greeting = (config.msg_success_greeting || "Gracias, {name}.").replace(
"{name}",
confirmedName || "",
);
return (
<div
style={{
width: "100%",
maxWidth: "440px",
margin: "0 auto",
padding: "2.5rem 1.5rem 4rem 1.5rem",
textAlign: "center",
}}
aria-live="polite"
>
<h3
style={{
fontFamily: "var(--font-display)",
fontSize: "clamp(3.2rem, 10vw, 4rem)",
fontWeight: 400,
color: "var(--color-gold-light)",
lineHeight: 1.15,
marginBottom: "0.8rem",
textShadow: "0 2px 20px rgba(212, 168, 67, 0.4)",
}}
>
¡Perfecto!
</h3>
<p
style={{
fontSize: "0.92rem",
fontWeight: 400,
letterSpacing: "0.12em",
color: "var(--color-text)",
lineHeight: 1.6,
marginBottom: "0.4rem",
}}
>
{config.msg_success || "Tu asistencia ha sido confirmada."}
</p>
{confirmedName && (
<p
style={{
fontSize: "1.05rem",
fontWeight: 600,
letterSpacing: "0.08em",
color: "var(--color-gold-light)",
marginBottom: "2rem",
}}
>
{greeting}
</p>
)}
{/* Decorative divider dot */}
<div
style={{
display: "flex",
justifyContent: "center",
gap: "0.4rem",
margin: "1.5rem 0",
color: "var(--color-gold)",
opacity: 0.5,
fontSize: "1.2rem",
}}
aria-hidden="true"
>
<span>·</span>
<span>·</span>
<span>·</span>
</div>
{/* Live Countdown */}
<Countdown
days={countdown.days}
hours={countdown.hours}
minutes={countdown.minutes}
seconds={countdown.seconds}
state={countdown.state}
label={config.countdown_label}
inProgressLabel={config.countdown_in_progress}
finishedLabel={config.countdown_finished}
/>
{/* Decorative divider dot */}
<div
style={{
display: "flex",
justifyContent: "center",
gap: "0.4rem",
margin: "1.5rem 0",
color: "var(--color-gold)",
opacity: 0.5,
fontSize: "1.2rem",
}}
aria-hidden="true"
>
<span>·</span>
<span>·</span>
<span>·</span>
</div>
{/* Circular Map Preview and Venue Logistics */}
<MapPreview
previewUrl={config.map_preview_url}
mapUrl={config.map_url}
venueName={config.address_name}
/>
<VenueInfo venueName={config.address_name} addressLines={config.address_lines} />
</div>
);
}
+41
View File
@@ -0,0 +1,41 @@
interface VenueInfoProps {
venueName: string;
addressLines: string;
}
export function VenueInfo({ venueName, addressLines }: VenueInfoProps) {
const lines = addressLines
? addressLines.split("\n").filter((line) => line.trim().length > 0)
: [];
return (
<div style={{ textAlign: "center", margin: "1rem 0" }}>
<h3
style={{
fontSize: "0.95rem",
fontWeight: 600,
letterSpacing: "0.18em",
textTransform: "uppercase",
color: "var(--color-text)",
marginBottom: "0.4rem",
}}
>
{venueName}
</h3>
{lines.map((line) => (
<p
key={line}
style={{
fontSize: "0.82rem",
color: "var(--color-text-muted)",
letterSpacing: "0.12em",
textTransform: "uppercase",
lineHeight: 1.5,
}}
>
{line}
</p>
))}
</div>
);
}
+13
View File
@@ -0,0 +1,13 @@
import React from "react";
import ReactDOM from "react-dom/client";
import { App } from "./App";
import "./styles/global.css";
const rootElement = document.getElementById("root");
if (rootElement) {
ReactDOM.createRoot(rootElement).render(
<React.StrictMode>
<App />
</React.StrictMode>,
);
}
+77
View File
@@ -0,0 +1,77 @@
/* Self-hosted fonts */
@font-face {
font-family: "InviteDisplay";
src: url("/birthday/fonts/display.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Montserrat";
src: url("/birthday/fonts/montserrat/montserrat-latin.woff2") format("woff2");
font-weight: 300 700;
font-style: normal;
font-display: swap;
}
:root {
--color-bg: #0a0a0a;
--color-card-bg: #121212;
--color-gold: #d4a843;
--color-gold-light: #f0d68a;
--color-gold-dark: #8b7332;
--color-gold-border: rgba(212, 168, 67, 0.25);
--color-gold-border-focus: rgba(212, 168, 67, 0.65);
--color-text: #ffffff;
--color-text-muted: rgba(255, 255, 255, 0.72);
--color-text-dim: rgba(255, 255, 255, 0.45);
--color-error: #e74c3c;
--color-error-bg: rgba(231, 76, 60, 0.12);
--font-display: "InviteDisplay", cursive, "Great Vibes", serif;
--font-body: "Montserrat", -apple-system, BlinkMacSystemFont, sans-serif;
--max-content-width: 480px;
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
font-family: var(--font-body);
background-color: var(--color-bg);
color: var(--color-text);
scroll-behavior: smooth;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
@media (prefers-reduced-motion: reduce) {
html {
scroll-behavior: auto;
}
}
body {
min-height: 100vh;
background-color: var(--color-bg);
color: var(--color-text);
overflow-x: hidden;
position: relative;
}
button {
font-family: inherit;
cursor: pointer;
}
input,
textarea {
font-family: inherit;
}
+50
View File
@@ -0,0 +1,50 @@
export interface InvitationConfig {
id: number;
title: string;
invitation_text: string;
honoree_name: string;
event_date: string; // "YYYY-MM-DD"
event_time: string; // "HH:MM"
event_timezone: string; // "America/Bogota"
address_name: string;
address_lines: string;
map_preview_url: string;
map_url: string;
rsvp_heading: string;
rsvp_cta: string;
submit_label: string;
msg_success: string;
msg_success_greeting: string;
msg_duplicate: string;
msg_error: string;
msg_config_error: string;
countdown_label: string;
countdown_in_progress: string;
countdown_finished: string;
updated_at?: string;
}
export interface RSVPRequest {
name: string;
phone: string;
email?: string | null;
}
export type RSVPApiResult =
| { result: "SUCCESS"; name: string }
| { result: "DUPLICATE" }
| { result: "VALIDATION_ERROR"; errors: Record<string, string> }
| { result: "ERROR" };
export interface RSVPAdminItem {
id: number;
name: string;
phone: string;
email: string | null;
created_at: string;
}
export interface RSVPListResponse {
count: number;
rsvps: RSVPAdminItem[];
}
+1
View File
@@ -0,0 +1 @@
/// <reference types="vite/client" />
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": false,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}
+17
View File
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": false,
"isolatedModules": true,
"noEmit": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["vite.config.ts"]
}
+19
View File
@@ -0,0 +1,19 @@
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [react()],
base: "/birthday/",
build: {
outDir: "dist",
assetsDir: "assets",
},
server: {
proxy: {
"/birthday/api": {
target: "http://localhost:8000",
changeOrigin: true,
},
},
},
});