mirror of
https://github.com/codex-storage/codex-marketplace-ui.git
synced 2025-02-24 05:38:18 +00:00
Move up the error to the error boundary
This commit is contained in:
parent
ed57e61703
commit
6a91435fed
@ -22,6 +22,9 @@ export function useData() {
|
|||||||
|
|
||||||
// Don't expect something new when coming back to the UI
|
// Don't expect something new when coming back to the UI
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
|
|
||||||
|
// Throw the error to the error boundary
|
||||||
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return data.content;
|
return data.content;
|
||||||
|
@ -39,6 +39,9 @@ export function Availabilities() {
|
|||||||
// Refreshing when focus returns can be useful if a user comes back
|
// Refreshing when focus returns can be useful if a user comes back
|
||||||
// to the UI after performing an operation in the terminal.
|
// to the UI after performing an operation in the terminal.
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
|
|
||||||
|
// Throw the error to the error boundary
|
||||||
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Error will be catched in ErrorBounday
|
// Error will be catched in ErrorBounday
|
||||||
@ -59,6 +62,9 @@ export function Availabilities() {
|
|||||||
// Refreshing when focus returns can be useful if a user comes back
|
// Refreshing when focus returns can be useful if a user comes back
|
||||||
// to the UI after performing an operation in the terminal.
|
// to the UI after performing an operation in the terminal.
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
|
|
||||||
|
// Throw the error to the error boundary
|
||||||
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// const allocation = availabilities
|
// const allocation = availabilities
|
||||||
|
@ -13,7 +13,7 @@ import { ErrorPlaceholder } from "../../components/ErrorPlaceholder/ErrorPlaceho
|
|||||||
import { ErrorBoundary } from "@sentry/react";
|
import { ErrorBoundary } from "@sentry/react";
|
||||||
|
|
||||||
const Purchases = () => {
|
const Purchases = () => {
|
||||||
const { data, isPending } = useQuery({
|
const { data, isPending, error } = useQuery({
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
CodexSdk.marketplace.purchases().then((s) => Promises.rejectOnError(s)),
|
CodexSdk.marketplace.purchases().then((s) => Promises.rejectOnError(s)),
|
||||||
queryKey: ["purchases"],
|
queryKey: ["purchases"],
|
||||||
@ -29,6 +29,11 @@ const Purchases = () => {
|
|||||||
// Refreshing when focus returns can be useful if a user comes back
|
// Refreshing when focus returns can be useful if a user comes back
|
||||||
// to the UI after performing an operation in the terminal.
|
// to the UI after performing an operation in the terminal.
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
|
|
||||||
|
initialData: [],
|
||||||
|
|
||||||
|
// Throw the error to the error boundary
|
||||||
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isPending) {
|
if (isPending) {
|
||||||
@ -49,23 +54,22 @@ const Purchases = () => {
|
|||||||
"state",
|
"state",
|
||||||
];
|
];
|
||||||
|
|
||||||
const cells =
|
const cells = data.map((p, index) => {
|
||||||
(data ?? []).map((p, index) => {
|
const r = p.request;
|
||||||
const r = p.request;
|
const ask = p.request.ask;
|
||||||
const ask = p.request.ask;
|
const duration = parseInt(p.request.ask.duration, 10);
|
||||||
const duration = parseInt(p.request.ask.duration, 10);
|
const pf = parseInt(p.request.ask.proofProbability, 10);
|
||||||
const pf = parseInt(p.request.ask.proofProbability, 10);
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
<FileCell requestId={r.id} purchaseCid={r.content.cid} index={index} />,
|
<FileCell requestId={r.id} purchaseCid={r.content.cid} index={index} />,
|
||||||
<TruncateCell value={r.id} />,
|
<TruncateCell value={r.id} />,
|
||||||
<Cell value={Times.pretty(duration)} />,
|
<Cell value={Times.pretty(duration)} />,
|
||||||
<Cell value={ask.slots.toString()} />,
|
<Cell value={ask.slots.toString()} />,
|
||||||
<Cell value={ask.reward + " CDX"} />,
|
<Cell value={ask.reward + " CDX"} />,
|
||||||
<Cell value={pf.toString()} />,
|
<Cell value={pf.toString()} />,
|
||||||
<CustomStateCellRender state={p.state} message={p.error} />,
|
<CustomStateCellRender state={p.state} message={p.error} />,
|
||||||
];
|
];
|
||||||
}) || [];
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user