Frontend security / security (push) Successful in 9s
Frontend verify / verify (push) Failing after 37m50s
Frontend security / security (pull_request) Successful in 9s
Frontend verify / verify (pull_request) Failing after 42m10s
Conventional commits / commits (pull_request) Successful in 29s
Enable every plugin recommended preset and replace Biome with ESLint formatting. Preserve API contracts and JSX whitespace; verify source, tests, builds and tooling.
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import type { QueryClient } from "@tanstack/react-query";
|
|
|
|
import {
|
|
apiQueryClient,
|
|
invalidateApiRequests,
|
|
type paths,
|
|
} from "@/shared/api";
|
|
|
|
type TbankConnectionStatus
|
|
= paths["/api/v1/tbank-connection"]["get"]["responses"][200]["content"]["application/json"];
|
|
|
|
const brokerageAccountsPath = "/api/v1/brokerage-accounts";
|
|
|
|
const tbankConnectionQueryOptions = () =>
|
|
apiQueryClient.queryOptions("get", "/api/v1/tbank-connection");
|
|
|
|
const tbankConnectionQueryKey = tbankConnectionQueryOptions().queryKey;
|
|
|
|
function commitTbankConnectionBoundary(
|
|
queryClient: QueryClient,
|
|
status: TbankConnectionStatus,
|
|
) {
|
|
invalidateApiRequests(
|
|
path =>
|
|
path.startsWith("/api/v1/brokerage-accounts")
|
|
|| path.startsWith("/api/v1/stocks")
|
|
|| path.startsWith("/api/v1/bonds")
|
|
|| path.startsWith("/api/v1/tbank-sync"),
|
|
);
|
|
queryClient.setQueryData(tbankConnectionQueryKey, status);
|
|
void queryClient.resetQueries({
|
|
predicate: ({ queryKey }) => {
|
|
const [method, path] = queryKey;
|
|
return (
|
|
method === "get"
|
|
&& typeof path === "string"
|
|
&& (path.startsWith("/api/v1/tbank-sync")
|
|
|| path === "/api/v1/bonds"
|
|
|| path.startsWith("/api/v1/bonds/")
|
|
|| path === "/api/v1/stocks"
|
|
|| path.startsWith("/api/v1/stocks/")
|
|
|| path === brokerageAccountsPath
|
|
|| path.startsWith(`${brokerageAccountsPath}/`))
|
|
);
|
|
},
|
|
});
|
|
}
|
|
|
|
export {
|
|
commitTbankConnectionBoundary,
|
|
tbankConnectionQueryOptions,
|
|
type TbankConnectionStatus,
|
|
};
|