refactor: enforce frontend view model boundaries
This commit is contained in:
@@ -8,6 +8,7 @@ import { apiErrorCode } from "@/shared/api";
|
||||
function useAccountsPageViewModel() {
|
||||
const accounts = useBrokerageAccounts();
|
||||
const sync = useScreenSync({ screen: "accounts" }, [accounts]);
|
||||
|
||||
if (
|
||||
!accounts.data
|
||||
|| (accounts.meta?.availability === "partial" && accounts.data.length === 0)
|
||||
@@ -21,6 +22,7 @@ function useAccountsPageViewModel() {
|
||||
state: "error" as const,
|
||||
};
|
||||
}
|
||||
|
||||
if (!accounts.data?.length)
|
||||
return {
|
||||
lastSuccessfulAt: accounts.meta?.lastSuccessfulAt,
|
||||
@@ -30,6 +32,7 @@ function useAccountsPageViewModel() {
|
||||
sourceError: sync.sourceError,
|
||||
state: "empty" as const,
|
||||
};
|
||||
|
||||
return {
|
||||
accounts: brokerageAccountCards(accounts.data, accounts.meta?.dependencies),
|
||||
lastSuccessfulAt: accounts.meta?.lastSuccessfulAt,
|
||||
|
||||
Reference in New Issue
Block a user