/** Prayer requests' shapes (backend/src/requests/*), for server and client components. */ export type RequestForm = { anonymousAllowed: boolean; emergencyNumbers: { label: string; number: string }[]; closeAfterDays: number }; export type Update = { id: string; author: "submitter" | "team"; text: string; createdAt: string }; /** GET /api/v1/requests: what members see. */ export type SharedRequest = { id: string; text: string; by: string; prayedCount: number; iPrayed: boolean; updates: Update[]; createdAt: string; mine: boolean }; export type RequestStatus = "closed" | "with_team" | "waiting" | "shared" | "not_shared"; /** GET /api/v1/me/requests: the sender's own. */ export type MyRequest = { id: string; text: string; visibility: "team" | "members"; showName: boolean; anonymous: boolean; status: RequestStatus; redactionNote: string | null; removedReason: string | null; prayedCount: number; updates: Update[]; closesAt: string; closedAt: string | null; createdAt: string; }; /** The prayer team's view. */ export type TeamRequest = MyRequest & { moderation: "none" | "pending" | "approved" | "removed"; submitter: { name: string; email: string; phone: string | null } | null; escalated: { at: string; note: string | null } | null; redacted: boolean; }; export const STATUS_NAMES: Record = { with_team: "With the prayer team", waiting: "Waiting for approval", shared: "Shared with members", not_shared: "Not shared", closed: "Closed", }; /** "3 December" from an ISO instant. */ export const shortDate = (iso: string) => new Intl.DateTimeFormat("en-ZA", { day: "numeric", month: "long" }).format(new Date(iso));