diff options
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 }; } |