refactor DocReviewAlertButton and FreightDashboardHeader comments for clarity and accuracy

This commit is contained in:
Marshal
2026-07-27 05:07:09 +00:00
parent bcf25538b6
commit 773456c256
2 changed files with 24 additions and 12 deletions

View File

@@ -116,8 +116,8 @@ const FreightDashboardHeader = ({
</Group>
{/* Right: actions + avatar. The doc-review alarm leads the group — it
only renders in the last half of a review phase that still has
undecided requests, so it never competes for space otherwise. */}
renders only during a review phase that still has undecided
requests, so it never competes for space otherwise. */}
<Group gap={10} wrap="nowrap" align="center">
<DocReviewAlertButton />

View File

@@ -36,11 +36,12 @@ function formatRemaining(ms: number): string {
}
/**
* Header alarm for the document-review deadline. Appears only once the review
* phase is half spent AND requests are still undecided — everything still
* pending when the clock runs out is expired automatically, so this is the last
* call to accept or reject. Clicking opens the booking requests already
* filtered to those undecided import requests.
* Header alarm for the document-review deadline. Runs for the whole review
* phase — from the moment it opens until the clock runs out — whenever requests
* are still undecided. Everything left pending at the deadline is expired
* automatically, so staff get the full window to accept or reject rather than
* only its back half. Clicking opens the booking requests already filtered to
* those undecided requests.
*/
export default function DocReviewAlertButton() {
const navigate = useNavigate();
@@ -67,10 +68,12 @@ export default function DocReviewAlertButton() {
}, [deadlineMs]);
if (!alert) return null;
// Half the review phase has to be gone before staff are alarmed — a 30-minute
// review warns with 15 minutes left.
const halfMs = (Math.max(alert.docReviewMinutes, 1) * 60_000) / 2;
if (remaining <= 0 || remaining > halfMs) return null;
// Alarm for the WHOLE review phase, from the moment it opens: anything still
// undecided when the clock runs out is expired automatically, so staff need
// the full window to act, not the back half of it. The endpoint only returns
// a schedule that is in DOC_REVIEW with undecided requests behind it, so the
// remaining check just hides the pill once the deadline passes.
if (remaining <= 0) return null;
const requestLabel = alert.pendingCount === 1 ? "request" : "requests";
@@ -85,7 +88,16 @@ export default function DocReviewAlertButton() {
<UnstyledButton
onClick={() => navigate(pendingRequestsHref(alert.tradeDirection))}
aria-label={`${alert.pendingCount} import booking ${requestLabel} awaiting a decision — document review ends in ${formatRemaining(remaining)}`}
className="group flex h-9 shrink-0 items-center gap-2 rounded-full border border-red-600/60 bg-red-600 pl-2.5 pr-2 text-white shadow-[0_2px_10px_rgba(220,38,38,0.35)] transition-transform hover:scale-[1.02] hover:bg-red-700"
className="group flex h-9 shrink-0 items-center gap-2 rounded-full pl-2.5 pr-2 transition-transform hover:scale-[1.02]"
// Inline, not Tailwind: Mantine's UnstyledButton resets the background
// in unlayered CSS, which beats a `@layer utilities` class whatever its
// specificity — `bg-red-600` alone renders the pill white.
style={{
background: "var(--mantine-color-red-6)",
border: "1px solid var(--mantine-color-red-7)",
color: "#fff",
boxShadow: "0 2px 10px rgba(220, 38, 38, 0.35)",
}}
>
{/* Live dot: a ping ring behind a solid core, so the pill reads as
active without animating the whole chip. */}