completed some features in market place

This commit is contained in:
2025-03-28 16:25:53 +05:30
parent a00df5716e
commit dc73c1a50b
12 changed files with 286 additions and 142 deletions

View File

@@ -0,0 +1,22 @@
let BackEnd_url = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
export const getAssetDetails = async (filename: string) => {
try {
const response = await fetch(`${BackEnd_url}/api/v1/assetDetails`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ filename }),
});
if (!response.ok) {
throw new Error("Failed to fetch asset details");
}
const result = await response.json();
return result;
} catch (error: any) {
// console.error("Error fetching category:", error.message);
throw new Error(error.message);
}
};

View File

@@ -6,6 +6,8 @@ export const fetchAssets = async () => {
throw new Error("Network response was not ok");
}
const result = await response.json();
const last10Assets = result.slice(-10);
console.log('last10Assets: ', last10Assets);
return result;
} catch (error) {
console.log("error: ", error);

View File

@@ -0,0 +1,7 @@
let BackEnd_url = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
export const fetchGltfUrl = (filename: string) => {
if (filename) {
return `${BackEnd_url}/api/v1/getAssetFile/${filename}`;
}
return null; // or handle the case when filename is not provided
};

View File

@@ -0,0 +1,4 @@
let BackEnd_url = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
export const getAssetDownload = (filename: any) => {
return `${BackEnd_url}/api/v1/getAssetFile/${filename}.gltf`;
};

View File

@@ -0,0 +1,25 @@
let BackEnd_url = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
export const getSortedAssets = async (category: any, orders: any) => {
try {
const response = await fetch(
`${BackEnd_url}/api/v1/categoryWise/${category}?sortBy=${orders}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error(`Error: ${response.statusText}`);
}
const result = await response.json();
return result; // Return the result to be used later
} catch (error: any) {
console.error("Error fetching category:", error.message);
throw new Error(error.message);
}
};