feat: Add support for project cancellation status across the application
This commit is contained in:
@@ -38,6 +38,10 @@ export default function ProjectStatusDropdown({
|
||||
label: t("projectStatus.fulfilled"),
|
||||
variant: "success",
|
||||
},
|
||||
cancelled: {
|
||||
label: t("projectStatus.cancelled"),
|
||||
variant: "danger",
|
||||
},
|
||||
};
|
||||
const handleChange = async (newStatus) => {
|
||||
if (newStatus === status) {
|
||||
@@ -50,11 +54,19 @@ export default function ProjectStatusDropdown({
|
||||
setIsOpen(false);
|
||||
|
||||
try {
|
||||
await fetch(`/api/projects/${project.project_id}`, {
|
||||
const updateData = { ...project, project_status: newStatus };
|
||||
|
||||
const response = await fetch(`/api/projects/${project.project_id}`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ ...project, project_status: newStatus }),
|
||||
body: JSON.stringify(updateData),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
console.error('Update failed:', errorData);
|
||||
}
|
||||
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
console.error("Failed to update status:", error);
|
||||
|
||||
Reference in New Issue
Block a user