fix(uplifts): keep two-decimal NTE and expose required on reason fields

This commit is contained in:
Arthur Bassi 2026-08-27 11:59:25 -03:00
parent ba2e3e37c7
commit 305b926128
6 changed files with 18 additions and 2 deletions

View file

@ -1,3 +1,6 @@
export function formatUpliftMoney(value: number): string {
return `$${value.toLocaleString("en-US", { maximumFractionDigits: 2 })}`;
return `$${value.toLocaleString("en-US", {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}`;
}

View file

@ -33,6 +33,8 @@ export function UpliftReasonField({
value={value}
disabled={disabled}
placeholder={placeholder}
required={required}
aria-required={required}
rows={3}
autoFocus
className={`${DLG_INPUT_CLS} resize-none`}

View file

@ -326,6 +326,7 @@ export function UpliftDecisionDialog({
minRows={2}
className="mt-2"
value={note}
required={noteRequired}
onChange={(e) => onNoteChange(e.target.value)}
/>
</DialogContent>

View file

@ -66,6 +66,7 @@ export function UpliftDecisionDialog({
minRows={2}
className="mt-2"
value={note}
required={noteRequired}
onChange={(event) => setNote(event.target.value)}
disabled={isPending}
/>

View file

@ -61,6 +61,7 @@ export function RevokeUpliftDialog({
multiline
minRows={2}
value={reason}
required={requireReason}
onChange={(event) => setReason(event.target.value)}
/>
</DialogContent>

View file

@ -101,7 +101,11 @@ describe("RejectDialog", () => {
it("marks the reason as required with an asterisk", () => {
renderReject();
expect(screen.getByRole("heading", { name: "Reject uplift of $250.00?" })).toBeInTheDocument();
expectDestructiveAsterisk("Reason for rejection");
const reason = screen.getByLabelText(/reason for rejection/i);
expect(reason).toBeRequired();
expect(reason).toHaveAttribute("aria-required", "true");
});
it("blocks cancel and escape while pending", () => {
@ -115,7 +119,7 @@ describe("RejectDialog", () => {
describe("RevokeDialog", () => {
it("keeps confirm disabled until a reason is typed", () => {
const { onConfirm } = renderRevoke();
const confirm = screen.getByRole("button", { name: "Revoke $500" });
const confirm = screen.getByRole("button", { name: "Revoke $500.00" });
expect(confirm).toBeDisabled();
fireEvent.change(screen.getByLabelText(/reason for revoking/i), {
@ -136,6 +140,10 @@ describe("RevokeDialog", () => {
it("marks the reason as required with an asterisk", () => {
renderRevoke();
expect(screen.getByRole("button", { name: "Revoke $500.00" })).toBeInTheDocument();
expectDestructiveAsterisk("Reason for revoking");
const reason = screen.getByLabelText(/reason for revoking/i);
expect(reason).toBeRequired();
expect(reason).toHaveAttribute("aria-required", "true");
});
});