feat:change all section color
This commit is contained in:
@@ -1,24 +1,33 @@
|
||||
import {
|
||||
useDeleteProject,
|
||||
useProjects,
|
||||
useUpdateProject,
|
||||
} from "@/hooks/queires/useProjects";
|
||||
import { useState } from "react";
|
||||
import { useProjects, useUpdateProject, useDeleteProject } from "@/hooks/queires/useProjects";
|
||||
|
||||
import { T_projects } from "@/types/projects.type";
|
||||
import { ProjectCard } from "./ProjectCard";
|
||||
import { EditProjectModal } from "./EditProjectModal";
|
||||
import { ProjectCard } from "./ProjectCard";
|
||||
|
||||
export default function ManageProject() {
|
||||
const { data: projectsData, isLoading } = useProjects();
|
||||
const updateMutation = useUpdateProject();
|
||||
const deleteMutation = useDeleteProject();
|
||||
|
||||
const [selectedProject, setSelectedProject] = useState<T_projects | null>(null);
|
||||
const [selectedProject, setSelectedProject] = useState<T_projects | null>(
|
||||
null,
|
||||
);
|
||||
|
||||
const projects: T_projects[] = projectsData?.data?.data?.result || [];
|
||||
|
||||
const handleUpdate = (data: Partial<T_projects>) => {
|
||||
if (selectedProject) {
|
||||
updateMutation.mutate({ id: selectedProject.id, data }, {
|
||||
onSuccess: () => setSelectedProject(null)
|
||||
});
|
||||
updateMutation.mutate(
|
||||
{ id: selectedProject.id, data },
|
||||
{
|
||||
onSuccess: () => setSelectedProject(null),
|
||||
},
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,33 +37,38 @@ export default function ManageProject() {
|
||||
}
|
||||
};
|
||||
|
||||
if (isLoading) return <div className="p-10 text-center animate-pulse">Loading Projects...</div>;
|
||||
if (isLoading)
|
||||
return (
|
||||
<div className="p-10 text-center animate-pulse">Loading Projects...</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="p-8 max-w-5xl mx-auto">
|
||||
<header className="mb-10">
|
||||
<h1 className="text-4xl font-extrabold neon-text-glow">Manage Projects</h1>
|
||||
<p className="text-muted-foreground">Edit, update or remove your portfolio items.</p>
|
||||
<h1 className="text-4xl font-extrabold">Manage Projects</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Edit, update or remove your portfolio items.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<div className="grid grid-cols-1 gap-6">
|
||||
{projects.map((item) => (
|
||||
<ProjectCard
|
||||
key={item.id}
|
||||
project={item}
|
||||
onEdit={setSelectedProject}
|
||||
<ProjectCard
|
||||
key={item.id}
|
||||
project={item}
|
||||
onEdit={setSelectedProject}
|
||||
onDelete={handleDelete}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{selectedProject && (
|
||||
<EditProjectModal
|
||||
project={selectedProject}
|
||||
onClose={() => setSelectedProject(null)}
|
||||
<EditProjectModal
|
||||
project={selectedProject}
|
||||
onClose={() => setSelectedProject(null)}
|
||||
onSave={handleUpdate}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user