feat: enhance task creation and editing with success/error toasts

- Added success and error toast notifications for task creation in CreateTaskDialog.
- Implemented success and error toast notifications for task updates in EditTaskDialog.
- Integrated custom toast notifications in MentorProjectCard for project archiving.
- Removed unused mock data files related to projects, interns, deadlines, and certificates.
- Updated useProjectTasks hook to accept projectId as a number instead of a string.
- Improved error handling in useSubmission hook methods to throw errors instead of returning null.
This commit is contained in:
Kemas M. Aryadary Rasyad
2026-07-06 20:38:30 +07:00
parent 8f5fb82f59
commit 7a331b8e7d
27 changed files with 500 additions and 913 deletions
+15 -6
View File
@@ -1,21 +1,30 @@
import { useProjectTasks, useCreateTask, useDeleteTask } from '../../../hooks/useTasks';
import { useProjectTasks, useDeleteTask } from '../../../hooks/useTasks';
import type { ProjectDetail } from '../../../types/project.types';
import type { ProjectTask } from '../../../types/task.types';
import { ClipboardList, Pencil, Trash2 } from 'lucide-react';
import { useState } from 'react';
import CreateTaskModal from './components/CreateTaskDialog';
import EditTaskModal from './components/EditTaskDialog';
import { customToast } from '../../utils/showToast';
export default function TaskTab({ project }: { project: ProjectDetail }) {
const { tasks, loading, error, refetch } = useProjectTasks(String(project.id));
const { tasks, loading, error, refetch } = useProjectTasks(project.id);
const { remove } = useDeleteTask();
const [isModalOpen, setIsModalOpen] = useState(false);
const [editModalOpen, setEditModalOpen] = useState(false);
const [selectedTask, setSelectedTask] = useState<ProjectTask | null>(null);
const handleDeleteTask = async (taskId: number) => {
const ok = await remove(taskId, String(project.id));
if (ok) refetch();
const handleDeleteTask = async (taskId: number,taskTitle: string) => {
const del = await remove(taskId, String(project.id));
if (del) {
try {
customToast.success("Berhasil", `Task ${taskTitle} berhasil dihapus`)
} catch (error) {
customToast.error("Gagal", `Task ${taskTitle} gagal dihapus`)
} finally {
refetch();
}
}
};
if (loading) return (
@@ -61,7 +70,7 @@ export default function TaskTab({ project }: { project: ProjectDetail }) {
<Pencil size={20} />
</button>
<button
onClick={() => handleDeleteTask(task.id)}
onClick={() => handleDeleteTask(task.id, task.title)}
className="hover:text-red-600 transition-colors p-1"
>
<Trash2 size={20} />