mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 13:32:06 +00:00
fix(uplifts): keep two-decimal NTE and expose required on reason fields
This commit is contained in:
parent
ba2e3e37c7
commit
305b926128
6 changed files with 18 additions and 2 deletions
|
|
@ -1,3 +1,6 @@
|
||||||
export function formatUpliftMoney(value: number): string {
|
export function formatUpliftMoney(value: number): string {
|
||||||
return `$${value.toLocaleString("en-US", { maximumFractionDigits: 2 })}`;
|
return `$${value.toLocaleString("en-US", {
|
||||||
|
minimumFractionDigits: 2,
|
||||||
|
maximumFractionDigits: 2,
|
||||||
|
})}`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ export function UpliftReasonField({
|
||||||
value={value}
|
value={value}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
|
required={required}
|
||||||
|
aria-required={required}
|
||||||
rows={3}
|
rows={3}
|
||||||
autoFocus
|
autoFocus
|
||||||
className={`${DLG_INPUT_CLS} resize-none`}
|
className={`${DLG_INPUT_CLS} resize-none`}
|
||||||
|
|
|
||||||
|
|
@ -326,6 +326,7 @@ export function UpliftDecisionDialog({
|
||||||
minRows={2}
|
minRows={2}
|
||||||
className="mt-2"
|
className="mt-2"
|
||||||
value={note}
|
value={note}
|
||||||
|
required={noteRequired}
|
||||||
onChange={(e) => onNoteChange(e.target.value)}
|
onChange={(e) => onNoteChange(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ export function UpliftDecisionDialog({
|
||||||
minRows={2}
|
minRows={2}
|
||||||
className="mt-2"
|
className="mt-2"
|
||||||
value={note}
|
value={note}
|
||||||
|
required={noteRequired}
|
||||||
onChange={(event) => setNote(event.target.value)}
|
onChange={(event) => setNote(event.target.value)}
|
||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ export function RevokeUpliftDialog({
|
||||||
multiline
|
multiline
|
||||||
minRows={2}
|
minRows={2}
|
||||||
value={reason}
|
value={reason}
|
||||||
|
required={requireReason}
|
||||||
onChange={(event) => setReason(event.target.value)}
|
onChange={(event) => setReason(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,11 @@ describe("RejectDialog", () => {
|
||||||
|
|
||||||
it("marks the reason as required with an asterisk", () => {
|
it("marks the reason as required with an asterisk", () => {
|
||||||
renderReject();
|
renderReject();
|
||||||
|
expect(screen.getByRole("heading", { name: "Reject uplift of $250.00?" })).toBeInTheDocument();
|
||||||
expectDestructiveAsterisk("Reason for rejection");
|
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", () => {
|
it("blocks cancel and escape while pending", () => {
|
||||||
|
|
@ -115,7 +119,7 @@ describe("RejectDialog", () => {
|
||||||
describe("RevokeDialog", () => {
|
describe("RevokeDialog", () => {
|
||||||
it("keeps confirm disabled until a reason is typed", () => {
|
it("keeps confirm disabled until a reason is typed", () => {
|
||||||
const { onConfirm } = renderRevoke();
|
const { onConfirm } = renderRevoke();
|
||||||
const confirm = screen.getByRole("button", { name: "Revoke $500" });
|
const confirm = screen.getByRole("button", { name: "Revoke $500.00" });
|
||||||
expect(confirm).toBeDisabled();
|
expect(confirm).toBeDisabled();
|
||||||
|
|
||||||
fireEvent.change(screen.getByLabelText(/reason for revoking/i), {
|
fireEvent.change(screen.getByLabelText(/reason for revoking/i), {
|
||||||
|
|
@ -136,6 +140,10 @@ describe("RevokeDialog", () => {
|
||||||
|
|
||||||
it("marks the reason as required with an asterisk", () => {
|
it("marks the reason as required with an asterisk", () => {
|
||||||
renderRevoke();
|
renderRevoke();
|
||||||
|
expect(screen.getByRole("button", { name: "Revoke $500.00" })).toBeInTheDocument();
|
||||||
expectDestructiveAsterisk("Reason for revoking");
|
expectDestructiveAsterisk("Reason for revoking");
|
||||||
|
const reason = screen.getByLabelText(/reason for revoking/i);
|
||||||
|
expect(reason).toBeRequired();
|
||||||
|
expect(reason).toHaveAttribute("aria-required", "true");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue