mirror of
https://github.com/logos-storage/logos-storage-marketplace-ui.git
synced 2026-01-07 16:03:06 +00:00
Fix URL not updated issue
This commit is contained in:
parent
6c96cbe295
commit
e6d7d9e619
@ -38,7 +38,7 @@ export function AvailabilityReservations({
|
||||
error,
|
||||
} = useQuery({
|
||||
queryFn: () =>
|
||||
CodexSdk.marketplace
|
||||
CodexSdk.marketplace()
|
||||
.reservations(availability!.id)
|
||||
.then((s) => Promises.rejectOnError(s)),
|
||||
queryKey: ["reservations"],
|
||||
|
||||
@ -27,18 +27,17 @@ export function useAvailabilityMutation(
|
||||
...input
|
||||
}: AvailabilityState) => {
|
||||
const unit = totalSizeUnit === "gb" ? GB : TB;
|
||||
const marketplace = CodexSdk.marketplace;
|
||||
const time = Times.toSeconds(duration, durationUnit);
|
||||
|
||||
const fn: (
|
||||
input: Omit<AvailabilityState, "totalSizeUnit" | "durationUnit">
|
||||
) => Promise<unknown> = input.id
|
||||
? (input) =>
|
||||
marketplace
|
||||
? (input) =>
|
||||
CodexSdk.marketplace()
|
||||
.updateAvailability({ ...input, id: input.id || "" })
|
||||
.then((s) => Promises.rejectOnError(s))
|
||||
: (input) =>
|
||||
marketplace
|
||||
: (input) =>
|
||||
CodexSdk.marketplace()
|
||||
.createAvailability(input)
|
||||
.then((s) => Promises.rejectOnError(s));
|
||||
|
||||
|
||||
@ -6,7 +6,10 @@ import { CircleX } from "lucide-react";
|
||||
|
||||
export function Debug() {
|
||||
const { data, isPending, isError, error } = useQuery({
|
||||
queryFn: () => CodexSdk.debug.info().then((s) => Promises.rejectOnError(s)),
|
||||
queryFn: () =>
|
||||
CodexSdk.debug()
|
||||
.info()
|
||||
.then((s) => Promises.rejectOnError(s)),
|
||||
queryKey: ["debug"],
|
||||
|
||||
// No need to retry because if the connection to the node
|
||||
|
||||
@ -15,7 +15,9 @@ export function LogLevel() {
|
||||
const [level, setLevel] = useState<CodexLogLevel>("DEBUG");
|
||||
const { mutateAsync, isPending } = useMutation({
|
||||
mutationFn: (level: CodexLogLevel) =>
|
||||
CodexSdk.debug.setLogLevel(level).then((s) => Promises.rejectOnError(s)),
|
||||
CodexSdk.debug()
|
||||
.setLogLevel(level)
|
||||
.then((s) => Promises.rejectOnError(s)),
|
||||
onSuccess: () => {
|
||||
setToast({
|
||||
message: "The log level has been updated successfully.",
|
||||
|
||||
@ -19,8 +19,11 @@ export function NodeIndicator() {
|
||||
|
||||
const { data, isError } = useQuery({
|
||||
queryKey: ["spr"],
|
||||
queryFn: async () =>
|
||||
CodexSdk.node.spr().then((data) => Promises.rejectOnError(data, report)),
|
||||
queryFn: async () => {
|
||||
return CodexSdk.node()
|
||||
.spr()
|
||||
.then((data) => Promises.rejectOnError(data, report));
|
||||
},
|
||||
refetchInterval: 5000,
|
||||
|
||||
// No need to retry because we defined a refetch interval
|
||||
|
||||
@ -14,7 +14,10 @@ const defaultSpace = {
|
||||
|
||||
export function NodeSpaceAllocation() {
|
||||
const { data: space, isPending } = useQuery({
|
||||
queryFn: () => CodexSdk.data.space().then((s) => Promises.rejectOnError(s)),
|
||||
queryFn: () =>
|
||||
CodexSdk.data()
|
||||
.space()
|
||||
.then((s) => Promises.rejectOnError(s)),
|
||||
queryKey: ["space"],
|
||||
initialData: defaultSpace,
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ export function StorageRequestFileChooser({
|
||||
onSuccess={onSuccess}
|
||||
editable={false}
|
||||
onDeleteItem={onDelete}
|
||||
codexData={CodexSdk.data}
|
||||
codexData={CodexSdk.data()}
|
||||
successMessage={"Success, the CID has been copied to the field on top."}
|
||||
/>
|
||||
</>
|
||||
|
||||
@ -18,7 +18,7 @@ export function useStorageRequestMutation(
|
||||
|
||||
const { mutateAsync } = useMutation({
|
||||
mutationFn: (input: CodexCreateStorageRequestInput) =>
|
||||
CodexSdk.marketplace
|
||||
CodexSdk.marketplace()
|
||||
.createStorageRequest(input)
|
||||
.then((s) => Promises.rejectOnError(s)),
|
||||
onSuccess: async () => {
|
||||
|
||||
@ -7,7 +7,9 @@ export function useData() {
|
||||
const { data = { content: [] } satisfies CodexDataResponse } =
|
||||
useQuery<CodexDataResponse>({
|
||||
queryFn: () =>
|
||||
CodexSdk.data.cids().then((res) => Promises.rejectOnError(res)),
|
||||
CodexSdk.data()
|
||||
.cids()
|
||||
.then((res) => Promises.rejectOnError(res)),
|
||||
queryKey: ["cids"],
|
||||
|
||||
initialData: { content: [] } satisfies CodexDataResponse,
|
||||
|
||||
@ -179,6 +179,6 @@ class CodexMarketplaceMock extends CodexMarketplace {
|
||||
|
||||
export const CodexSdk = {
|
||||
...Sdk,
|
||||
marketplace: new CodexMarketplaceMock(import.meta.env.VITE_CODEX_API_URL),
|
||||
data: new CodexDataMock(import.meta.env.VITE_CODEX_API_URL),
|
||||
marketplace: () => new CodexMarketplaceMock(CodexSdk.url()),
|
||||
data: () => new CodexDataMock(CodexSdk.url()),
|
||||
};
|
||||
|
||||
@ -21,7 +21,7 @@ export function Availabilities() {
|
||||
// Error will be catched in ErrorBounday
|
||||
const { data: availabilities = [], isPending } = useQuery({
|
||||
queryFn: () =>
|
||||
CodexSdk.marketplace
|
||||
CodexSdk.marketplace()
|
||||
.availabilities()
|
||||
.then((s) => Promises.rejectOnError(s))
|
||||
.then((res) => res.sort((a, b) => b.totalSize - a.totalSize)),
|
||||
@ -47,7 +47,9 @@ export function Availabilities() {
|
||||
// Error will be catched in ErrorBounday
|
||||
const { data: space = defaultSpace } = useQuery({
|
||||
queryFn: () =>
|
||||
CodexSdk.data.space().then((s) => Promises.rejectOnError(s)),
|
||||
CodexSdk.data()
|
||||
.space()
|
||||
.then((s) => Promises.rejectOnError(s)),
|
||||
queryKey: ["space"],
|
||||
initialData: defaultSpace,
|
||||
|
||||
|
||||
@ -18,6 +18,8 @@ function About() {
|
||||
queryClient.invalidateQueries({ queryKey: ["cids"] });
|
||||
};
|
||||
|
||||
console.info(CodexSdk.data);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="dashboard">
|
||||
@ -29,7 +31,11 @@ function About() {
|
||||
/>
|
||||
)}>
|
||||
<Card title="Upload a file">
|
||||
<Upload multiple codexData={CodexSdk.data} onSuccess={onSuccess} />
|
||||
<Upload
|
||||
multiple
|
||||
codexData={CodexSdk.data()}
|
||||
onSuccess={onSuccess}
|
||||
/>
|
||||
</Card>
|
||||
</ErrorBoundary>
|
||||
|
||||
|
||||
@ -20,7 +20,9 @@ import { ErrorBoundary } from "@sentry/react";
|
||||
const Purchases = () => {
|
||||
const { data, isPending } = useQuery({
|
||||
queryFn: () =>
|
||||
CodexSdk.marketplace.purchases().then((s) => Promises.rejectOnError(s)),
|
||||
CodexSdk.marketplace()
|
||||
.purchases()
|
||||
.then((s) => Promises.rejectOnError(s)),
|
||||
queryKey: ["purchases"],
|
||||
|
||||
// No need to retry because if the connection to the node
|
||||
|
||||
@ -23,11 +23,19 @@ export const CodexSdk = {
|
||||
return WebStorage.set("codex-node-url", url);
|
||||
},
|
||||
|
||||
debug: client.debug,
|
||||
debug() {
|
||||
return client.debug
|
||||
},
|
||||
|
||||
data: client.data,
|
||||
data() {
|
||||
return client.data
|
||||
},
|
||||
|
||||
node: client.node,
|
||||
node() {
|
||||
return client.node
|
||||
},
|
||||
|
||||
marketplace: client.marketplace,
|
||||
marketplace() {
|
||||
return client.marketplace
|
||||
},
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user