refactor: enforce frontend view model boundaries
Frontend verify / commits (pull_request) Successful in 28s
Frontend verify / security (pull_request) Successful in 10s
Frontend verify / verify (pull_request) Successful in 8m19s

This commit is contained in:
2026-09-28 18:48:23 +03:00
parent 5b69003516
commit ca0ad4f824
287 changed files with 8558 additions and 4538 deletions
@@ -9,9 +9,11 @@ import type { OperationValues } from "./OperationForm.types";
import { OperationFormView } from "./OperationForm.view";
type ExampleProps = { conflict?: boolean; pending?: boolean };
const OperationExample: FC<ExampleProps> = (props) => {
const [opened, setOpened] = useState(true);
const [action, setAction] = useState("");
const methods = useForm<OperationValues>({
defaultValues: {
amount: "500",
@@ -24,7 +26,9 @@ const OperationExample: FC<ExampleProps> = (props) => {
targetCardId: "",
},
});
const kind = useWatch({ control: methods.control, name: "kind" });
return (
<FormProvider {...methods}>
<OperationFormView
@@ -52,12 +56,12 @@ const OperationExample: FC<ExampleProps> = (props) => {
validDate: value => value === "2026-08-01",
}}
latest={
(props.conflict)
? ({
props.conflict
? {
details: "Учебная версия",
onAdopt: () => setAction("Локальное принятие версии"),
version: 2,
})
}
: undefined
}
loadingExpenses={false}
@@ -69,7 +73,7 @@ const OperationExample: FC<ExampleProps> = (props) => {
onNext={() => {}}
onPrevious={() => {}}
onReload={
(props.conflict) ? () => setAction("Локальный reload") : undefined
props.conflict ? () => setAction("Локальный reload") : undefined
}
onSubmit={(event) => {
event.preventDefault();
@@ -92,10 +96,12 @@ const OperationExample: FC<ExampleProps> = (props) => {
saveDisabled={false}
sourcePage={1}
/>
<output aria-live="polite">{action}</output>
</FormProvider>
);
};
const meta = {
component: OperationExample,
parameters: {
@@ -109,8 +115,11 @@ const meta = {
tags: ["autodocs"],
title: "Product/OperationForm",
} satisfies Meta<typeof OperationExample>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Refund: Story = {};
export const Pending: Story = { args: { pending: true } };
export const Conflict: Story = { args: { conflict: true } };