import Link from "next/link"; import { ActionButton } from "@/components/ActionButton"; import { apiGet } from "@/lib/server-api"; import { badgeClass, fmtClock, fmtDay, notificationStatusLabel } from "@/lib/format"; import type { Me, Notification } from "@/lib/types"; type Search = Promise>; export default async function NotificationsPage({ searchParams }: { searchParams: Search }) { const sp = await searchParams; const params = new URLSearchParams(); for (const key of ["day", "status", "type", "user_id"]) { const v = sp[key]; if (typeof v === "string" && v) params.set(key, v); } const [{ notifications }, me] = await Promise.all([ apiGet<{ notifications: Notification[] }>(`/notifications?${params}`), apiGet("/auth/me"), ]); const canEdit = me.account.role !== "viewer"; const value = (key: string) => (typeof sp[key] === "string" ? (sp[key] as string) : ""); return ( <>

Lembretes

{value("user_id") && } Limpar

expirado = chegou tarde demais (mais de 10 min de atraso) e não foi enviado;{" "} falhou = erro no envio pelo Telegram. Só lembretes com falha do dia atual podem ser reenviados.

{canEdit && } {notifications.length === 0 && ( )} {notifications.map((n) => ( {canEdit && ( )} ))}
Dia Usuário Tipo Aviso Previsto Status Detalhe
Nenhum lembrete encontrado.
{fmtDay(n.reference_date)} {n.user_name} {n.type === "entrada2" ? "retorno" : "saída"} {fmtClock(n.scheduled_at)} {fmtClock(n.predicted_at)} {notificationStatusLabel[n.status]} {n.error_message ?? (n.sent_at ? `enviado às ${fmtClock(n.sent_at)}` : "")} {n.status === "scheduled" && ( )} {n.status === "failed" && ( )}
); }