38 lines
927 B
TypeScript
38 lines
927 B
TypeScript
import type { QueryClient } from "@tanstack/react-query";
|
|
|
|
import {
|
|
apiQueryClient,
|
|
isGetUnder,
|
|
type paths,
|
|
} from "@/shared/api";
|
|
|
|
type TbankConnectionStatus
|
|
= paths["/api/v1/tbank-connection"]["get"]["responses"][200]["content"]["application/json"];
|
|
|
|
const investmentGetPredicate = isGetUnder([
|
|
"/api/v1/brokerage-accounts",
|
|
"/api/v1/stocks",
|
|
"/api/v1/bonds",
|
|
]);
|
|
|
|
const tbankConnectionQueryOptions = () =>
|
|
apiQueryClient.queryOptions("get", "/api/v1/tbank-connection");
|
|
|
|
const tbankConnectionQueryKey = tbankConnectionQueryOptions().queryKey;
|
|
|
|
function commitTbankConnectionBoundary(
|
|
queryClient: QueryClient,
|
|
status: TbankConnectionStatus,
|
|
) {
|
|
queryClient.setQueryData(tbankConnectionQueryKey, status);
|
|
void queryClient.resetQueries({
|
|
predicate: ({ queryKey }) => investmentGetPredicate(queryKey),
|
|
});
|
|
}
|
|
|
|
export {
|
|
commitTbankConnectionBoundary,
|
|
tbankConnectionQueryOptions,
|
|
type TbankConnectionStatus,
|
|
};
|