worked with socket for dashboard
This commit is contained in:
@@ -3,7 +3,7 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
|
||||
|
||||
export const createProject = async (projectUuid: string, userId: string, thumbnail: string, organization: string) => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/v2/upsertProject`, {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/NewProject`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>", // Replace with actual token
|
||||
@@ -14,6 +14,7 @@ export const createProject = async (projectUuid: string, userId: string, thumbna
|
||||
body: JSON.stringify({ projectUuid, userId, thumbnail, organization, }),
|
||||
});
|
||||
|
||||
console.log('response: ', response);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to add project");
|
||||
}
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
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 {
|
||||
console.log("projectId", userId, organization, projectId);
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/v2/Project/archive/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/Projects/Archive/${projectId}`,
|
||||
{
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>", // Replace with actual token
|
||||
Authorization: "Bearer <access_token>", // Replace with actual token
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify({ userId, organization }),
|
||||
}
|
||||
);
|
||||
|
||||
console.log("response: ", response);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to clearPanel in the zone");
|
||||
}
|
||||
|
||||
30
app/src/services/dashboard/deleteTrash.ts
Normal file
30
app/src/services/dashboard/deleteTrash.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
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 deleteTrash = async (organization: string, projectId: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/Trash/Delete?projectId=${projectId}`,
|
||||
{
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>", // Replace with actual token
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
console.log("restore: ", response);
|
||||
|
||||
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");
|
||||
}
|
||||
};
|
||||
38
app/src/services/dashboard/duplicateProject.ts
Normal file
38
app/src/services/dashboard/duplicateProject.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const duplicateProject = async (
|
||||
projectUuid: string,
|
||||
thumbnail: string,
|
||||
projectName: string
|
||||
) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/project/Duplicate`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>", // Replace with actual token
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify({ projectUuid, thumbnail, projectName }),
|
||||
}
|
||||
);
|
||||
|
||||
console.log("response: ", response);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to add project");
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -3,7 +3,7 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
|
||||
export const getAllProjects = async (userId: string, organization: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/v2/Projects`,
|
||||
`${url_Backend_dwinzo}/api/V1/Projects`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
||||
@@ -2,11 +2,10 @@ const url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_
|
||||
// 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/v2/TrashItems`,
|
||||
`${url_Backend_dwinzo}/api/V1/TrashItems`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
@@ -23,7 +22,6 @@ export const getTrash = async (organization: string) => {
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log('TrashItems: ', data);
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Failed to fetch trash data:", error);
|
||||
|
||||
@@ -2,7 +2,7 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
|
||||
|
||||
export const projectTutorial = async () => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/v1/tutorials`, {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/tutorials`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
@@ -3,7 +3,7 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
|
||||
export const recentlyViewed = async (organization: string, userId: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/v2/RecentlyViewed`,
|
||||
`${url_Backend_dwinzo}/api/V1/RecentlyViewed`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
||||
@@ -4,7 +4,7 @@ const url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_
|
||||
export const restoreTrash = async (organization: string, projectId: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/v2/Trash/restore?projectId=${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/Trash/restore?projectId=${projectId}`,
|
||||
{
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
|
||||
@@ -7,26 +7,26 @@ export const searchProject = async (
|
||||
) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/v2/searchProjects?searchName=${searchName}`,
|
||||
`${url_Backend_dwinzo}/api/V1/search/searchProjects?searchName=${searchName}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>", // Replace with actual token
|
||||
Authorization: "Bearer <access_token>", // Replace with actual token
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
console.log("response: ", response);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to Search project");
|
||||
}
|
||||
|
||||
|
||||
const result = await response.json();
|
||||
console.log("searchProjects: ", result);
|
||||
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
|
||||
@@ -7,13 +7,13 @@ export const trashSearchProject = async (
|
||||
) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/v2/searchTrashProjects?searchName=${searchName}`,
|
||||
`${url_Backend_dwinzo}/api/V1/search/searchTrashProjects?searchName=${searchName}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>", // Replace with actual token
|
||||
Authorization: "Bearer <access_token>", // Replace with actual token
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
@@ -24,7 +24,7 @@ export const trashSearchProject = async (
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
console.log('searchTrashProjects: ', result);
|
||||
console.log("searchTrashProjects: ", result);
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
@@ -34,4 +34,3 @@ export const trashSearchProject = async (
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ export const updateProject = async (
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/v2/Project/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/Projects/${projectId}`,
|
||||
{
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const viewProject = async (organization: string,projectId: string,userId: string) => {
|
||||
export const viewProject = async (
|
||||
organization: string,
|
||||
projectId: string,
|
||||
userId: string
|
||||
) => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/v2/Project/${projectId}`,
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/Project/${projectId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>", // Replace with actual token
|
||||
Authorization: "Bearer <access_token>", // Replace with actual token
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
@@ -24,4 +29,3 @@ export const viewProject = async (organization: string,projectId: string,userId:
|
||||
throw new Error(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
|
||||
|
||||
export const signInApi = async (Email: string,Password: Object,organization: Object,fingerprint:any) => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/v2/Auth/login`, {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/Auth/login`, {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json",},
|
||||
body: JSON.stringify({ Email, Password, organization,fingerprint}),
|
||||
|
||||
@@ -7,7 +7,7 @@ export const signUpApi = async (
|
||||
organization: Object
|
||||
) => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/v2/Auth/signup`, {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/Auth/signup`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", },
|
||||
body: JSON.stringify({ userName, Email, Password, organization }),
|
||||
|
||||
Reference in New Issue
Block a user