"use client";
import Link from "next/link";
import { useMemo } from "react";
import { useDerived, useSnap } from "@/lib/client";
import { Panel } from "@/components/portal";
import { monthEndView } from "@/lib/today";
const ACCENT = "var(--color-accent-700)";
type Box = "open" | "flag" | "done" | "wait";
function Row({ box, first, children, state }: { box: Box; first?: boolean; children: React.ReactNode; state: React.ReactNode }) {
const border = box === "flag" ? "#ec3013" : box === "wait" ? "#b5b1af" : "#201e1d";
return (
{children}
{state}
);
}
export default function MonthEndPanel() {
const { s } = useSnap();
const { L, byId, staffById } = useDerived();
const m = useMemo(() => monthEndView(s, L, byId, staffById), [s, L, byId, staffById]);
return (
{m.daysLeft} day{m.daysLeft === 1 ? "" : "s"} left}
foot={Month-end pack}
>
0 ? "flag" : "done"}
state={m.deliveriesOverdue > 0 ? {m.deliveriesOverdue} overdue : "done"}>
Deliveries booked in
{m.stocktakeFiled ? "Stock take filed" : Stock take filed}
{m.unsignedReceipts > 0 && (
Chase}>
{m.unsignedReceipts} receipt{m.unsignedReceipts === 1 ? "" : "s"} to sign
)}
0 ? {m.unallocated} unallocated
: "after the count"}>
Journal ready
);
}