chore: finish frontend ESLint migration #18
Enable every plugin recommended preset and replace Biome with ESLint formatting. Preserve API contracts and JSX whitespace; verify source, tests, builds and tooling.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { apiClient, apiErrorCode } from "@/shared/api";
|
||||
|
||||
import type {
|
||||
CreateBankCard,
|
||||
CreateBankOperation,
|
||||
@@ -22,59 +24,61 @@ function useBankMutations() {
|
||||
const queryClient = useQueryClient();
|
||||
const invalidate = () =>
|
||||
queryClient.invalidateQueries({
|
||||
predicate: ({ queryKey: [method, path] }) =>
|
||||
method === "get" &&
|
||||
typeof path === "string" &&
|
||||
(path === "/api/v1/bank-cards" ||
|
||||
path.startsWith("/api/v1/bank-cards/")),
|
||||
predicate: ({ queryKey }) => {
|
||||
const [method, path] = queryKey;
|
||||
return method === "get"
|
||||
&& typeof path === "string"
|
||||
&& (path === "/api/v1/bank-cards"
|
||||
|| path.startsWith("/api/v1/bank-cards/"));
|
||||
},
|
||||
});
|
||||
const options = {
|
||||
retry: false,
|
||||
onSuccess: invalidate,
|
||||
onError: (error: unknown) => {
|
||||
if (
|
||||
[
|
||||
"BANK_VERSION_CONFLICT",
|
||||
"BANK_WRITE_CONFLICT",
|
||||
"BANK_DEPENDENT_REFUNDS",
|
||||
"BANK_INTENT_CONFLICT",
|
||||
"BANK_REFUND_LIMIT",
|
||||
"BANK_DEPENDENT_REFUNDS",
|
||||
"BANK_VERSION_CONFLICT",
|
||||
"BANK_WRITE_CONFLICT",
|
||||
].includes(apiErrorCode(error) ?? "")
|
||||
)
|
||||
return invalidate();
|
||||
},
|
||||
onSuccess: invalidate,
|
||||
retry: false,
|
||||
} as const;
|
||||
const createCard = useMutation({
|
||||
const cardCreation = useMutation({
|
||||
...options,
|
||||
mutationFn: (body: CreateBankCard) =>
|
||||
mutationData(apiClient.POST("/api/v1/bank-cards", { body })),
|
||||
});
|
||||
const updateCard = useMutation({
|
||||
...options,
|
||||
mutationFn: ({ id, body }: { id: string; body: UpdateBankCard }) =>
|
||||
mutationFn: ({ body, id }: { body: UpdateBankCard; id: string }) =>
|
||||
mutationData(
|
||||
apiClient.PATCH("/api/v1/bank-cards/{id}", {
|
||||
params: { path: { id } },
|
||||
body,
|
||||
params: { path: { id } },
|
||||
}),
|
||||
),
|
||||
});
|
||||
const createOperation = useMutation({
|
||||
const operationCreation = useMutation({
|
||||
...options,
|
||||
mutationFn: (body: CreateBankOperation) =>
|
||||
mutationData(apiClient.POST("/api/v1/bank-cards/operations", { body })),
|
||||
});
|
||||
const updateOperation = useMutation({
|
||||
...options,
|
||||
mutationFn: ({ id, body }: { id: string; body: UpdateBankOperation }) =>
|
||||
mutationFn: ({ body, id }: { body: UpdateBankOperation; id: string }) =>
|
||||
mutationData(
|
||||
apiClient.PATCH("/api/v1/bank-cards/operations/{id}", {
|
||||
params: { path: { id } },
|
||||
body,
|
||||
params: { path: { id } },
|
||||
}),
|
||||
),
|
||||
});
|
||||
const deleteOperation = useMutation({
|
||||
const operationDeletion = useMutation({
|
||||
...options,
|
||||
mutationFn: ({ id, version }: { id: string; version: number }) =>
|
||||
mutationData(
|
||||
@@ -83,29 +87,29 @@ function useBankMutations() {
|
||||
}),
|
||||
),
|
||||
});
|
||||
const createCategory = useMutation({
|
||||
const categoryCreation = useMutation({
|
||||
...options,
|
||||
mutationFn: (body: CreateExpenseCategory) =>
|
||||
mutationData(apiClient.POST("/api/v1/bank-cards/categories", { body })),
|
||||
});
|
||||
const updateCategory = useMutation({
|
||||
...options,
|
||||
mutationFn: ({ id, body }: { id: string; body: UpdateExpenseCategory }) =>
|
||||
mutationFn: ({ body, id }: { body: UpdateExpenseCategory; id: string }) =>
|
||||
mutationData(
|
||||
apiClient.PATCH("/api/v1/bank-cards/categories/{id}", {
|
||||
params: { path: { id } },
|
||||
body,
|
||||
params: { path: { id } },
|
||||
}),
|
||||
),
|
||||
});
|
||||
return {
|
||||
createCard,
|
||||
createCard: cardCreation,
|
||||
createCategory: categoryCreation,
|
||||
createOperation: operationCreation,
|
||||
deleteOperation: operationDeletion,
|
||||
updateCard,
|
||||
createOperation,
|
||||
updateOperation,
|
||||
deleteOperation,
|
||||
createCategory,
|
||||
updateCategory,
|
||||
updateOperation,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user