completed some features in market place
This commit is contained in:
22
app/src/services/marketplace/fetchAssetDetails.ts
Normal file
22
app/src/services/marketplace/fetchAssetDetails.ts
Normal 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);
|
||||
}
|
||||
};
|
||||
@@ -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);
|
||||
|
||||
7
app/src/services/marketplace/fetchGltfUrl.ts
Normal file
7
app/src/services/marketplace/fetchGltfUrl.ts
Normal 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
|
||||
};
|
||||
4
app/src/services/marketplace/getAssetDownload.ts
Normal file
4
app/src/services/marketplace/getAssetDownload.ts
Normal 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`;
|
||||
};
|
||||
25
app/src/services/marketplace/getSortedAssets.ts
Normal file
25
app/src/services/marketplace/getSortedAssets.ts
Normal 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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user