refactor: clarify frontend module ownership
This commit is contained in:
@@ -9,7 +9,14 @@ import {
|
||||
type TbankConnectionStatus
|
||||
= paths["/api/v1/tbank-connection"]["get"]["responses"][200]["content"]["application/json"];
|
||||
|
||||
const brokerageAccountsPath = "/api/v1/brokerage-accounts";
|
||||
function isInvestmentPath(path: string) {
|
||||
return [
|
||||
"/api/v1/brokerage-accounts",
|
||||
"/api/v1/stocks",
|
||||
"/api/v1/bonds",
|
||||
"/api/v1/tbank-sync",
|
||||
].some(root => path === root || path.startsWith(`${root}/`));
|
||||
}
|
||||
|
||||
const tbankConnectionQueryOptions = () =>
|
||||
apiQueryClient.queryOptions("get", "/api/v1/tbank-connection");
|
||||
@@ -20,13 +27,7 @@ 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"),
|
||||
);
|
||||
invalidateApiRequests(isInvestmentPath);
|
||||
queryClient.setQueryData(tbankConnectionQueryKey, status);
|
||||
void queryClient.resetQueries({
|
||||
predicate: ({ queryKey }) => {
|
||||
@@ -35,13 +36,7 @@ function commitTbankConnectionBoundary(
|
||||
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}/`))
|
||||
&& isInvestmentPath(path)
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user