diff options
Diffstat (limited to 'packages/merchant-backoffice-ui/src')
9 files changed, 28 insertions, 26 deletions
diff --git a/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx b/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx index 9c50dfe43..cb4abdd40 100644 --- a/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx +++ b/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx @@ -169,14 +169,14 @@ export function InstanceRoutes({ if (error.type === ErrorType.TIMEOUT) { setGlobalNotification({ message: i18n.str`The request to the backend take too long and was cancelled`, - description: i18n.str`Diagnostic from ${error.info?.url} is "${error.message}"`, + description: i18n.str`Diagnostic from ${error.info.url} is "${error.message}"`, type: "ERROR", to, }); } else { setGlobalNotification({ message: i18n.str`The backend reported a problem: HTTP status #${error.status}`, - description: i18n.str`Diagnostic from ${error.info?.url} is '${error.message}'`, + description: i18n.str`Diagnostic from ${error.info.url} is '${error.message}'`, details: error.type === ErrorType.CLIENT || error.type === ErrorType.SERVER ? error.payload.detail @@ -601,12 +601,12 @@ function AdminInstanceUpdatePage({ error.type === ErrorType.TIMEOUT ? { message: i18n.str`The request to the backend take too long and was cancelled`, - description: i18n.str`Diagnostic from ${error.info?.url} is '${error.message}'`, + description: i18n.str`Diagnostic from ${error.info.url} is '${error.message}'`, type: "ERROR" as const, } : { message: i18n.str`The backend reported a problem: HTTP status #${error.status}`, - description: i18n.str`Diagnostic from ${error.info?.url} is '${error.message}'`, + description: i18n.str`Diagnostic from ${error.info.url} is '${error.message}'`, details: error.type === ErrorType.CLIENT || error.type === ErrorType.SERVER diff --git a/packages/merchant-backoffice-ui/src/hooks/backend.ts b/packages/merchant-backoffice-ui/src/hooks/backend.ts index 3610e0494..90fd320a9 100644 --- a/packages/merchant-backoffice-ui/src/hooks/backend.ts +++ b/packages/merchant-backoffice-ui/src/hooks/backend.ts @@ -70,7 +70,9 @@ export function useBackendInstancesTestForAdmin(): HttpResponse< useEffect(() => { request<Type>(`/management/instances`) .then((data) => setResult(data)) - .catch((error) => setResult(error)); + .catch((error: RequestError<MerchantBackend.ErrorDetail>) => + setResult(error.cause), + ); }, [request]); return result; @@ -78,14 +80,14 @@ export function useBackendInstancesTestForAdmin(): HttpResponse< export function useBackendConfig(): HttpResponse< MerchantBackend.VersionResponse, - MerchantBackend.ErrorDetail + RequestError<MerchantBackend.ErrorDetail> > { const { request } = useBackendBaseRequest(); type Type = MerchantBackend.VersionResponse; const [result, setResult] = useState< - HttpResponse<Type, MerchantBackend.ErrorDetail> + HttpResponse<Type, RequestError<MerchantBackend.ErrorDetail>> >({ loading: true }); useEffect(() => { diff --git a/packages/merchant-backoffice-ui/src/hooks/instance.ts b/packages/merchant-backoffice-ui/src/hooks/instance.ts index 8a882218b..eae65d64c 100644 --- a/packages/merchant-backoffice-ui/src/hooks/instance.ts +++ b/packages/merchant-backoffice-ui/src/hooks/instance.ts @@ -205,7 +205,7 @@ export function useInstanceDetails(): HttpResponse< if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } @@ -240,7 +240,7 @@ export function useInstanceKYCDetails(): HttpResponse< return { ok: true, data: { type: "redirect", status: data.data } }; return { ok: true, data: { type: "ok" } }; } - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } @@ -268,7 +268,7 @@ export function useManagedInstanceDetails( if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } @@ -285,6 +285,6 @@ export function useBackendInstances(): HttpResponse< if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } diff --git a/packages/merchant-backoffice-ui/src/hooks/order.ts b/packages/merchant-backoffice-ui/src/hooks/order.ts index a42d05966..e7a893f2c 100644 --- a/packages/merchant-backoffice-ui/src/hooks/order.ts +++ b/packages/merchant-backoffice-ui/src/hooks/order.ts @@ -150,7 +150,7 @@ export function useOrderDetails( if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } @@ -237,8 +237,8 @@ export function useInstanceOrders( if (beforeData) setLastBefore(beforeData); }, [afterData, beforeData]); - if (beforeError) return beforeError.info; - if (afterError) return afterError.info; + if (beforeError) return beforeError.cause; + if (afterError) return afterError.cause; // if the query returns less that we ask, then we have reach the end or beginning const isReachingEnd = afterData && afterData.data.orders.length < totalAfter; diff --git a/packages/merchant-backoffice-ui/src/hooks/product.ts b/packages/merchant-backoffice-ui/src/hooks/product.ts index d51e8de55..8ecaefaa6 100644 --- a/packages/merchant-backoffice-ui/src/hooks/product.ts +++ b/packages/merchant-backoffice-ui/src/hooks/product.ts @@ -122,8 +122,8 @@ export function useInstanceProducts(): HttpResponse< refreshWhenOffline: false, }); - if (listError) return listError.info; - if (productError) return productError.info; + if (listError) return listError.cause; + if (productError) return productError.cause; if (products) { const dataWithId = products.map((d) => { @@ -159,6 +159,6 @@ export function useProductDetails( if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } diff --git a/packages/merchant-backoffice-ui/src/hooks/reserves.ts b/packages/merchant-backoffice-ui/src/hooks/reserves.ts index edcce29cf..bb55b2474 100644 --- a/packages/merchant-backoffice-ui/src/hooks/reserves.ts +++ b/packages/merchant-backoffice-ui/src/hooks/reserves.ts @@ -129,7 +129,7 @@ export function useInstanceReserves(): HttpResponse< if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } @@ -154,7 +154,7 @@ export function useReserveDetails( if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } @@ -176,6 +176,6 @@ export function useTipDetails( if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } diff --git a/packages/merchant-backoffice-ui/src/hooks/templates.ts b/packages/merchant-backoffice-ui/src/hooks/templates.ts index 39a106537..56cdd3046 100644 --- a/packages/merchant-backoffice-ui/src/hooks/templates.ts +++ b/packages/merchant-backoffice-ui/src/hooks/templates.ts @@ -170,7 +170,7 @@ export function useInstanceTemplates( }, [afterData /*, beforeData*/]); // if (beforeError) return beforeError; - if (afterError) return afterError.info; + if (afterError) return afterError.cause; // if the query returns less that we ask, then we have reach the end or beginning const isReachingEnd = @@ -247,6 +247,6 @@ export function useTemplateDetails( if (data) { return data; } - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } diff --git a/packages/merchant-backoffice-ui/src/hooks/transfer.ts b/packages/merchant-backoffice-ui/src/hooks/transfer.ts index d3266e57c..27c3bdc75 100644 --- a/packages/merchant-backoffice-ui/src/hooks/transfer.ts +++ b/packages/merchant-backoffice-ui/src/hooks/transfer.ts @@ -133,8 +133,8 @@ export function useInstanceTransfers( if (beforeData) setLastBefore(beforeData); }, [afterData, beforeData]); - if (beforeError) return beforeError.info; - if (afterError) return afterError.info; + if (beforeError) return beforeError.cause; + if (afterError) return afterError.cause; // if the query returns less that we ask, then we have reach the end or beginning const isReachingEnd = diff --git a/packages/merchant-backoffice-ui/src/hooks/webhooks.ts b/packages/merchant-backoffice-ui/src/hooks/webhooks.ts index 7a8043441..c91fff8b4 100644 --- a/packages/merchant-backoffice-ui/src/hooks/webhooks.ts +++ b/packages/merchant-backoffice-ui/src/hooks/webhooks.ts @@ -116,7 +116,7 @@ export function useInstanceWebhooks( if (afterData) setLastAfter(afterData); }, [afterData]); - if (afterError) return afterError.info; + if (afterError) return afterError.cause; const isReachingEnd = afterData && afterData.data.webhooks.length < totalAfter; @@ -171,6 +171,6 @@ export function useWebhookDetails( if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } |