refactor: tighten types and reuse instrument UI
This commit is contained in:
@@ -403,7 +403,7 @@ describe("banking API", () => {
|
||||
);
|
||||
|
||||
await waitFor(() =>
|
||||
expect(result.current.categories.data?.[0].name).toBe("Food"),
|
||||
expect(result.current.categories.data?.[0]?.name).toBe("Food"),
|
||||
);
|
||||
await act(() =>
|
||||
result.current.updateCategory.mutateAsync({
|
||||
@@ -412,7 +412,7 @@ describe("banking API", () => {
|
||||
}),
|
||||
);
|
||||
await waitFor(() =>
|
||||
expect(result.current.categories.data?.[0].name).toBe("Groceries"),
|
||||
expect(result.current.categories.data?.[0]?.name).toBe("Groceries"),
|
||||
);
|
||||
await act(() =>
|
||||
result.current.updateOperation.mutateAsync({
|
||||
|
||||
@@ -46,16 +46,16 @@ function useBankMutationOptions() {
|
||||
return {
|
||||
onError: (error: unknown) => {
|
||||
const errorCode = apiErrorCode(error);
|
||||
if (
|
||||
[
|
||||
ApiErrorCode.BankDependentRefunds,
|
||||
ApiErrorCode.BankIntentConflict,
|
||||
ApiErrorCode.BankRefundLimit,
|
||||
ApiErrorCode.BankVersionConflict,
|
||||
ApiErrorCode.BankWriteConflict,
|
||||
].some(code => isApiErrorCode(errorCode, code))
|
||||
)
|
||||
return invalidate();
|
||||
|
||||
return [
|
||||
ApiErrorCode.BankDependentRefunds,
|
||||
ApiErrorCode.BankIntentConflict,
|
||||
ApiErrorCode.BankRefundLimit,
|
||||
ApiErrorCode.BankVersionConflict,
|
||||
ApiErrorCode.BankWriteConflict,
|
||||
].some(code => isApiErrorCode(errorCode, code))
|
||||
? invalidate()
|
||||
: undefined;
|
||||
},
|
||||
onSuccess: invalidate,
|
||||
retry: false,
|
||||
|
||||
@@ -143,7 +143,7 @@ function useBankOperations(
|
||||
|
||||
return !isAll
|
||||
&& previousQuery?.queryKey.length === options.queryKey.length
|
||||
&& previous?.path?.id === id
|
||||
&& previous?.path.id === id
|
||||
&& previous?.query?.month === query.month
|
||||
&& previous?.query?.from === query.from
|
||||
&& previous?.query?.to === query.to
|
||||
@@ -165,6 +165,7 @@ function useBankOperations(
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/only-throw-error -- Preserve generated ProblemDetails for apiErrorCode and field-error consumers.
|
||||
if (error) throw error;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- An empty HTTP body can violate the generated response contract.
|
||||
if (!data) throw new Error("Missing bank operations response");
|
||||
if (!isAll) return data;
|
||||
items.push(...data.items);
|
||||
|
||||
Reference in New Issue
Block a user