diff --git a/docker-compose.yml b/docker-compose.yml
index e12c35d..1834a4a 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -8,4 +8,4 @@ services:
ports:
- "3000:80"
environment:
- - codex_url=${codex_url:-http://kubernetes.docker.internal:30003}
+ - codex_url=${codex_url:-http://kubernetes.docker.internal:30001}
diff --git a/frontend/src/pages/data/tabs/download/DownloadTab.tsx b/frontend/src/pages/data/tabs/download/DownloadTab.tsx
index 62e34c5..55f123f 100644
--- a/frontend/src/pages/data/tabs/download/DownloadTab.tsx
+++ b/frontend/src/pages/data/tabs/download/DownloadTab.tsx
@@ -7,6 +7,7 @@ function DownloadTab() {
const { ftdCid, setFtdCid, nodeInfo } = useDexyStore();
const [filename, setFilename] = useState("file");
+ const [error, setError] = useState("");
function download(cid: string) {
console.log(filename);
@@ -22,36 +23,60 @@ function DownloadTab() {
{},
}
)
- .then((response) => response.blob())
- .then((blob) => {
- const url = window.URL.createObjectURL(new Blob([blob]));
- const link = document.createElement("a");
- link.href = url;
- link.setAttribute("download", filename);
- document.body.appendChild(link);
- link.click();
- link.parentNode?.removeChild(link);
- });
+ .then((response) =>
+ {
+ if (response.status === 200) {
+ response.blob()
+ .then((blob) => {
+ const url = window.URL.createObjectURL(new Blob([blob]));
+ const link = document.createElement("a");
+ link.href = url;
+ link.setAttribute("download", filename);
+ document.body.appendChild(link);
+ link.click();
+ link.parentNode?.removeChild(link);
+ })
+ }
+ else {
+ response.text().then((text) => {
+ setError(text);
+ }).catch((error) => {
+ console.error("Error reading response body:", error);
+ setError("Failed to read response body");
+ });
+ }
+ })
+ .catch((error) => {
+ console.error("Error downloading file:", error);
+ setError("Failed to download file");
+ });
}
return (
-
+ {error} +
+ )} + > ); } diff --git a/frontend/src/pages/data/tabs/upload/UploadTab.tsx b/frontend/src/pages/data/tabs/upload/UploadTab.tsx index b7f4e1a..ac519d0 100644 --- a/frontend/src/pages/data/tabs/upload/UploadTab.tsx +++ b/frontend/src/pages/data/tabs/upload/UploadTab.tsx @@ -14,6 +14,7 @@ function UploadTab() { const { uploads, setUploads, nodeInfo } = useDexyStore(); var files = useRefDrop the files here ...
- ) : ( -Drag 'n' drop some files here, or click to select files
- )} -Drop the files here ...
+ ) : ( +Drag 'n' drop some files here, or click to select files
+ )} ++ {error} +
+ )} + > ); } diff --git a/frontend/src/pages/marketplace/tabs/Availability/OfferStorage.tsx b/frontend/src/pages/marketplace/tabs/Availability/OfferStorage.tsx index 9768fc9..e7d348f 100644 --- a/frontend/src/pages/marketplace/tabs/Availability/OfferStorage.tsx +++ b/frontend/src/pages/marketplace/tabs/Availability/OfferStorage.tsx @@ -11,7 +11,8 @@ function OfferStorage() { const [minPrice, setMinPrice,] = useState("file"); const [maxCollateral, setMaxCollateral,] = useState("file"); const [expiry, setExpiry,] = useState("file"); - + const [error, setError] = useState(""); + function upload(cid: string) { fetch( @@ -33,58 +34,75 @@ function OfferStorage() { }) } ) - // create a popup in the browser to show if the upload was successful - .then((response) => { + // create a popup in the browser to show if the upload was successful + .then((response) => { if (response.status === 200) { - alert("Upload successful!"); + alert("Successfully created storage offer!"); + setError(""); } else { - alert("Upload failed!"); + response.text().then((text) => { + setError(text); + }).catch((error) => { + console.error("Error reading response body:", error); + setError("Failed to read response body"); + }); } }) + .catch((error) => { + console.error("Error creating storage offer:", error); + setError("Failed to create storage offer"); + }); } return ( -+ {error} +
+ )} + > ); } diff --git a/frontend/src/pages/marketplace/tabs/Rosc/CreateTab.tsx b/frontend/src/pages/marketplace/tabs/Rosc/CreateTab.tsx index 80ec572..1011830 100644 --- a/frontend/src/pages/marketplace/tabs/Rosc/CreateTab.tsx +++ b/frontend/src/pages/marketplace/tabs/Rosc/CreateTab.tsx @@ -10,7 +10,8 @@ function CreateTab() { const [duration, setDuration,] = useState("file"); const [proofProbability, setProofProbability,] = useState("file"); const [collateral, setCollateral,] = useState("file"); - + const [error, setError] = useState(""); + function upload(cid: string) { fetch( @@ -31,52 +32,69 @@ function CreateTab() { }) } ) - // create a popup in the browser to show if the upload was successful - .then((response) => { + // create a popup in the browser to show if the upload was successful + .then((response) => { if (response.status === 200) { - alert("Upload successful!"); + alert("Successfully created storage offer!"); + setError(""); } else { - alert("Upload failed!"); + response.text().then((text) => { + setError(text); + }).catch((error) => { + console.error("Error reading response body:", error); + setError("Failed to read response body"); + }); } }) + .catch((error) => { + console.error("Error creating storage offer:", error); + setError("Failed to create storage offer"); + }); } return ( -+ {error} +
+ )} + > ); }