diff options
author | Sebastian <sebasjm@gmail.com> | 2023-02-10 09:50:54 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-02-10 09:52:01 -0300 |
commit | 53af8b486fd8a538c1f54a2ce66ed5f74b2b46ed (patch) | |
tree | fdda21230b6f98a8cf84f6459910c76c610234dd /packages/merchant-backoffice-ui/src/hooks/order.ts | |
parent | 7a591c39d78c5183ae05d36221d0bcf8322cea92 (diff) | |
download | wallet-core-53af8b486fd8a538c1f54a2ce66ed5f74b2b46ed.tar.xz |
fix: request error is whats being thrown
Diffstat (limited to 'packages/merchant-backoffice-ui/src/hooks/order.ts')
-rw-r--r-- | packages/merchant-backoffice-ui/src/hooks/order.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/order.ts b/packages/merchant-backoffice-ui/src/hooks/order.ts index c01f8dd83..3bcf7aaab 100644 --- a/packages/merchant-backoffice-ui/src/hooks/order.ts +++ b/packages/merchant-backoffice-ui/src/hooks/order.ts @@ -13,16 +13,16 @@ You should have received a copy of the GNU General Public License along with GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { useEffect, useState } from "preact/hooks"; -import useSWR from "swr"; -import { MerchantBackend } from "../declaration.js"; -import { MAX_RESULT_SIZE, PAGE_SIZE } from "../utils/constants.js"; import { - HttpError, HttpResponse, HttpResponseOk, HttpResponsePaginated, + RequestError, } from "@gnu-taler/web-util/lib/index.browser"; +import { useEffect, useState } from "preact/hooks"; +import useSWR from "swr"; +import { MerchantBackend } from "../declaration.js"; +import { MAX_RESULT_SIZE, PAGE_SIZE } from "../utils/constants.js"; import { useBackendInstanceRequest, useMatchMutate } from "./backend.js"; export interface OrderAPI { @@ -136,7 +136,7 @@ export function useOrderDetails( const { data, error, isValidating } = useSWR< HttpResponseOk<MerchantBackend.Orders.MerchantOrderStatusResponse>, - HttpError<MerchantBackend.ErrorDetail> + RequestError<MerchantBackend.ErrorDetail> >([`/private/orders/${oderId}`], fetcher, { refreshInterval: 0, refreshWhenHidden: false, @@ -147,7 +147,7 @@ export function useOrderDetails( if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error; + if (error) return error.info; return { loading: true }; } @@ -185,7 +185,7 @@ export function useInstanceOrders( isValidating: loadingBefore, } = useSWR< HttpResponseOk<MerchantBackend.Orders.OrderHistory>, - HttpError<MerchantBackend.ErrorDetail> + RequestError<MerchantBackend.ErrorDetail> >( [ `/private/orders`, @@ -203,7 +203,7 @@ export function useInstanceOrders( isValidating: loadingAfter, } = useSWR< HttpResponseOk<MerchantBackend.Orders.OrderHistory>, - HttpError<MerchantBackend.ErrorDetail> + RequestError<MerchantBackend.ErrorDetail> >( [ `/private/orders`, @@ -234,8 +234,8 @@ export function useInstanceOrders( if (beforeData) setLastBefore(beforeData); }, [afterData, beforeData]); - if (beforeError) return beforeError; - if (afterError) return afterError; + if (beforeError) return beforeError.info; + if (afterError) return afterError.info; // if the query returns less that we ask, then we have reach the end or beginning const isReachingEnd = afterData && afterData.data.orders.length < totalAfter; |