feat: show a live example number for active number-format rules
Admins configuring the honey-batch/bottling auto-numbering format
(WH-{YYYY}-{SEQ:4}) had no way to see what it would actually produce
before saving - a typo'd placeholder or unexpected format silently
breaks every batch number from then on. When the rule is active, the
format card now renders the next number it would generate, live as
the format is edited, using the same formatGeneratedNumber logic the
backend uses (ported to the frontend, no shared package between the
two apps) and the real next sequence value (sequenceValue + 1).
Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
1 parent
1dddc387ba
commit
1c16db114e
2 files changed
+29
No files matched your search
@@ -9,6 +9,7 @@ import {
|
||||
updateAutomationRule,
|
||||
} from "@/lib/automation/api";
|
||||
import { AutomationRule, AutomationTriggerType } from "@/lib/automation/types";
|
||||
import { formatGeneratedNumber } from "@/lib/automation/number-format";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
@@ -130,6 +131,14 @@ function RuleCard({ rule }: { rule: AutomationRule }) {
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Aktueller Zähler: {rule.sequenceValue}
|
||||
</p>
|
||||
{rule.active ? (
|
||||
<p className="text-sm font-medium">
|
||||
Beispiel für die nächste Nummer:{" "}
|
||||
<span className="font-mono">
|
||||
{formatGeneratedNumber(format, rule.sequenceValue + 1, new Date())}
|
||||
</span>
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col gap-2">
|
||||
|
||||
Reference in new issue
Block a user