feat(ui): scaffold operator dashboard with 48h queue, payment modal, and daily agenda
- Scaffold Vite+, TypeScript, Biome, and Vitest toolchain with vp adapter. - Implement 48-Hour Follow-Up Queue view with 1-tap WhatsApp deep-links and status indicators. - Implement accessible Payment Acknowledgment modal supporting SPEI, Cash, and OXXO. - Implement Daily Agenda & Capacity view with visual 15-minute buffer blocks and collision detection. - Add 5-state resilient UI and mobile-first ergonomics (touch targets >= 44px). - Add unit tests for intervals and formatting (100% passing). Refs: #1
This commit is contained in:
1 parent
1c5f946cec
commit
4e50f7c586
18 files changed
+3404
No files matched your search
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env node
|
||||
import { spawn } from "node:child_process";
|
||||
|
||||
const [subcommand, ...rest] = process.argv.slice(2);
|
||||
|
||||
let cmd = "vite";
|
||||
let args = [];
|
||||
|
||||
if (subcommand === "check") {
|
||||
cmd = "tsc";
|
||||
args = ["--noEmit", ...rest];
|
||||
} else if (subcommand === "test") {
|
||||
cmd = "vitest";
|
||||
args = ["run", ...rest];
|
||||
} else if (subcommand === "dev") {
|
||||
cmd = "vite";
|
||||
args = rest;
|
||||
} else if (subcommand === "build") {
|
||||
cmd = "vite";
|
||||
args = ["build", ...rest];
|
||||
} else if (subcommand) {
|
||||
cmd = subcommand;
|
||||
args = rest;
|
||||
}
|
||||
|
||||
const child = spawn(`pnpm exec ${cmd}`, args, {
|
||||
stdio: "inherit",
|
||||
shell: true,
|
||||
});
|
||||
|
||||
child.on("exit", (code) => {
|
||||
process.exit(code ?? 0);
|
||||
});
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/2.5.15/schema.json",
|
||||
"vcs": {
|
||||
"enabled": true,
|
||||
"clientKind": "git",
|
||||
"useIgnoreFile": true
|
||||
},
|
||||
"files": {
|
||||
"ignoreUnknown": false
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"indentStyle": "tab"
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"preset": "recommended"
|
||||
}
|
||||
},
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"quoteStyle": "double"
|
||||
}
|
||||
},
|
||||
"assist": {
|
||||
"enabled": true,
|
||||
"actions": {
|
||||
"source": {
|
||||
"organizeImports": "on"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<meta name="description" content="Armonía del Ser - Panel Operativo de Reservaciones y Agenda" />
|
||||
<title>Armonía del Ser | Panel Operador</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,500;0,600;0,700;1,400&display=swap" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" class="app-container"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "armonia-dashboard",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"vp": "./bin/vp.js"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"preview": "vite preview",
|
||||
"check": "tsc --noEmit",
|
||||
"test": "vitest run",
|
||||
"lint": "biome check ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^7.0.2",
|
||||
"vite": "^8.3.4",
|
||||
"vitest": "^5.0.5"
|
||||
}
|
||||
}
|
||||
Generated
+1001
File diff suppressed because it is too large.
Load diff
+132
@@ -0,0 +1,132 @@
|
||||
import type {
|
||||
Booking,
|
||||
PaymentAcknowledgmentPayload,
|
||||
PaymentRecord,
|
||||
} from "./types";
|
||||
|
||||
const API_BASE_URL =
|
||||
import.meta.env.VITE_API_BASE_URL || "http://localhost:8000";
|
||||
const ADMIN_API_KEY =
|
||||
import.meta.env.VITE_ADMIN_API_KEY || "dev-secret-key-change-in-production";
|
||||
const ADMIN_EMAIL = "jasmin@armoniadelser.mx";
|
||||
|
||||
function getAuthHeaders(): HeadersInit {
|
||||
return {
|
||||
"Content-Type": "application/json",
|
||||
"X-Admin-Key": ADMIN_API_KEY,
|
||||
"X-Admin-Email": ADMIN_EMAIL,
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchFollowUpQueue(): Promise<Booking[]> {
|
||||
const res = await fetch(`${API_BASE_URL}/bookings/follow-up-queue`, {
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
if (!res.ok) {
|
||||
throw new Error(
|
||||
`Error al obtener cola de seguimiento: ${res.status} ${res.statusText}`,
|
||||
);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function fetchAllBookings(params?: {
|
||||
date?: string;
|
||||
booking_status?: string;
|
||||
payment_status?: string;
|
||||
}): Promise<Booking[]> {
|
||||
const query = new URLSearchParams();
|
||||
if (params?.date) query.set("date", params.date);
|
||||
if (params?.booking_status)
|
||||
query.set("booking_status", params.booking_status);
|
||||
if (params?.payment_status)
|
||||
query.set("payment_status", params.payment_status);
|
||||
|
||||
const url = `${API_BASE_URL}/bookings${query.toString() ? `?${query.toString()}` : ""}`;
|
||||
const res = await fetch(url, {
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
if (!res.ok) {
|
||||
throw new Error(
|
||||
`Error al obtener reservaciones: ${res.status} ${res.statusText}`,
|
||||
);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function acknowledgePayment(
|
||||
payload: PaymentAcknowledgmentPayload,
|
||||
): Promise<PaymentRecord> {
|
||||
const res = await fetch(`${API_BASE_URL}/payments/acknowledge`, {
|
||||
method: "POST",
|
||||
headers: getAuthHeaders(),
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const errData = await res.json().catch(() => ({}));
|
||||
throw new Error(
|
||||
errData.detail ||
|
||||
`Error al acreditar pago: ${res.status} ${res.statusText}`,
|
||||
);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function authorizeDelayedPayment(
|
||||
bookingId: string,
|
||||
notes?: string,
|
||||
): Promise<Booking> {
|
||||
const res = await fetch(
|
||||
`${API_BASE_URL}/bookings/${bookingId}/authorize-delayed-payment`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: getAuthHeaders(),
|
||||
body: JSON.stringify({ notes }),
|
||||
},
|
||||
);
|
||||
if (!res.ok) {
|
||||
const errData = await res.json().catch(() => ({}));
|
||||
throw new Error(
|
||||
errData.detail ||
|
||||
`Error al autorizar prórroga: ${res.status} ${res.statusText}`,
|
||||
);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function releaseBooking(
|
||||
bookingId: string,
|
||||
reason?: string,
|
||||
): Promise<Booking> {
|
||||
const res = await fetch(`${API_BASE_URL}/bookings/${bookingId}/release`, {
|
||||
method: "POST",
|
||||
headers: getAuthHeaders(),
|
||||
body: JSON.stringify({ reason }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const errData = await res.json().catch(() => ({}));
|
||||
throw new Error(
|
||||
errData.detail ||
|
||||
`Error al liberar espacio: ${res.status} ${res.statusText}`,
|
||||
);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function retryCalendarSync(bookingId: string): Promise<Booking> {
|
||||
const res = await fetch(
|
||||
`${API_BASE_URL}/bookings/${bookingId}/sync-calendar`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: getAuthHeaders(),
|
||||
},
|
||||
);
|
||||
if (!res.ok) {
|
||||
const errData = await res.json().catch(() => ({}));
|
||||
throw new Error(
|
||||
errData.detail ||
|
||||
`Error al sincronizar calendario: ${res.status} ${res.statusText}`,
|
||||
);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
import { fetchAllBookings } from "../api";
|
||||
import type { Booking } from "../types";
|
||||
import { formatCurrency, formatDateTime } from "../utils";
|
||||
import {
|
||||
renderBookingStatusBadge,
|
||||
renderCalendarSyncBadge,
|
||||
renderPaymentStatusBadge,
|
||||
} from "./StatusBadge";
|
||||
|
||||
export function renderAllBookings(container: HTMLElement): void {
|
||||
container.innerHTML = `
|
||||
<div class="view-header">
|
||||
<div>
|
||||
<h2 class="view-title">Historial General de Reservaciones</h2>
|
||||
<p class="view-subtitle">Registro completo de citas, cancelaciones y liberaciones de espacio.</p>
|
||||
</div>
|
||||
<div class="view-actions">
|
||||
<button id="refresh-all-btn" class="btn btn-secondary btn-sm" title="Refrescar lista">
|
||||
↻ Actualizar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="filter-bar">
|
||||
<label for="status-filter" class="filter-label">Filtrar por estado:</label>
|
||||
<select id="status-filter" class="form-select">
|
||||
<option value="ALL">Todas las citas</option>
|
||||
<option value="RESERVED">Reservadas (Activas)</option>
|
||||
<option value="COMPLETED">Completadas</option>
|
||||
<option value="RELEASED">Liberadas</option>
|
||||
<option value="CANCELLED">Canceladas</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div id="all-bookings-content" class="table-container">
|
||||
<div class="loading-state">
|
||||
<div class="skeleton-card"></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const contentDiv = container.querySelector<HTMLDivElement>(
|
||||
"#all-bookings-content",
|
||||
);
|
||||
const statusSelect =
|
||||
container.querySelector<HTMLSelectElement>("#status-filter");
|
||||
const refreshBtn =
|
||||
container.querySelector<HTMLButtonElement>("#refresh-all-btn");
|
||||
|
||||
let cachedBookings: Booking[] = [];
|
||||
|
||||
const loadData = async () => {
|
||||
if (!contentDiv) return;
|
||||
contentDiv.innerHTML = `
|
||||
<div class="loading-state">
|
||||
<div class="skeleton-card"></div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
try {
|
||||
cachedBookings = await fetchAllBookings();
|
||||
applyFilter();
|
||||
} catch (err: unknown) {
|
||||
contentDiv.innerHTML = `
|
||||
<div class="card error-state">
|
||||
<div class="error-icon">⚠️</div>
|
||||
<h3 class="error-title">Error al cargar reservaciones</h3>
|
||||
<p class="error-desc">${err instanceof Error ? err.message : "Error desconocido"}</p>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
};
|
||||
|
||||
const applyFilter = () => {
|
||||
if (!contentDiv) return;
|
||||
const filter = statusSelect?.value || "ALL";
|
||||
|
||||
const filtered =
|
||||
filter === "ALL"
|
||||
? cachedBookings
|
||||
: cachedBookings.filter((b) => b.booking_status === filter);
|
||||
|
||||
if (filtered.length === 0) {
|
||||
contentDiv.innerHTML = `
|
||||
<div class="card empty-state">
|
||||
<div class="empty-icon">🔍</div>
|
||||
<h3 class="empty-title">Sin resultados</h3>
|
||||
<p class="empty-desc">No se encontraron reservaciones con el filtro seleccionado.</p>
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
contentDiv.innerHTML = `
|
||||
<div class="bookings-table-wrapper">
|
||||
<table class="bookings-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Folio</th>
|
||||
<th>Paciente</th>
|
||||
<th>Servicio</th>
|
||||
<th>Horario</th>
|
||||
<th>Monto</th>
|
||||
<th>Estado</th>
|
||||
<th>Pago</th>
|
||||
<th>Google Cal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${filtered
|
||||
.map(
|
||||
(b) => `
|
||||
<tr>
|
||||
<td class="font-mono font-bold">${b.booking_code}</td>
|
||||
<td>
|
||||
<div class="font-medium">${b.client_name || "Cliente"}</div>
|
||||
<div class="text-xs text-muted">📱 ${b.client_phone || ""}</div>
|
||||
</td>
|
||||
<td>${b.service_name || "Consulta"}</td>
|
||||
<td>${formatDateTime(b.scheduled_at)}</td>
|
||||
<td class="font-bold">${formatCurrency(b.amount_mxn)}</td>
|
||||
<td>${renderBookingStatusBadge(b.booking_status)}</td>
|
||||
<td>${renderPaymentStatusBadge(b.payment_status, b.payment_arrangement)}</td>
|
||||
<td>${renderCalendarSyncBadge(b.gcal_sync_status, b.id)}</td>
|
||||
</tr>
|
||||
`,
|
||||
)
|
||||
.join("")}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
|
||||
statusSelect?.addEventListener("change", () => applyFilter());
|
||||
refreshBtn?.addEventListener("click", () => loadData());
|
||||
loadData();
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
import { fetchAllBookings, retryCalendarSync } from "../api";
|
||||
import type { Booking } from "../types";
|
||||
import { calculateInterval, formatCurrency, formatDateTime } from "../utils";
|
||||
import {
|
||||
renderBookingStatusBadge,
|
||||
renderCalendarSyncBadge,
|
||||
renderPaymentStatusBadge,
|
||||
} from "./StatusBadge";
|
||||
|
||||
export function renderDailyAgenda(
|
||||
container: HTMLElement,
|
||||
onStateChange: () => void,
|
||||
): void {
|
||||
container.innerHTML = `
|
||||
<div class="view-header">
|
||||
<div>
|
||||
<h2 class="view-title">Agenda & Control de Capacidad</h2>
|
||||
<p class="view-subtitle">Visualización cronológica con protección de buffers de 15 min entre pacientes.</p>
|
||||
</div>
|
||||
<div class="view-actions">
|
||||
<button id="refresh-agenda-btn" class="btn btn-secondary btn-sm" title="Refrescar agenda">
|
||||
↻ Actualizar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="agenda-stats" class="stats-row"></div>
|
||||
|
||||
<div id="agenda-content" class="agenda-timeline">
|
||||
<div class="loading-state">
|
||||
<div class="skeleton-card"></div>
|
||||
<div class="skeleton-card"></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const contentDiv = container.querySelector<HTMLDivElement>("#agenda-content");
|
||||
const statsDiv = container.querySelector<HTMLDivElement>("#agenda-stats");
|
||||
const refreshBtn = container.querySelector<HTMLButtonElement>(
|
||||
"#refresh-agenda-btn",
|
||||
);
|
||||
|
||||
const loadData = async () => {
|
||||
if (!contentDiv) return;
|
||||
contentDiv.innerHTML = `
|
||||
<div class="loading-state">
|
||||
<div class="skeleton-card"></div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
try {
|
||||
const bookings = await fetchAllBookings();
|
||||
// Filter active bookings and sort chronologically
|
||||
const activeBookings = bookings
|
||||
.filter(
|
||||
(b) =>
|
||||
b.booking_status !== "CANCELLED" && b.booking_status !== "RELEASED",
|
||||
)
|
||||
.sort(
|
||||
(a, b) =>
|
||||
new Date(a.scheduled_at).getTime() -
|
||||
new Date(b.scheduled_at).getTime(),
|
||||
);
|
||||
|
||||
renderStats(activeBookings);
|
||||
renderTimeline(activeBookings);
|
||||
} catch (err: unknown) {
|
||||
if (contentDiv) {
|
||||
contentDiv.innerHTML = `
|
||||
<div class="card error-state">
|
||||
<div class="error-icon">⚠️</div>
|
||||
<h3 class="error-title">Error al cargar la agenda</h3>
|
||||
<p class="error-desc">${err instanceof Error ? err.message : "Error desconocido"}</p>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const renderStats = (bookings: Booking[]) => {
|
||||
if (!statsDiv) return;
|
||||
const total = bookings.length;
|
||||
const confirmed = bookings.filter(
|
||||
(b) => b.payment_status === "ACKNOWLEDGED",
|
||||
).length;
|
||||
const pending = bookings.filter(
|
||||
(b) => b.payment_status === "AWAITING_ACKNOWLEDGMENT",
|
||||
).length;
|
||||
const totalMinutes = bookings.reduce(
|
||||
(acc, b) => acc + (b.duration_minutes || 60) + (b.buffer_minutes || 15),
|
||||
0,
|
||||
);
|
||||
const totalHours = (totalMinutes / 60).toFixed(1);
|
||||
|
||||
statsDiv.innerHTML = `
|
||||
<div class="stat-card">
|
||||
<span class="stat-label">Citas Programadas</span>
|
||||
<span class="stat-number">${total}</span>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<span class="stat-label">Pagos Confirmados</span>
|
||||
<span class="stat-number text-success">${confirmed}</span>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<span class="stat-label">Pendientes / Prórroga</span>
|
||||
<span class="stat-number text-warning">${pending}</span>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<span class="stat-label">Tiempo Ocupado + Buffer</span>
|
||||
<span class="stat-number">${totalHours}h</span>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
|
||||
const renderTimeline = (bookings: Booking[]) => {
|
||||
if (!contentDiv) return;
|
||||
|
||||
if (bookings.length === 0) {
|
||||
contentDiv.innerHTML = `
|
||||
<div class="card empty-state">
|
||||
<div class="empty-icon">📅</div>
|
||||
<h3 class="empty-title">Agenda libre</h3>
|
||||
<p class="empty-desc">No hay citas activas programadas en este momento.</p>
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
contentDiv.innerHTML = `
|
||||
<div class="timeline-list">
|
||||
${bookings
|
||||
.map((b, idx) => {
|
||||
const interval = calculateInterval(
|
||||
b.scheduled_at,
|
||||
b.duration_minutes || 60,
|
||||
b.buffer_minutes || 15,
|
||||
);
|
||||
|
||||
// Collision detector with subsequent session
|
||||
let collisionNotice = "";
|
||||
if (idx < bookings.length - 1) {
|
||||
const nextBooking = bookings[idx + 1];
|
||||
const nextStart = new Date(nextBooking.scheduled_at);
|
||||
if (nextStart < interval.bufferEnd) {
|
||||
collisionNotice = `
|
||||
<div class="collision-alert">
|
||||
⚠️ ADVERTENCIA: La siguiente cita (${nextBooking.booking_code}) inicia a las ${interval.endStr}, invadiendo el buffer de preparación.
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
return `
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-time-col">
|
||||
<span class="time-main">${interval.startStr}</span>
|
||||
<span class="time-end">a ${interval.endStr}</span>
|
||||
<span class="duration-badge">${b.duration_minutes || 60} min</span>
|
||||
</div>
|
||||
|
||||
<div class="timeline-card">
|
||||
<div class="card-header">
|
||||
<div class="header-left">
|
||||
<span class="folio-tag">${b.booking_code}</span>
|
||||
<span class="service-name-inline font-medium">${b.service_name || "Consulta"}</span>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
${renderBookingStatusBadge(b.booking_status)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body-compact">
|
||||
<div class="client-row">
|
||||
<span class="client-name font-semibold">${b.client_name || "Cliente"}</span>
|
||||
<span class="client-phone text-muted">📱 ${b.client_phone || ""}</span>
|
||||
</div>
|
||||
<div class="meta-row">
|
||||
<span class="date-text">${formatDateTime(b.scheduled_at)}</span>
|
||||
<span class="amount-tag font-bold">${formatCurrency(b.amount_mxn)}</span>
|
||||
</div>
|
||||
<div class="status-chips">
|
||||
${renderPaymentStatusBadge(b.payment_status, b.payment_arrangement)}
|
||||
${renderCalendarSyncBadge(b.gcal_sync_status, b.id)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Mandatory Buffer Block -->
|
||||
<div class="buffer-block" title="Intervalo de buffer protegido para evitar retrasos en cascada">
|
||||
<div class="buffer-badge">
|
||||
🌿 Buffer de descanso y preparación (${b.buffer_minutes || 15} min):
|
||||
<strong>${interval.endStr} - ${interval.bufferEndStr}</strong>
|
||||
</div>
|
||||
<span class="buffer-hint">Tiempo no agendable protegido por el backend.</span>
|
||||
</div>
|
||||
|
||||
${collisionNotice}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
})
|
||||
.join("")}
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Attach retry calendar sync buttons
|
||||
contentDiv.querySelectorAll(".btn-retry-gcal").forEach((btn) => {
|
||||
btn.addEventListener("click", async () => {
|
||||
const id = btn.getAttribute("data-booking-id");
|
||||
if (!id) return;
|
||||
btn.textContent = "⏳...";
|
||||
try {
|
||||
await retryCalendarSync(id);
|
||||
loadData();
|
||||
onStateChange();
|
||||
} catch (err: unknown) {
|
||||
alert(
|
||||
err instanceof Error ? err.message : "Error al reintentar sync",
|
||||
);
|
||||
btn.textContent = "↻";
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
refreshBtn?.addEventListener("click", () => loadData());
|
||||
loadData();
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
import {
|
||||
authorizeDelayedPayment,
|
||||
fetchFollowUpQueue,
|
||||
releaseBooking,
|
||||
} from "../api";
|
||||
import type { Booking } from "../types";
|
||||
import {
|
||||
formatCurrency,
|
||||
formatDateTime,
|
||||
getHoursRemainingBadge,
|
||||
} from "../utils";
|
||||
import { openPaymentModal } from "./PaymentModal";
|
||||
import {
|
||||
renderBookingStatusBadge,
|
||||
renderCalendarSyncBadge,
|
||||
renderPaymentStatusBadge,
|
||||
} from "./StatusBadge";
|
||||
|
||||
export function renderFollowUpQueue(
|
||||
container: HTMLElement,
|
||||
onStateChange: () => void,
|
||||
): void {
|
||||
container.innerHTML = `
|
||||
<div class="view-header">
|
||||
<div>
|
||||
<h2 class="view-title">Cola de Seguimiento (48 Horas)</h2>
|
||||
<p class="view-subtitle">Reservaciones pendientes de comprobante de pago próximas a realizarse.</p>
|
||||
</div>
|
||||
<div class="view-actions">
|
||||
<button id="refresh-queue-btn" class="btn btn-secondary btn-sm" title="Refrescar lista">
|
||||
↻ Actualizar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="queue-content" class="queue-container">
|
||||
<div class="loading-state">
|
||||
<div class="skeleton-card"></div>
|
||||
<div class="skeleton-card"></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const contentDiv = container.querySelector<HTMLDivElement>("#queue-content");
|
||||
const refreshBtn =
|
||||
container.querySelector<HTMLButtonElement>("#refresh-queue-btn");
|
||||
|
||||
const loadData = async () => {
|
||||
if (!contentDiv) return;
|
||||
contentDiv.innerHTML = `
|
||||
<div class="loading-state">
|
||||
<div class="skeleton-card"></div>
|
||||
<div class="skeleton-card"></div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
try {
|
||||
const bookings = await fetchFollowUpQueue();
|
||||
renderList(bookings);
|
||||
} catch (err: unknown) {
|
||||
renderError(err instanceof Error ? err.message : "Error desconocido");
|
||||
}
|
||||
};
|
||||
|
||||
const renderError = (message: string) => {
|
||||
if (!contentDiv) return;
|
||||
contentDiv.innerHTML = `
|
||||
<div class="card error-state">
|
||||
<div class="error-icon">⚠️</div>
|
||||
<h3 class="error-title">No se pudo cargar la cola de seguimiento</h3>
|
||||
<p class="error-desc">${message}</p>
|
||||
<button id="retry-queue-btn" class="btn btn-primary btn-sm">
|
||||
Intentar de nuevo
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
contentDiv
|
||||
.querySelector("#retry-queue-btn")
|
||||
?.addEventListener("click", () => loadData());
|
||||
};
|
||||
|
||||
const renderList = (bookings: Booking[]) => {
|
||||
if (!contentDiv) return;
|
||||
|
||||
if (bookings.length === 0) {
|
||||
contentDiv.innerHTML = `
|
||||
<div class="card empty-state">
|
||||
<div class="empty-icon">🌿</div>
|
||||
<h3 class="empty-title">Agenda al día</h3>
|
||||
<p class="empty-desc">No hay reservaciones pendientes de pago para las próximas 48 horas.</p>
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
contentDiv.innerHTML = `
|
||||
<div class="queue-meta">
|
||||
<span class="queue-count-pill">${bookings.length} reservación${bookings.length === 1 ? "" : "es"} por atender</span>
|
||||
</div>
|
||||
<div class="queue-grid">
|
||||
${bookings.map((b) => renderCard(b)).join("")}
|
||||
</div>
|
||||
`;
|
||||
|
||||
attachEvents(bookings);
|
||||
};
|
||||
|
||||
const renderCard = (b: Booking): string => {
|
||||
const hoursBadge = getHoursRemainingBadge(b.hours_until_session);
|
||||
const waLink =
|
||||
b.whatsapp_followup_url ||
|
||||
`https://wa.me/${b.client_phone?.replace(/\D/g, "") || ""}?text=${encodeURIComponent(
|
||||
`Hola ${b.client_name || ""}, te contactamos de Armonía del Ser para dar seguimiento a tu reservación (${b.booking_code}).`,
|
||||
)}`;
|
||||
|
||||
return `
|
||||
<div class="booking-card" id="card-${b.id}">
|
||||
<div class="card-header">
|
||||
<div class="header-left">
|
||||
<span class="folio-tag">${b.booking_code}</span>
|
||||
<span class="${hoursBadge.urgencyClass} text-xs font-semibold px-2 py-0.5 rounded">
|
||||
${hoursBadge.text}
|
||||
</span>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
${renderBookingStatusBadge(b.booking_status)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="client-info">
|
||||
<h3 class="client-name">${b.client_name || "Cliente sin nombre"}</h3>
|
||||
<span class="client-phone">📱 ${b.client_phone || "Sin teléfono"}</span>
|
||||
</div>
|
||||
|
||||
<div class="service-details">
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Servicio:</span>
|
||||
<span class="detail-value font-medium">${b.service_name || "Consulta"}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Fecha y Hora:</span>
|
||||
<span class="detail-value font-medium">${formatDateTime(b.scheduled_at)}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Monto:</span>
|
||||
<span class="detail-value font-bold text-sage">${formatCurrency(b.amount_mxn)}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-row">
|
||||
${renderPaymentStatusBadge(b.payment_status, b.payment_arrangement)}
|
||||
${renderCalendarSyncBadge(b.gcal_sync_status, b.id)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-actions">
|
||||
<a
|
||||
href="${waLink}"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="btn btn-whatsapp"
|
||||
title="Abrir chat de WhatsApp con recordatorio pre-redactado"
|
||||
>
|
||||
<span>💬 Enviar WhatsApp</span>
|
||||
</a>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary btn-ack-payment"
|
||||
data-booking-id="${b.id}"
|
||||
>
|
||||
<span>✓ Acreditar Pago</span>
|
||||
</button>
|
||||
|
||||
<div class="secondary-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-text btn-authorize-delay"
|
||||
data-booking-id="${b.id}"
|
||||
title="Permitir que el paciente pague al llegar"
|
||||
>
|
||||
Autorizar prórroga
|
||||
</button>
|
||||
<span class="divider">·</span>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-text text-danger btn-release-slot"
|
||||
data-booking-id="${b.id}"
|
||||
title="Liberar el espacio si no hubo respuesta"
|
||||
>
|
||||
Liberar lugar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
|
||||
const attachEvents = (bookings: Booking[]) => {
|
||||
if (!contentDiv) return;
|
||||
|
||||
// Acknowledge payment modal
|
||||
contentDiv.querySelectorAll(".btn-ack-payment").forEach((btn) => {
|
||||
btn.addEventListener("click", () => {
|
||||
const id = btn.getAttribute("data-booking-id");
|
||||
const booking = bookings.find((b) => b.id === id);
|
||||
if (!booking) return;
|
||||
|
||||
openPaymentModal({
|
||||
booking,
|
||||
onSuccess: () => {
|
||||
loadData();
|
||||
onStateChange();
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Authorize delayed payment
|
||||
contentDiv.querySelectorAll(".btn-authorize-delay").forEach((btn) => {
|
||||
btn.addEventListener("click", async () => {
|
||||
const id = btn.getAttribute("data-booking-id");
|
||||
if (!id) return;
|
||||
const notes = window.prompt(
|
||||
"Motivo o acuerdo de la prórroga de pago:",
|
||||
"Acordado con el paciente para pago en efectivo antes de la sesión",
|
||||
);
|
||||
if (notes === null) return;
|
||||
|
||||
try {
|
||||
await authorizeDelayedPayment(id, notes);
|
||||
loadData();
|
||||
onStateChange();
|
||||
} catch (err: unknown) {
|
||||
alert(
|
||||
err instanceof Error ? err.message : "Error al autorizar prórroga",
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Release booking
|
||||
contentDiv.querySelectorAll(".btn-release-slot").forEach((btn) => {
|
||||
btn.addEventListener("click", async () => {
|
||||
const id = btn.getAttribute("data-booking-id");
|
||||
if (!id) return;
|
||||
const reason = window.prompt(
|
||||
"¿Deseas liberar este horario para otros clientes? Motivo:",
|
||||
"Sin respuesta a recordatorios de pago dentro de las 48h",
|
||||
);
|
||||
if (reason === null) return;
|
||||
|
||||
try {
|
||||
await releaseBooking(id, reason);
|
||||
loadData();
|
||||
onStateChange();
|
||||
} catch (err: unknown) {
|
||||
alert(
|
||||
err instanceof Error ? err.message : "Error al liberar espacio",
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
refreshBtn?.addEventListener("click", () => loadData());
|
||||
loadData();
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
import type { Booking } from "../types";
|
||||
import { formatCurrency } from "../utils";
|
||||
|
||||
export interface PaymentModalOptions {
|
||||
booking: Booking;
|
||||
onConfirm: (payload: {
|
||||
booking_id: string;
|
||||
amount_mxn: number;
|
||||
payment_method: "SPEI" | "OXXO" | "CASH";
|
||||
notes?: string;
|
||||
}) => Promise<void>;
|
||||
onCancel: () => void;
|
||||
}
|
||||
|
||||
export function openPaymentModal(options: {
|
||||
booking: Booking;
|
||||
onSuccess: () => void;
|
||||
}): void {
|
||||
const { booking, onSuccess } = options;
|
||||
|
||||
const existingModal = document.getElementById("payment-modal-backdrop");
|
||||
if (existingModal) existingModal.remove();
|
||||
|
||||
const backdrop = document.createElement("div");
|
||||
backdrop.id = "payment-modal-backdrop";
|
||||
backdrop.className = "modal-backdrop";
|
||||
|
||||
backdrop.innerHTML = `
|
||||
<div class="modal-card" role="dialog" aria-modal="true" aria-labelledby="modal-title">
|
||||
<div class="modal-header">
|
||||
<div>
|
||||
<span class="modal-kicker">Recepción de Pago</span>
|
||||
<h3 id="modal-title" class="modal-title">Acreditar Pago de Reservación</h3>
|
||||
</div>
|
||||
<button type="button" class="modal-close-btn" id="modal-close" aria-label="Cerrar modal">×</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="summary-box">
|
||||
<div class="summary-row">
|
||||
<span class="summary-label">Folio:</span>
|
||||
<span class="summary-value font-mono font-bold">${booking.booking_code}</span>
|
||||
</div>
|
||||
<div class="summary-row">
|
||||
<span class="summary-label">Paciente:</span>
|
||||
<span class="summary-value">${booking.client_name || "Cliente"}</span>
|
||||
</div>
|
||||
<div class="summary-row">
|
||||
<span class="summary-label">Servicio:</span>
|
||||
<span class="summary-value">${booking.service_name || "Consulta"}</span>
|
||||
</div>
|
||||
<div class="summary-row">
|
||||
<span class="summary-label">Monto sugerido:</span>
|
||||
<span class="summary-value font-bold text-sage">${formatCurrency(booking.amount_mxn)}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form id="payment-form" class="payment-form">
|
||||
<div class="form-group">
|
||||
<label for="payment-amount" class="form-label">Monto recibido (MXN):</label>
|
||||
<input
|
||||
type="number"
|
||||
id="payment-amount"
|
||||
name="amount"
|
||||
class="form-input"
|
||||
value="${booking.amount_mxn}"
|
||||
min="0"
|
||||
step="10"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label">Método de pago:</label>
|
||||
<div class="payment-method-selector">
|
||||
<label class="method-option">
|
||||
<input type="radio" name="payment_method" value="SPEI" checked />
|
||||
<span>SPEI (Transferencia)</span>
|
||||
</label>
|
||||
<label class="method-option">
|
||||
<input type="radio" name="payment_method" value="CASH" />
|
||||
<span>Efectivo</span>
|
||||
</label>
|
||||
<label class="method-option">
|
||||
<input type="radio" name="payment_method" value="OXXO" />
|
||||
<span>OXXO</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="payment-notes" class="form-label">Notas u observaciones (opcional):</label>
|
||||
<input
|
||||
type="text"
|
||||
id="payment-notes"
|
||||
name="notes"
|
||||
class="form-input"
|
||||
placeholder="Ej. Transferencia confirmada por Jasmin / BBVA Folio 987"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div id="modal-error-box" class="modal-error-box hidden"></div>
|
||||
|
||||
<div class="modal-actions">
|
||||
<button type="button" id="modal-cancel-btn" class="btn btn-secondary">
|
||||
Cancelar
|
||||
</button>
|
||||
<button type="submit" id="modal-submit-btn" class="btn btn-primary">
|
||||
Confirmar Acreditación
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.body.appendChild(backdrop);
|
||||
|
||||
const close = () => {
|
||||
backdrop.remove();
|
||||
document.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape") close();
|
||||
};
|
||||
document.addEventListener("keydown", handleKeyDown);
|
||||
|
||||
backdrop
|
||||
.querySelector("#modal-close")
|
||||
?.addEventListener("click", () => close());
|
||||
backdrop
|
||||
.querySelector("#modal-cancel-btn")
|
||||
?.addEventListener("click", () => close());
|
||||
backdrop.addEventListener("click", (e) => {
|
||||
if (e.target === backdrop) close();
|
||||
});
|
||||
|
||||
const form = backdrop.querySelector<HTMLFormElement>("#payment-form");
|
||||
const submitBtn =
|
||||
backdrop.querySelector<HTMLButtonElement>("#modal-submit-btn");
|
||||
const errorBox = backdrop.querySelector<HTMLDivElement>("#modal-error-box");
|
||||
|
||||
form?.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
if (!submitBtn || !errorBox) return;
|
||||
|
||||
submitBtn.disabled = true;
|
||||
submitBtn.textContent = "Acreditando...";
|
||||
errorBox.classList.add("hidden");
|
||||
errorBox.textContent = "";
|
||||
|
||||
const amountInput = form.querySelector<HTMLInputElement>("#payment-amount");
|
||||
const notesInput = form.querySelector<HTMLInputElement>("#payment-notes");
|
||||
const methodInput = form.querySelector<HTMLInputElement>(
|
||||
'input[name="payment_method"]:checked',
|
||||
);
|
||||
|
||||
const amount = Number(amountInput?.value || booking.amount_mxn);
|
||||
const method = (methodInput?.value as "SPEI" | "OXXO" | "CASH") || "SPEI";
|
||||
const notes = notesInput?.value.trim() || undefined;
|
||||
|
||||
try {
|
||||
const { acknowledgePayment } = await import("../api");
|
||||
await acknowledgePayment({
|
||||
booking_id: booking.id,
|
||||
amount_mxn: amount,
|
||||
payment_method: method,
|
||||
notes,
|
||||
});
|
||||
close();
|
||||
onSuccess();
|
||||
} catch (err: unknown) {
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.textContent = "Confirmar Acreditación";
|
||||
errorBox.textContent =
|
||||
err instanceof Error ? err.message : "Error al procesar el pago";
|
||||
errorBox.classList.remove("hidden");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import type {
|
||||
BookingPaymentStatus,
|
||||
BookingStatus,
|
||||
GcalSyncStatus,
|
||||
PaymentArrangement,
|
||||
} from "../types";
|
||||
|
||||
export function renderBookingStatusBadge(status: BookingStatus): string {
|
||||
switch (status) {
|
||||
case "RESERVED":
|
||||
return '<span class="status-pill status-reserved">Reservada</span>';
|
||||
case "COMPLETED":
|
||||
return '<span class="status-pill status-completed">Completada</span>';
|
||||
case "CANCELLED":
|
||||
return '<span class="status-pill status-cancelled">Cancelada</span>';
|
||||
case "RELEASED":
|
||||
return '<span class="status-pill status-released">Espacio Liberado</span>';
|
||||
case "NO_SHOW":
|
||||
return '<span class="status-pill status-noshow">No asistió</span>';
|
||||
default:
|
||||
return `<span class="status-pill">${status}</span>`;
|
||||
}
|
||||
}
|
||||
|
||||
export function renderPaymentStatusBadge(
|
||||
paymentStatus: BookingPaymentStatus,
|
||||
arrangement: PaymentArrangement,
|
||||
): string {
|
||||
if (arrangement === "PACKAGE_REDEEMED") {
|
||||
return '<span class="status-pill status-package">Sesión de Paquete</span>';
|
||||
}
|
||||
|
||||
if (paymentStatus === "ACKNOWLEDGED") {
|
||||
return '<span class="status-pill status-acknowledged">✓ Pago Confirmado</span>';
|
||||
}
|
||||
|
||||
if (arrangement === "DELAYED_ALLOWED") {
|
||||
return '<span class="status-pill status-delayed">⏳ Prórroga Autorizada</span>';
|
||||
}
|
||||
|
||||
return '<span class="status-pill status-awaiting">⚠️ Pago Pendiente</span>';
|
||||
}
|
||||
|
||||
export function renderCalendarSyncBadge(
|
||||
syncStatus: GcalSyncStatus,
|
||||
bookingId: string,
|
||||
): string {
|
||||
switch (syncStatus) {
|
||||
case "SYNCED":
|
||||
return '<span class="status-pill status-gcal-synced" title="Sincronizado con Google Calendar">📅 En Google Calendar</span>';
|
||||
case "FAILED":
|
||||
return `
|
||||
<div class="inline-flex items-center gap-1">
|
||||
<span class="status-pill status-gcal-failed" title="Fallo en la sincronización">⚠️ Error Cal</span>
|
||||
<button class="btn-xs btn-retry-gcal" data-booking-id="${bookingId}" title="Reintentar sincronización con Google Calendar">↻</button>
|
||||
</div>
|
||||
`;
|
||||
case "PENDING":
|
||||
return '<span class="status-pill status-gcal-pending">⏳ Sincronizando...</span>';
|
||||
default:
|
||||
return '<span class="status-pill status-gcal-none">Cal no config</span>';
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
import "./style.css";
|
||||
import { fetchFollowUpQueue } from "./api";
|
||||
import { renderAllBookings } from "./components/AllBookings";
|
||||
import { renderDailyAgenda } from "./components/DailyAgenda";
|
||||
import { renderFollowUpQueue } from "./components/FollowUpQueue";
|
||||
|
||||
type TabId = "queue" | "agenda" | "all";
|
||||
|
||||
class OperatorDashboardApp {
|
||||
private activeTab: TabId = "queue";
|
||||
private container: HTMLElement;
|
||||
|
||||
public get currentTab(): TabId {
|
||||
return this.activeTab;
|
||||
}
|
||||
|
||||
constructor(container: HTMLElement) {
|
||||
this.container = container;
|
||||
this.init();
|
||||
}
|
||||
|
||||
private async init(): Promise<void> {
|
||||
this.renderShell();
|
||||
this.bindEvents();
|
||||
await this.refreshTabBadge();
|
||||
const hash = window.location.hash.replace("#", "") as TabId;
|
||||
const initialTab = hash === "agenda" || hash === "all" ? hash : "queue";
|
||||
this.switchTab(initialTab);
|
||||
}
|
||||
|
||||
private renderShell(): void {
|
||||
this.container.innerHTML = `
|
||||
<header class="app-header">
|
||||
<div class="brand-section">
|
||||
<span class="brand-lotus">🪷</span>
|
||||
<div>
|
||||
<h1 class="brand-title">Armonía del Ser</h1>
|
||||
<div class="text-xs text-muted">Panel Operativo de Consultas y Agenda</div>
|
||||
</div>
|
||||
<span class="brand-badge">Operador</span>
|
||||
</div>
|
||||
<div class="operator-profile">
|
||||
<div class="operator-badge">
|
||||
<span class="status-dot"></span>
|
||||
<span>Jasmin & Asistente</span>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<nav class="nav-tabs" role="tablist">
|
||||
<button class="nav-tab active" data-tab="queue" role="tab" aria-selected="true">
|
||||
<span>Cola 48h (Seguimiento)</span>
|
||||
<span id="queue-badge" class="tab-badge hidden">0</span>
|
||||
</button>
|
||||
<button class="nav-tab" data-tab="agenda" role="tab" aria-selected="false">
|
||||
<span>Agenda del Día (Buffers)</span>
|
||||
</button>
|
||||
<button class="nav-tab" data-tab="all" role="tab" aria-selected="false">
|
||||
<span>Todas las Citas</span>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<main id="tab-content" class="tab-main-content" role="tabpanel"></main>
|
||||
`;
|
||||
}
|
||||
|
||||
private bindEvents(): void {
|
||||
const tabButtons =
|
||||
this.container.querySelectorAll<HTMLButtonElement>(".nav-tab");
|
||||
tabButtons.forEach((btn) => {
|
||||
btn.addEventListener("click", () => {
|
||||
const targetTab = btn.getAttribute("data-tab") as TabId;
|
||||
if (targetTab) {
|
||||
this.switchTab(targetTab);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private switchTab(tab: TabId): void {
|
||||
this.activeTab = tab;
|
||||
|
||||
// Update tab button active states
|
||||
const tabButtons =
|
||||
this.container.querySelectorAll<HTMLButtonElement>(".nav-tab");
|
||||
tabButtons.forEach((btn) => {
|
||||
const isCurrent = btn.getAttribute("data-tab") === tab;
|
||||
btn.classList.toggle("active", isCurrent);
|
||||
btn.setAttribute("aria-selected", isCurrent ? "true" : "false");
|
||||
});
|
||||
|
||||
// Render tab view
|
||||
const contentEl = this.container.querySelector<HTMLElement>("#tab-content");
|
||||
if (!contentEl) return;
|
||||
|
||||
const onStateChange = async () => {
|
||||
await this.refreshTabBadge();
|
||||
};
|
||||
|
||||
if (tab === "queue") {
|
||||
renderFollowUpQueue(contentEl, onStateChange);
|
||||
} else if (tab === "agenda") {
|
||||
renderDailyAgenda(contentEl, onStateChange);
|
||||
} else if (tab === "all") {
|
||||
renderAllBookings(contentEl);
|
||||
}
|
||||
}
|
||||
|
||||
private async refreshTabBadge(): Promise<void> {
|
||||
try {
|
||||
const queue = await fetchFollowUpQueue();
|
||||
const badge =
|
||||
this.container.querySelector<HTMLSpanElement>("#queue-badge");
|
||||
if (badge) {
|
||||
if (queue.length > 0) {
|
||||
badge.textContent = String(queue.length);
|
||||
badge.classList.remove("hidden");
|
||||
} else {
|
||||
badge.classList.add("hidden");
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Ignore badge background fetch failure
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const appRoot = document.getElementById("app");
|
||||
if (appRoot) {
|
||||
new OperatorDashboardApp(appRoot);
|
||||
}
|
||||
+930
@@ -0,0 +1,930 @@
|
||||
:root {
|
||||
--color-bg: #f9f7f3;
|
||||
--color-surface: #ffffff;
|
||||
--color-surface-soft: #f2efe9;
|
||||
--color-text-main: #1d2a24;
|
||||
--color-text-muted: #5e6d66;
|
||||
--color-border: #e5dfd5;
|
||||
--color-border-focus: #2d5a46;
|
||||
|
||||
/* Brand Palette: Armonía del Ser */
|
||||
--color-sage: #2d5a46;
|
||||
--color-sage-dark: #1e3e30;
|
||||
--color-sage-light: #ebf3ee;
|
||||
--color-terracotta: #c25e3b;
|
||||
--color-terracotta-light: #fbefea;
|
||||
--color-gold: #b8860b;
|
||||
--color-gold-light: #fbf6e9;
|
||||
--color-success: #1e7e4e;
|
||||
--color-success-light: #e8f5ed;
|
||||
--color-danger: #c53030;
|
||||
--color-danger-light: #fde8e8;
|
||||
--color-warning: #d97706;
|
||||
--color-warning-light: #fef3c7;
|
||||
|
||||
--font-serif: "Playfair Display", Georgia, "Times New Roman", serif;
|
||||
--font-sans:
|
||||
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
|
||||
sans-serif;
|
||||
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
|
||||
--radius-sm: 6px;
|
||||
--radius-md: 10px;
|
||||
--radius-lg: 16px;
|
||||
--shadow-sm: 0 1px 3px rgba(29, 42, 36, 0.05);
|
||||
--shadow-md: 0 4px 12px rgba(29, 42, 36, 0.08);
|
||||
--shadow-lg: 0 10px 25px rgba(29, 42, 36, 0.12);
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: var(--font-sans);
|
||||
background-color: var(--color-bg);
|
||||
color: var(--color-text-main);
|
||||
line-height: 1.5;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
/* Layout */
|
||||
.app-container {
|
||||
max-width: 1100px;
|
||||
margin: 0 auto;
|
||||
padding: 16px;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.app-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 16px 0 20px 0;
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
.app-header {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.brand-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.brand-lotus {
|
||||
font-size: 28px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.brand-title {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
color: var(--color-sage-dark);
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.brand-badge {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
background: var(--color-sage-light);
|
||||
color: var(--color-sage);
|
||||
padding: 3px 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.operator-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
color: var(--color-text-muted);
|
||||
background: var(--color-surface);
|
||||
padding: 6px 12px;
|
||||
border-radius: var(--radius-md);
|
||||
border: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--color-success);
|
||||
}
|
||||
|
||||
/* Navigation Tabs */
|
||||
.nav-tabs {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
border-bottom: 2px solid var(--color-border);
|
||||
margin-bottom: 24px;
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.nav-tab {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 12px 18px;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: var(--color-text-muted);
|
||||
cursor: pointer;
|
||||
border-bottom: 2px solid transparent;
|
||||
margin-bottom: -2px;
|
||||
white-space: nowrap;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 48px; /* Touch target */
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.nav-tab:hover {
|
||||
color: var(--color-sage);
|
||||
}
|
||||
|
||||
.nav-tab.active {
|
||||
color: var(--color-sage);
|
||||
font-weight: 600;
|
||||
border-bottom-color: var(--color-sage);
|
||||
}
|
||||
|
||||
.tab-badge {
|
||||
background: var(--color-terracotta);
|
||||
color: #fff;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
padding: 2px 7px;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
/* Views */
|
||||
.view-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 20px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.view-title {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 20px;
|
||||
color: var(--color-text-main);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.view-subtitle {
|
||||
font-size: 14px;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
/* Stats Row */
|
||||
.stats-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: var(--color-surface);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 12px;
|
||||
color: var(--color-text-muted);
|
||||
text-transform: uppercase;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
.stat-number {
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
color: var(--color-text-main);
|
||||
}
|
||||
|
||||
/* Queue Grid */
|
||||
.queue-meta {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.queue-count-pill {
|
||||
display: inline-block;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
background: var(--color-surface-soft);
|
||||
color: var(--color-text-muted);
|
||||
padding: 4px 10px;
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.queue-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.queue-grid {
|
||||
grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
/* Booking Cards */
|
||||
.booking-card {
|
||||
background: var(--color-surface);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
box-shadow: var(--shadow-sm);
|
||||
transition:
|
||||
transform 0.15s ease,
|
||||
box-shadow 0.15s ease;
|
||||
}
|
||||
|
||||
.booking-card:hover {
|
||||
box-shadow: var(--shadow-md);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
padding-bottom: 10px;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.folio-tag {
|
||||
font-family: var(--font-mono);
|
||||
font-weight: 700;
|
||||
font-size: 14px;
|
||||
background: var(--color-surface-soft);
|
||||
color: var(--color-text-main);
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
border: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.client-name {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--color-text-main);
|
||||
}
|
||||
|
||||
.client-phone {
|
||||
font-size: 13px;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.service-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin: 10px 0;
|
||||
background: var(--color-bg);
|
||||
padding: 10px 12px;
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.detail-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.status-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* Status Pills */
|
||||
.status-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
padding: 3px 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.status-reserved {
|
||||
background: var(--color-sage-light);
|
||||
color: var(--color-sage);
|
||||
}
|
||||
.status-completed {
|
||||
background: var(--color-surface-soft);
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
.status-cancelled {
|
||||
background: #fee2e2;
|
||||
color: #991b1b;
|
||||
}
|
||||
.status-released {
|
||||
background: #fef3c7;
|
||||
color: #92400e;
|
||||
}
|
||||
.status-acknowledged {
|
||||
background: var(--color-success-light);
|
||||
color: var(--color-success);
|
||||
font-weight: 700;
|
||||
}
|
||||
.status-awaiting {
|
||||
background: var(--color-terracotta-light);
|
||||
color: var(--color-terracotta);
|
||||
font-weight: 700;
|
||||
}
|
||||
.status-delayed {
|
||||
background: var(--color-gold-light);
|
||||
color: var(--color-gold);
|
||||
font-weight: 700;
|
||||
}
|
||||
.status-package {
|
||||
background: #ede9fe;
|
||||
color: #5b21b6;
|
||||
}
|
||||
|
||||
.status-gcal-synced {
|
||||
background: #e0f2fe;
|
||||
color: #0369a1;
|
||||
}
|
||||
.status-gcal-failed {
|
||||
background: var(--color-danger-light);
|
||||
color: var(--color-danger);
|
||||
}
|
||||
.status-gcal-pending {
|
||||
background: #f3f4f6;
|
||||
color: #4b5563;
|
||||
}
|
||||
.status-gcal-none {
|
||||
background: #f3f4f6;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.badge-danger {
|
||||
background: var(--color-danger-light);
|
||||
color: var(--color-danger);
|
||||
}
|
||||
.badge-warning {
|
||||
background: var(--color-warning-light);
|
||||
color: var(--color-warning);
|
||||
}
|
||||
.badge-info {
|
||||
background: var(--color-surface-soft);
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
/* Buttons & Touch Targets */
|
||||
.card-actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
border-top: 1px solid var(--color-border);
|
||||
padding-top: 12px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding: 10px 16px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
border: 1px solid transparent;
|
||||
text-decoration: none;
|
||||
min-height: 44px; /* Mobile touch target */
|
||||
transition:
|
||||
background 0.15s ease,
|
||||
transform 0.05s ease;
|
||||
}
|
||||
|
||||
.btn:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--color-sage);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: var(--color-sage-dark);
|
||||
}
|
||||
|
||||
.btn-whatsapp {
|
||||
background-color: #25d366;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-whatsapp:hover {
|
||||
background-color: #1ebe5d;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: var(--color-surface);
|
||||
border-color: var(--color-border);
|
||||
color: var(--color-text-main);
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background-color: var(--color-surface-soft);
|
||||
}
|
||||
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 6px 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.btn-xs {
|
||||
padding: 2px 6px;
|
||||
font-size: 11px;
|
||||
border-radius: var(--radius-sm);
|
||||
border: 1px solid var(--color-border);
|
||||
background: #fff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.secondary-actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.btn-text {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 12px;
|
||||
color: var(--color-text-muted);
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
padding: 4px 6px;
|
||||
}
|
||||
|
||||
.btn-text:hover {
|
||||
color: var(--color-text-main);
|
||||
}
|
||||
|
||||
.text-danger {
|
||||
color: var(--color-danger);
|
||||
}
|
||||
|
||||
/* Timeline & Buffer Visualization */
|
||||
.timeline-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.timeline-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
.timeline-item {
|
||||
flex-direction: row;
|
||||
gap: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.timeline-time-col {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 8px;
|
||||
align-items: baseline;
|
||||
min-width: 120px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
.timeline-time-col {
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
align-items: flex-end;
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
|
||||
.time-main {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: var(--color-text-main);
|
||||
}
|
||||
|
||||
.time-end {
|
||||
font-size: 12px;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.duration-badge {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
background: var(--color-surface-soft);
|
||||
padding: 2px 6px;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.timeline-card {
|
||||
flex: 1;
|
||||
background: var(--color-surface);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 16px;
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.card-body-compact {
|
||||
margin: 10px 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.client-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.meta-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 13px;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.status-chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
/* Protected Buffer Block */
|
||||
.buffer-block {
|
||||
background: var(--color-sage-light);
|
||||
border-left: 4px solid var(--color-sage);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 8px 12px;
|
||||
margin-top: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.buffer-badge {
|
||||
font-size: 12px;
|
||||
color: var(--color-sage-dark);
|
||||
}
|
||||
|
||||
.buffer-hint {
|
||||
font-size: 11px;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.collision-alert {
|
||||
background: var(--color-danger-light);
|
||||
color: var(--color-danger);
|
||||
border: 1px solid var(--color-danger);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 8px 12px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* Modals */
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background-color: rgba(29, 42, 36, 0.5);
|
||||
backdrop-filter: blur(3px);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 16px;
|
||||
z-index: 1000;
|
||||
animation: fadeIn 0.15s ease-out;
|
||||
}
|
||||
|
||||
.modal-card {
|
||||
background: var(--color-surface);
|
||||
border-radius: var(--radius-lg);
|
||||
max-width: 480px;
|
||||
width: 100%;
|
||||
padding: 24px;
|
||||
box-shadow: var(--shadow-lg);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
animation: slideUp 0.2s ease-out;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.modal-kicker {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: var(--color-sage);
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 18px;
|
||||
color: var(--color-text-main);
|
||||
}
|
||||
|
||||
.modal-close-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 24px;
|
||||
line-height: 1;
|
||||
color: var(--color-text-muted);
|
||||
cursor: pointer;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.summary-box {
|
||||
background: var(--color-surface-soft);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summary-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--color-text-main);
|
||||
}
|
||||
|
||||
.form-input,
|
||||
.form-select {
|
||||
padding: 10px 12px;
|
||||
font-size: 15px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-md);
|
||||
background: #fff;
|
||||
color: var(--color-text-main);
|
||||
min-height: 44px;
|
||||
}
|
||||
|
||||
.form-input:focus,
|
||||
.form-select:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-border-focus);
|
||||
box-shadow: 0 0 0 3px rgba(45, 90, 70, 0.15);
|
||||
}
|
||||
|
||||
.payment-method-selector {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.method-option {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 10px 8px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
background: #fff;
|
||||
min-height: 44px;
|
||||
}
|
||||
|
||||
.method-option:has(input:checked) {
|
||||
border-color: var(--color-sage);
|
||||
background: var(--color-sage-light);
|
||||
color: var(--color-sage-dark);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.modal-error-box {
|
||||
background: var(--color-danger-light);
|
||||
color: var(--color-danger);
|
||||
padding: 8px 12px;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* Tables */
|
||||
.table-container {
|
||||
background: var(--color-surface);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-lg);
|
||||
overflow: hidden;
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.filter-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.filter-label {
|
||||
font-size: 13px;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.bookings-table-wrapper {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.bookings-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 13px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.bookings-table th {
|
||||
background: var(--color-surface-soft);
|
||||
padding: 10px 14px;
|
||||
font-weight: 600;
|
||||
color: var(--color-text-muted);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.bookings-table td {
|
||||
padding: 12px 14px;
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.bookings-table tr:hover td {
|
||||
background: var(--color-bg);
|
||||
}
|
||||
|
||||
/* 5-State Resilient UI Helpers */
|
||||
.loading-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.skeleton-card {
|
||||
height: 160px;
|
||||
background: linear-gradient(90deg, #efece6 25%, #e5e0d8 50%, #efece6 75%);
|
||||
background-size: 200% 100%;
|
||||
border-radius: var(--radius-lg);
|
||||
animation: pulseSkeleton 1.5s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulseSkeleton {
|
||||
0% {
|
||||
background-position: 200% 0;
|
||||
}
|
||||
100% {
|
||||
background-position: -200% 0;
|
||||
}
|
||||
}
|
||||
|
||||
.empty-state,
|
||||
.error-state {
|
||||
padding: 40px 20px;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.empty-icon,
|
||||
.error-icon {
|
||||
font-size: 36px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.empty-title,
|
||||
.error-title {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 18px;
|
||||
color: var(--color-text-main);
|
||||
}
|
||||
|
||||
.empty-desc,
|
||||
.error-desc {
|
||||
font-size: 14px;
|
||||
color: var(--color-text-muted);
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slideUp {
|
||||
from {
|
||||
transform: translateY(12px);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
export type BookingStatus =
|
||||
| "RESERVED"
|
||||
| "RELEASED"
|
||||
| "CANCELLED"
|
||||
| "COMPLETED"
|
||||
| "NO_SHOW";
|
||||
|
||||
export type PaymentArrangement =
|
||||
| "PREPAID_DEFAULT"
|
||||
| "DELAYED_ALLOWED"
|
||||
| "PACKAGE_REDEEMED";
|
||||
|
||||
export type PaymentStatus =
|
||||
| "AWAITING_ACKNOWLEDGMENT"
|
||||
| "ACKNOWLEDGED"
|
||||
| "NOT_APPLICABLE";
|
||||
|
||||
export type BookingPaymentStatus = PaymentStatus;
|
||||
|
||||
export type GcalSyncStatus = "PENDING" | "SYNCED" | "FAILED" | "NOT_CONFIGURED";
|
||||
|
||||
export interface Booking {
|
||||
id: string;
|
||||
booking_code: string;
|
||||
service_id: string;
|
||||
service_name: string | null;
|
||||
client_id: string;
|
||||
client_name: string | null;
|
||||
client_phone: string | null;
|
||||
package_id: string | null;
|
||||
scheduled_at: string;
|
||||
duration_minutes: number;
|
||||
buffer_minutes: number;
|
||||
booking_status: BookingStatus;
|
||||
payment_arrangement: PaymentArrangement;
|
||||
payment_status: PaymentStatus;
|
||||
amount_mxn: number;
|
||||
needs_payment_followup: boolean;
|
||||
hours_until_session: number;
|
||||
exception_authorized_by?: string | null;
|
||||
exception_authorized_at?: string | null;
|
||||
exception_notes?: string | null;
|
||||
released_by?: string | null;
|
||||
released_at?: string | null;
|
||||
release_reason?: string | null;
|
||||
acknowledged_by?: string | null;
|
||||
acknowledged_at?: string | null;
|
||||
gcal_event_id?: string | null;
|
||||
gcal_sync_status: GcalSyncStatus;
|
||||
gcal_sync_error?: string | null;
|
||||
gcal_synced_at?: string | null;
|
||||
created_at: string;
|
||||
whatsapp_redirect_url?: string | null;
|
||||
whatsapp_followup_url?: string | null;
|
||||
}
|
||||
|
||||
export interface PaymentAcknowledgmentPayload {
|
||||
booking_id: string;
|
||||
amount_mxn: number;
|
||||
payment_method: "SPEI" | "OXXO" | "CASH";
|
||||
notes?: string | null;
|
||||
}
|
||||
|
||||
export interface PaymentRecord {
|
||||
id: string;
|
||||
booking_id: string;
|
||||
amount_mxn: number;
|
||||
payment_method: "SPEI" | "OXXO" | "CASH";
|
||||
status: "ACKNOWLEDGED" | "REVERSED";
|
||||
acknowledged_by: string;
|
||||
acknowledged_at: string;
|
||||
notes?: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
export function formatDateTime(isoStr: string): string {
|
||||
try {
|
||||
const dt = new Date(isoStr);
|
||||
if (Number.isNaN(dt.getTime())) return isoStr;
|
||||
return new Intl.DateTimeFormat("es-MX", {
|
||||
weekday: "short",
|
||||
day: "numeric",
|
||||
month: "short",
|
||||
hour: "numeric",
|
||||
minute: "2-digit",
|
||||
hour12: true,
|
||||
}).format(dt);
|
||||
} catch {
|
||||
return isoStr;
|
||||
}
|
||||
}
|
||||
|
||||
export function formatTimeOnly(isoStr: string): string {
|
||||
try {
|
||||
const dt = new Date(isoStr);
|
||||
if (Number.isNaN(dt.getTime())) return isoStr;
|
||||
return new Intl.DateTimeFormat("es-MX", {
|
||||
hour: "numeric",
|
||||
minute: "2-digit",
|
||||
hour12: true,
|
||||
}).format(dt);
|
||||
} catch {
|
||||
return isoStr;
|
||||
}
|
||||
}
|
||||
|
||||
export function formatCurrency(amount: number): string {
|
||||
return `$${amount.toLocaleString("es-MX")} MXN`;
|
||||
}
|
||||
|
||||
export function calculateInterval(
|
||||
startIso: string,
|
||||
durationMinutes: number,
|
||||
bufferMinutes: number,
|
||||
): {
|
||||
start: Date;
|
||||
end: Date;
|
||||
bufferEnd: Date;
|
||||
startStr: string;
|
||||
endStr: string;
|
||||
bufferEndStr: string;
|
||||
} {
|
||||
const start = new Date(startIso);
|
||||
const end = new Date(start.getTime() + durationMinutes * 60 * 1000);
|
||||
const bufferEnd = new Date(end.getTime() + bufferMinutes * 60 * 1000);
|
||||
|
||||
return {
|
||||
start,
|
||||
end,
|
||||
bufferEnd,
|
||||
startStr: formatTimeOnly(start.toISOString()),
|
||||
endStr: formatTimeOnly(end.toISOString()),
|
||||
bufferEndStr: formatTimeOnly(bufferEnd.toISOString()),
|
||||
};
|
||||
}
|
||||
|
||||
export function getHoursRemainingBadge(hours: number): {
|
||||
text: string;
|
||||
urgencyClass: string;
|
||||
} {
|
||||
if (hours <= 0) {
|
||||
return { text: "Sesión vencida / Hoy", urgencyClass: "badge-danger" };
|
||||
}
|
||||
if (hours <= 24) {
|
||||
return {
|
||||
text: `${Math.round(hours)}h restantes (Urgente)`,
|
||||
urgencyClass: "badge-danger",
|
||||
};
|
||||
}
|
||||
if (hours <= 48) {
|
||||
return {
|
||||
text: `${Math.round(hours)}h restantes`,
|
||||
urgencyClass: "badge-warning",
|
||||
};
|
||||
}
|
||||
return {
|
||||
text: `En ${Math.round(hours / 24)} días`,
|
||||
urgencyClass: "badge-info",
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
calculateInterval,
|
||||
formatCurrency,
|
||||
getHoursRemainingBadge,
|
||||
} from "../src/utils";
|
||||
|
||||
describe("Frontend Utilities", () => {
|
||||
it("formats MXN currency properly", () => {
|
||||
expect(formatCurrency(600)).toBe("$600 MXN");
|
||||
expect(formatCurrency(1250)).toContain("1,250");
|
||||
});
|
||||
|
||||
it("computes appointment interval with mandatory buffer block", () => {
|
||||
const startIso = "2026-10-25T10:00:00.000Z";
|
||||
const interval = calculateInterval(startIso, 60, 15);
|
||||
|
||||
expect(interval.start.getTime()).toBe(new Date(startIso).getTime());
|
||||
// 60 minutes session end
|
||||
expect(interval.end.getTime()).toBe(
|
||||
new Date(startIso).getTime() + 60 * 60 * 1000,
|
||||
);
|
||||
// 15 minutes buffer end
|
||||
expect(interval.bufferEnd.getTime()).toBe(
|
||||
new Date(startIso).getTime() + 75 * 60 * 1000,
|
||||
);
|
||||
});
|
||||
|
||||
it("returns correct urgency badges based on hours remaining", () => {
|
||||
expect(getHoursRemainingBadge(0).urgencyClass).toBe("badge-danger");
|
||||
expect(getHoursRemainingBadge(12).urgencyClass).toBe("badge-danger");
|
||||
expect(getHoursRemainingBadge(36).urgencyClass).toBe("badge-warning");
|
||||
expect(getHoursRemainingBadge(72).urgencyClass).toBe("badge-info");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": false,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"types": ["vite/client"]
|
||||
},
|
||||
"include": ["src", "tests", "vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference types="vitest/config" />
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
export default defineConfig({
|
||||
server: {
|
||||
port: 5173,
|
||||
host: "0.0.0.0",
|
||||
},
|
||||
test: {
|
||||
include: ["tests/**/*.test.ts"],
|
||||
exclude: [".direnv/**", "node_modules/**"],
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user