added dashboard with add delete and recently view the projects
This commit is contained in:
0
app/src/services/dashboard/addedProject.ts
Normal file
0
app/src/services/dashboard/addedProject.ts
Normal file
38
app/src/services/dashboard/createProject.ts
Normal file
38
app/src/services/dashboard/createProject.ts
Normal 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");
|
||||
}
|
||||
}
|
||||
};
|
||||
35
app/src/services/dashboard/deleteProject.ts
Normal file
35
app/src/services/dashboard/deleteProject.ts
Normal 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");
|
||||
}
|
||||
}
|
||||
};
|
||||
24
app/src/services/dashboard/getAllProjects.ts
Normal file
24
app/src/services/dashboard/getAllProjects.ts
Normal 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);
|
||||
}
|
||||
};
|
||||
28
app/src/services/dashboard/getTrash.ts
Normal file
28
app/src/services/dashboard/getTrash.ts
Normal 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");
|
||||
}
|
||||
};
|
||||
27
app/src/services/dashboard/projectTutorial.ts
Normal file
27
app/src/services/dashboard/projectTutorial.ts
Normal 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");
|
||||
}
|
||||
}
|
||||
};
|
||||
24
app/src/services/dashboard/recentlyViewed.ts
Normal file
24
app/src/services/dashboard/recentlyViewed.ts
Normal 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);
|
||||
}
|
||||
};
|
||||
26
app/src/services/dashboard/restoreTrash.ts
Normal file
26
app/src/services/dashboard/restoreTrash.ts
Normal 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");
|
||||
}
|
||||
};
|
||||
35
app/src/services/dashboard/searchProjects.ts
Normal file
35
app/src/services/dashboard/searchProjects.ts
Normal 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");
|
||||
}
|
||||
}
|
||||
};
|
||||
32
app/src/services/dashboard/trashSearchProject.ts
Normal file
32
app/src/services/dashboard/trashSearchProject.ts
Normal 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");
|
||||
}
|
||||
}
|
||||
};
|
||||
45
app/src/services/dashboard/updateProject.ts
Normal file
45
app/src/services/dashboard/updateProject.ts
Normal 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");
|
||||
}
|
||||
}
|
||||
};
|
||||
28
app/src/services/dashboard/viewProject.ts
Normal file
28
app/src/services/dashboard/viewProject.ts
Normal 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);
|
||||
}
|
||||
};
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user