added dashboard with add delete and recently view the projects

This commit is contained in:
2025-05-19 14:50:33 +05:30
parent eebc91831d
commit 0ecb85a211
33 changed files with 1467 additions and 288 deletions

View File

@@ -0,0 +1,38 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
// let url_Backend_dwinzo = `http://192.168.0.110:5000`;
export const createProject = async (
projectUuid: string,
userId: string,
thumbnail: string,
organization: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/upsertProject`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
projectUuid,
userId,
thumbnail,
organization,
}),
});
if (!response.ok) {
throw new Error("Failed to add project");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,35 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
export const deleteProject = async (
projectId: string,
userId: string,
organization: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1//Project/archive/${projectId}`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId, organization }),
}
);
if (!response.ok) {
throw new Error("Failed to clearPanel in the zone");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to clean pannel");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,24 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getAllProjects = async (userId: string, organization: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/Projects/${userId}/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch assets");
}
return await response.json();
} catch (error: any) {
echo.error("Failed to get asset image");
throw new Error(error.message);
}
};

View File

@@ -0,0 +1,28 @@
const url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
// const url_Backend_dwinzo = `http://192.168.0.102:5000`;
export const getTrash = async (organization: string) => {
console.log("Organization:", organization);
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/Trash/Lists?organization=${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch trash data");
}
const data = await response.json();
return data;
} catch (error: any) {
console.error("Failed to fetch trash data:", error);
throw new Error(error.message || "Unknown error");
}
};

View File

@@ -0,0 +1,27 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const projectTutorial = async () => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/tutorials`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
console.log("response: ", response);
if (!response.ok) {
throw new Error("Failed to add project");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,24 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const recentlyViewed = async (organization: string, userId: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/RecentlyViewed/${userId}/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch project");
}
return await response.json();
} catch (error: any) {
console.error("Failed to get project");
throw new Error(error.message);
}
};

View File

@@ -0,0 +1,26 @@
const url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
// const url_Backend_dwinzo = `http://192.168.0.102:5000`;
export const restoreTrash = async (organization: string, projectId: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/restore?organization=${organization}&projectId=${projectId}`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch trash data");
}
const data = await response.json();
return data;
} catch (error: any) {
console.error("Failed to fetch trash data:", error);
throw new Error(error.message || "Unknown error");
}
};

View File

@@ -0,0 +1,35 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const searchProject = async (
organization: string,
userId: string,
searchName: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/searchProjects?organization=${organization}&userId=${userId}&searchName=${searchName}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to Search project");
}
console.log("response: ", response);
const result = await response.json();
console.log("result: ", result);
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const trashSearchProject = async (
organization: string,
userId: string,
searchName: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/searchTrashProjects?organization=${organization}&userId=${userId}&searchName=${searchName}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to add project");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,45 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
export const updateProject = async (
projectId: string,
userId: string,
organization: string,
thumbnail?: string,
projectName?: string
) => {
const body: any = {
projectId,
userId,
organization,
};
if (projectName) body.projectName = projectName;
if (thumbnail) body.thumbnail = thumbnail;
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/Project/modify`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
if (!response.ok) {
throw new Error("Failed to clearPanel in the zone");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,28 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const viewProject = async (
organization: string,
projectId: string,
userId: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/Project/view?organization=${organization}&projectId=${projectId}&userId=${userId}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch");
}
return await response.json();
} catch (error: any) {
console.error("Failed to get asset image:", error);
throw new Error(error.message);
}
};

View File

@@ -20,6 +20,7 @@ export const signUpApi = async (
}
const result = await response.json();
console.log("result: ", result);
return result;
} catch (error) {
echo.error("Failed to sign-up");