Files
bdinvite/frontend/src/hooks/useConfig.ts
T
kiskaadee d4ae37fef8 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
2026-09-30 23:38:18 -05:00

31 lines
888 B
TypeScript

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 };
}