Files
frontend/src/pages/cards/ui/CardsPage/CardsPage.vm.ts
T
ksv741 e38ecd87d6
Frontend verify / commits (pull_request) Successful in 39s
Frontend verify / security (pull_request) Successful in 10s
Frontend verify / verify (pull_request) Failing after 5m50s
fix(auth,bank): guard switch-auth nav and surface banking retry
AuthForm disables the switch-auth Link while submit is pending so pointer
click and Enter can no longer leave the auth route and lose the draft/error
context. The form restores a true Link after the request settles.

CardsPage/CardPage distinguish cold vs cached banking failures:
- cold card/section errors expose accessible alert + retry
- cached failures keep the previous data and offer a section GET retry
- summary-only/history-only outages do not hide successful sections
- notFound still skips the retry CTA

Tests cover the pending link guard, cold/cached cards error with retry,
summary failure with retry, and the prerequisite card list recovery.

Closes #56, #57
2026-10-14 10:43:34 +03:00

52 lines
1.4 KiB
TypeScript

import type { ChangeEvent } from "react";
import { useState } from "react";
import { useSearchParams } from "react-router";
import {
bankPeriod,
useBankCards,
useBankCategories,
useBankSummary,
} from "@/entities/bank-card";
type CardsPageVm = ReturnType<typeof useCardsPageVm>;
function useCardsPageVm() {
const [parameters, setParameters] = useSearchParams();
const period = bankPeriod(parameters);
const [archive, setArchive] = useState(false);
const categories = useBankCategories();
const [managingCategories, setManagingCategories] = useState(false);
const [adding, setAdding] = useState(false);
const cards = useBankCards(archive);
const summary = useBankSummary(period);
return {
adding,
archive,
cards,
categories,
closeAdding: () => setAdding(false),
closeCategories: () => setManagingCategories(false),
items: cards.data?.map(card => ({
...card,
to: `/cards/${card.id}?${new URLSearchParams(period)}`,
})),
managingCategories,
onAddCard: () => setAdding(true),
onArchiveChange: (event: ChangeEvent<HTMLInputElement>) =>
setArchive(event.currentTarget.checked),
onCategories: () => setManagingCategories(true),
period,
retryCards: () => cards.refetch(),
retrySummary: () => summary.refetch(),
setPeriod: (value: [null | string, null | string]) => {
if (value[0] && value[1]) setParameters({ from: value[0], to: value[1] });
},
summary,
};
}
export { type CardsPageVm, useCardsPageVm };