refactor: enforce enum machine codes #18
Use owner enums for known codes; preserve wire values and unknown fallbacks. Verified npm ci and verify: 379 tests, 5 lint checks, app and Storybook builds.
This commit was merged in pull request #41.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { apiClient, apiErrorCode } from "@/shared/api";
|
||||
import { apiClient, ApiErrorCode, apiErrorCode, isApiErrorCode } from "@/shared/api";
|
||||
|
||||
import type {
|
||||
CreateBankCard,
|
||||
@@ -34,14 +34,15 @@ function useBankMutations() {
|
||||
});
|
||||
const options = {
|
||||
onError: (error: unknown) => {
|
||||
const errorCode = apiErrorCode(error);
|
||||
if (
|
||||
[
|
||||
"BANK_DEPENDENT_REFUNDS",
|
||||
"BANK_INTENT_CONFLICT",
|
||||
"BANK_REFUND_LIMIT",
|
||||
"BANK_VERSION_CONFLICT",
|
||||
"BANK_WRITE_CONFLICT",
|
||||
].includes(apiErrorCode(error) ?? "")
|
||||
ApiErrorCode.BankDependentRefunds,
|
||||
ApiErrorCode.BankIntentConflict,
|
||||
ApiErrorCode.BankRefundLimit,
|
||||
ApiErrorCode.BankVersionConflict,
|
||||
ApiErrorCode.BankWriteConflict,
|
||||
].some(code => isApiErrorCode(errorCode, code))
|
||||
)
|
||||
return invalidate();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user