From e987952a9b6300803f778dfd74e8bb1a8fc08b84 Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Mon, 12 Oct 2026 15:27:12 -0400 Subject: [PATCH] feat(awards): polish Award Automation admin view styling - Replace hand-rolled buttons with @payloadcms/ui Button (secondary dry run, primary apply) since the admin bundle has no Tailwind for shadcn - Real spacing values throughout: Payload defines no --spacing-* vars, so gaps used to collapse to zero; use px literals and var(--base) - Framed panels with theme-elevation borders, uppercase table headers, stats strip with collapsed line boxes so small caps sit evenly inside the card padding --- .../admin/awards/AwardAutomationView.tsx | 201 +++++++++++++----- 1 file changed, 151 insertions(+), 50 deletions(-) diff --git a/src/components/admin/awards/AwardAutomationView.tsx b/src/components/admin/awards/AwardAutomationView.tsx index 43128c78..5b869335 100644 --- a/src/components/admin/awards/AwardAutomationView.tsx +++ b/src/components/admin/awards/AwardAutomationView.tsx @@ -1,11 +1,16 @@ "use client"; import * as React from "react"; -import { Button } from "@/components/ui/button"; -import { Badge } from "@/components/ui/badge"; +import { Button } from "@payloadcms/ui"; import { runAwardEvaluation, applyAwardGrants } from "@/lib/awards/automationActions"; import type { EvaluationResult } from "@/lib/awards/automation"; +const panelStyle: React.CSSProperties = { + border: "1px solid var(--theme-elevation-150)", + borderRadius: "3px", + background: "var(--theme-elevation-50)", +}; + /** * Admin view (award-rules collection): preview which members currently * qualify under the active rules, then apply the grants. Both actions are @@ -40,68 +45,164 @@ export default function AwardAutomationView() { setResult(res.result); }; - return ( -
-

Award Automation

-

- Evaluate every active award rule against all members. Preview first: nothing is written - until you apply. Applying is safe to repeat, members who already hold an award are skipped. -

+ const grantCount = result ? result.plans.filter((p) => p.kind === "grant").length : 0; + const upgradeCount = result ? result.plans.filter((p) => p.kind === "upgrade").length : 0; -
- -
{error && ( -

{error}

+

+ {error} +

)} {result && ( - <> -

- {result.dryRun ? "Dry run" : "Applied"}{" "} - Rules evaluated: {result.rulesEvaluated}, members checked: {result.membersChecked},{" "} - {result.dryRun - ? `would grant ${result.plans.filter((p) => p.kind === "grant").length}, would upgrade ${result.plans.filter((p) => p.kind === "upgrade").length}` - : `granted ${result.granted}, upgraded ${result.upgraded}`} - , skipped: {result.skips.length} -

+
+
+ {[ + { label: "Mode", value: result.dryRun ? "Dry run" : "Applied" }, + { label: "Rules evaluated", value: String(result.rulesEvaluated) }, + { label: "Members checked", value: String(result.membersChecked) }, + { + label: result.dryRun ? "Would grant" : "Granted", + value: String(result.dryRun ? grantCount : result.granted), + }, + { + label: result.dryRun ? "Would upgrade" : "Upgraded", + value: String(result.dryRun ? upgradeCount : result.upgraded), + }, + { label: "Skipped", value: String(result.skips.length) }, + ].map((stat) => ( +
+ + {stat.label} + + {stat.value} +
+ ))} +
- {result.plans.length > 0 && ( - - - - - - - - - - - - {result.plans.map((plan, i) => ( - - - - - - + {result.plans.length > 0 ? ( +
+
MemberRuleAwardMetric valueAction
{plan.username}{plan.ruleLabel}{plan.awardName}{plan.metricValue.toFixed(2)} - {plan.kind === "upgrade" - ? `Upgrade (retires award #${plan.replacesAwardId})` - : "Grant"} -
+ + + {["Member", "Rule", "Award", "Metric value", "Action"].map((col) => ( + + ))} - ))} - -
+ {col} +
+ + + {result.plans.map((plan, i) => ( + + {[ + plan.username, + plan.ruleLabel, + plan.awardName, + plan.metricValue.toFixed(2), + plan.kind === "upgrade" + ? `Upgrade (retires award #${plan.replacesAwardId})` + : "Grant", + ].map((cell, j) => ( + + {cell} + + ))} + + ))} + + +
+ ) : ( +

+ No members currently qualify for anything new. +

)} - {result.plans.length === 0 &&

No members currently qualify for anything new.

} - + )} );