MCPcopy Create free account
hub / github.com/dailydotdev/apps / useTransactionError

Function useTransactionError

packages/shared/src/hooks/useTransactionError.ts:13–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11import { useToastNotification } from './useToastNotification';
12
13export const useTransactionError = () => {
14 const { displayToast } = useToastNotification();
15 const { updateUser } = useAuthContext();
16
17 return async (data: ApiErrorResult) => {
18 if (
19 data.response.errors?.[0]?.extensions?.code ===
20 ApiError.BalanceTransactionError
21 ) {
22 const errorExtensions = data.response
23 .errors[0] as ApiResponseError<ApiUserTransactionErrorExtension>;
24
25 if (
26 errorExtensions.extensions.status ===
27 UserTransactionStatus.InsufficientFunds &&
28 errorExtensions.extensions.balance
29 ) {
30 await updateUser({
31 ...user,
32 balance: errorExtensions.extensions.balance,
33 });
34 }
35 }
36
37 displayToast(data?.response?.errors?.[0]?.message || labels.error.generic);
38 };
39};

Callers 2

CommentScreenFunction · 0.90
useCampaignMutationFunction · 0.90

Calls 3

useToastNotificationFunction · 0.90
useAuthContextFunction · 0.90
displayToastFunction · 0.85

Tested by

no test coverage detected