feat: Sprint 1 — staffing assign, dashboard cache, bulk ops, notifications

Staffing "Assign" Button:
- Inline assignment form on each suggestion card in StaffingPanel
- Pre-fills project, dates, hours from search criteria
- 1-click confirm creates allocation with PROPOSED status
- Success/error toasts, removes assigned suggestions from list

Dashboard Redis Caching:
- New cache utility (packages/api/src/lib/cache.ts) with get/set/invalidate
- All 5 dashboard queries wrapped with 60s TTL cache-aside pattern
- Auto-invalidation on allocation + project mutations (fire-and-forget)
- Graceful fallthrough to DB if Redis unavailable

Bulk Operations:
- CSV export for selected resources and projects (apps/web/src/lib/csv-export.ts)
- Project batch delete mutation with cascade (assignments, demands, rules)
- Export/Delete buttons added to BatchActionBar on both list pages

Budget Overrun Notifications:
- checkBudgetThresholds() alerts at 80% (HIGH) and 100% (URGENT)
- Called after every allocation mutation, duplicate-safe
- Targets ADMIN + MANAGER users with SSE delivery

Estimate Approval Reminders:
- checkPendingEstimateReminders() finds SUBMITTED versions > 3 days old
- Cron endpoint: GET /api/cron/estimate-reminders (optional CRON_SECRET auth)
- Creates in-app REMINDER notifications, duplicate-safe

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
2026-03-19 20:43:36 +01:00
parent 0d78fe1770
commit 4118995319
14 changed files with 1042 additions and 71 deletions
@@ -8,6 +8,7 @@ import { RESOURCE_COLUMNS } from "@planarchy/shared";
import { BlueprintTarget, ResourceType } from "@planarchy/shared";
import { trpc } from "~/lib/trpc/client.js";
import { formatMoney } from "~/lib/format.js";
import { generateCsv, downloadCsv } from "~/lib/csv-export.js";
import dynamic from "next/dynamic";
import { ResourceModal } from "~/components/resources/ResourceModal.js";
import { BulkEditModal } from "~/components/resources/BulkEditModal.js";
@@ -508,6 +509,22 @@ export function ResourcesClient() {
return "Departed: no";
}, [departedFilter]);
const exportSelectedCsv = useCallback(() => {
const selected = displayedResources.filter((r) => selection.selectedIds.has(r.id));
if (selected.length === 0) return;
const csv = generateCsv(selected, [
{ header: "EID", accessor: (r) => r.eid },
{ header: "Name", accessor: (r) => r.displayName },
{ header: "Email", accessor: (r) => r.email },
{ header: "Chapter", accessor: (r) => r.chapter ?? "" },
{ header: "LCR (cents)", accessor: (r) => r.lcrCents },
{ header: "Currency", accessor: (r) => r.currency },
{ header: "Chargeability Target", accessor: (r) => r.chargeabilityTarget },
{ header: "Active", accessor: (r) => r.isActive ? "Yes" : "No" },
]);
downloadCsv(csv, `resources-export-${new Date().toISOString().slice(0, 10)}.csv`);
}, [displayedResources, selection.selectedIds]);
const chips = [
...(search ? [{ label: `Search: "${search}"`, onRemove: () => setSearch("") }] : []),
...(chapterFilter.length > 0
@@ -1429,10 +1446,15 @@ export function ResourcesClient() {
count={selection.count}
onClear={selection.clear}
actions={[
{
label: "Export Selected",
variant: "default" as const,
onClick: exportSelectedCsv,
},
...(filterableFields.length > 0
? [
{
label: "Edit Custom Fields",
label: "Bulk Edit",
variant: "default" as const,
onClick: () => setModal({ type: "bulkEdit" }),
disabled: false,