Files
Dwinzo_Demo/app/src/services/dashboard/duplicateProject.ts

49 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-06-10 15:28:23 +05:30
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const duplicateProject = async (
2025-08-02 18:23:42 +05:30
refProjectID: string,
2025-06-10 15:28:23 +05:30
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") || "",
},
2025-08-02 18:23:42 +05:30
body: JSON.stringify({
refProjectID,
projectUuid,
thumbnail,
projectName,
}),
2025-06-10 15:28:23 +05:30
}
);
const newAccessToken = response.headers.get("x-access-token");
if (newAccessToken) {
2025-08-05 11:31:26 +05:30
//
localStorage.setItem("token", newAccessToken);
}
2025-08-05 11:31:26 +05:30
2025-06-10 15:28:23 +05:30
if (!response.ok) {
2025-08-05 11:31:26 +05:30
2025-06-10 15:28:23 +05:30
}
const result = await response.json();
2025-08-05 11:31:26 +05:30
//
2025-06-10 15:28:23 +05:30
return result;
} catch (error) {
if (error instanceof Error) {
2025-08-05 11:31:26 +05:30
2025-06-10 15:28:23 +05:30
} else {
2025-08-05 11:31:26 +05:30
2025-06-10 15:28:23 +05:30
}
}
};