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
@@ -0,0 +1,30 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
type BankPeriodPickerProps = {
onChange: (value: [null | string, null | string]) => void;
period: { from: string; to: string };
};
function useBankPeriodPickerVm(props: BankPeriodPickerProps) {
const { onChange, period } = props;
const { t } = useTranslation();
const scope = `${period.from}-${period.to}`;
const [draft, setDraft] = useState<{
scope: string;
value: [null | string, null | string];
}>();
const value: [null | string, null | string]
= draft?.scope === scope ? draft.value : [period.from, period.to];
const onPeriodChange = (next: [null | string, null | string]) => {
setDraft({ scope, value: next });
onChange(next);
};
return { onChange, onPeriodChange, t, value };
}
export { useBankPeriodPickerVm };