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/product.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/product.ts')
-rw-r--r-- | packages/merchant-backoffice-ui/src/hooks/product.ts | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/product.ts b/packages/merchant-backoffice-ui/src/hooks/product.ts index 5d95a2f8f..df86f68f5 100644 --- a/packages/merchant-backoffice-ui/src/hooks/product.ts +++ b/packages/merchant-backoffice-ui/src/hooks/product.ts @@ -13,13 +13,13 @@ 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 useSWR, { useSWRConfig } from "swr"; -import { MerchantBackend, WithId } from "../declaration.js"; import { - HttpError, HttpResponse, HttpResponseOk, + RequestError, } from "@gnu-taler/web-util/lib/index.browser"; +import useSWR, { useSWRConfig } from "swr"; +import { MerchantBackend, WithId } from "../declaration.js"; import { useBackendInstanceRequest, useMatchMutate } from "./backend.js"; export interface ProductAPI { @@ -96,7 +96,7 @@ export function useInstanceProducts(): HttpResponse< const { data: list, error: listError } = useSWR< HttpResponseOk<MerchantBackend.Products.InventorySummaryResponse>, - HttpError<MerchantBackend.ErrorDetail> + RequestError<MerchantBackend.ErrorDetail> >([`/private/products`], fetcher, { refreshInterval: 0, refreshWhenHidden: false, @@ -110,7 +110,7 @@ export function useInstanceProducts(): HttpResponse< ); const { data: products, error: productError } = useSWR< HttpResponseOk<MerchantBackend.Products.ProductDetail>[], - HttpError<MerchantBackend.ErrorDetail> + RequestError<MerchantBackend.ErrorDetail> >([paths], multiFetcher, { refreshInterval: 0, refreshWhenHidden: false, @@ -119,8 +119,8 @@ export function useInstanceProducts(): HttpResponse< refreshWhenOffline: false, }); - if (listError) return listError; - if (productError) return productError; + if (listError) return listError.info; + if (productError) return productError.info; if (products) { const dataWithId = products.map((d) => { @@ -145,7 +145,7 @@ export function useProductDetails( const { data, error, isValidating } = useSWR< HttpResponseOk<MerchantBackend.Products.ProductDetail>, - HttpError<MerchantBackend.ErrorDetail> + RequestError<MerchantBackend.ErrorDetail> >([`/private/products/${productId}`], fetcher, { refreshInterval: 0, refreshWhenHidden: false, @@ -156,6 +156,6 @@ export function useProductDetails( if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error; + if (error) return error.info; return { loading: true }; } |