refactor: remove redundant page view models
Frontend verify / commits (pull_request) Successful in 29s
Frontend verify / security (pull_request) Successful in 10s
Frontend verify / verify (pull_request) Successful in 8m35s

This commit is contained in:
2026-09-28 20:34:33 +03:00
parent 94adbafa34
commit fb3a5a6eaa
10 changed files with 109 additions and 313 deletions
@@ -27,14 +27,12 @@ import {
import type { CardsPageVm } from "./CardsPage.vm";
import classes from "./CardsPage.module.css";
import { useCardsPageViewVm } from "./CardsPageView.vm";
type CardsPageViewProps = { vm: CardsPageVm };
const CardsPageViewCards: FC<CardsPageViewProps> = (props) => {
const { t } = useTranslation();
const { vm } = props;
const { onAddCard } = useCardsPageViewVm(props);
if (vm.items) {
if (vm.items.length > 0) {
@@ -59,7 +57,7 @@ const CardsPageViewCards: FC<CardsPageViewProps> = (props) => {
return (
<StateView
action={<Button onClick={onAddCard}>{t("bank.addCard")}</Button>}
action={<Button onClick={vm.onAddCard}>{t("bank.addCard")}</Button>}
text={text}
title={t("bank.empty")}
/>
@@ -80,16 +78,8 @@ const CardsPageViewCards: FC<CardsPageViewProps> = (props) => {
};
const CardsPageView: FC<CardsPageViewProps> = (props) => {
const {
onAddCard,
onArchiveChange,
onCategories,
retryCards,
retryCategories,
retrySummary,
t,
vm,
} = useCardsPageViewVm(props);
const { vm } = props;
const { t } = useTranslation();
return (
<Stack gap="lg">
@@ -98,7 +88,7 @@ const CardsPageView: FC<CardsPageViewProps> = (props) => {
<ActionIcon
aria-label={t("bank.addCard")}
onClick={onAddCard}
onClick={vm.onAddCard}
size="lg"
title={t("bank.addCard")}
variant="light"
@@ -110,7 +100,7 @@ const CardsPageView: FC<CardsPageViewProps> = (props) => {
<Switch
checked={vm.archive}
label={t("bank.showArchive")}
onChange={onArchiveChange}
onChange={vm.onArchiveChange}
/>
<CardsPageViewCards {...props} />
@@ -119,7 +109,7 @@ const CardsPageView: FC<CardsPageViewProps> = (props) => {
<Group role="alert">
<Text>{t(vm.items ? "bank.refreshError" : "bank.error")}</Text>
<Button onClick={retryCards} variant="default">
<Button onClick={vm.retryCards} variant="default">
{t("bank.retry")}
</Button>
</Group>
@@ -134,7 +124,7 @@ const CardsPageView: FC<CardsPageViewProps> = (props) => {
<Button
color="gray"
leftSection={<CategoriesIcon size={18} strokeWidth="1.7" />}
onClick={onCategories}
onClick={vm.onCategories}
variant="subtle"
>
{t("bank.categories")}
@@ -148,7 +138,7 @@ const CardsPageView: FC<CardsPageViewProps> = (props) => {
error={vm.summary.isError}
fetching={vm.summary.isFetching}
loading={vm.summary.isLoading}
retry={retrySummary}
retry={vm.retrySummary}
/>
{vm.categories.isError && (
@@ -156,7 +146,7 @@ const CardsPageView: FC<CardsPageViewProps> = (props) => {
cached={Boolean(vm.categories.data)}
error={vm.categories.error}
loadingError
retry={retryCategories}
retry={vm.retryCategories}
/>
)}
</Stack>