refactor(stock-quick-draft): useState lazy init, sr-only title, trim mock stubs
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
parent
2d4d0df6d1
commit
cdbf91526f
2 changed files with 3 additions and 9 deletions
|
|
@ -9,9 +9,6 @@ vi.mock("@/components/ui/modal-shell", () => ({
|
|||
ModalShell: {
|
||||
Dialog: ({ children, open }: { children: React.ReactNode; open: boolean }) =>
|
||||
open ? <div data-testid="modal">{children}</div> : null,
|
||||
Header: ({ children }: { children: React.ReactNode }) => <div data-testid="modal-header">{children}</div>,
|
||||
Body: ({ children }: { children: React.ReactNode }) => <div data-testid="modal-body">{children}</div>,
|
||||
Footer: ({ children }: { children: React.ReactNode }) => <div data-testid="modal-footer">{children}</div>,
|
||||
},
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { useState } from "react";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { ModalShell } from "@/components/ui/modal-shell";
|
||||
|
||||
|
|
@ -34,11 +34,8 @@ function formatMonthYear(date: Date): string {
|
|||
}
|
||||
|
||||
export function QuickDraftModal({ open, onOpenChange }: QuickDraftModalProps) {
|
||||
const defaultReference = useMemo(
|
||||
const [defaultReference] = useState(
|
||||
() => `Stock order entry — ${formatMonthYear(new Date())}`,
|
||||
// intentionally only computed once per mount
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[],
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
@ -47,7 +44,7 @@ export function QuickDraftModal({ open, onOpenChange }: QuickDraftModalProps) {
|
|||
onOpenChange={onOpenChange}
|
||||
size="xl"
|
||||
eyebrow="Stock Order Reference"
|
||||
title=""
|
||||
title={<span className="sr-only">Stock Order Reference</span>}
|
||||
footer={<div data-testid="region-footer" hidden />}
|
||||
>
|
||||
<div className="space-y-1.5">
|
||||
|
|
|
|||
Loading…
Reference in a new issue