{/* Drop area */}
diff --git a/app/(dashboard)/task/component/FormUpdateStatus.tsx b/app/(dashboard)/task/component/FormUpdateStatus.tsx
deleted file mode 100644
index ec11140..0000000
--- a/app/(dashboard)/task/component/FormUpdateStatus.tsx
+++ /dev/null
@@ -1,141 +0,0 @@
-import { useState, type FC } from 'react';
-import {
- AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle
-} from "@/components/ui/alert-dialog"
-import { Button } from '@/components/ui/button';
-import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from '@/components/ui/select';
-import { Textarea } from '@/components/ui/textarea';
-import * as Yup from 'yup'
-import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form";
-import { yupResolver } from '@hookform/resolvers/yup';
-import { useForm } from 'react-hook-form';
-import { IProjectAssignment } from '../type.assignment';
-import { DatePicker } from '@/components/ui/datepicker';
-import { Loader2 } from 'lucide-react';
-import { useFetchWithAxios } from '@/lib/axios/useFetch';
-import { IStatus } from '../types';
-import { Skeleton } from '@/components/ui/skeleton';
-import { serverApiCall } from '@/lib/server-api';
-import { toast } from 'sonner';
-import dayjs from 'dayjs';
-
-const validationSchema = Yup.object().shape({
- project_status_id: Yup.string().required(),
- date: Yup.date().required('Date is required'),
- note: Yup.string().optional().default(''),
-});
-
-type FormDataType = Yup.InferType
;
-
-type Props = {
- title: string
- data?: IProjectAssignment
- onCancel?: VoidFunction
- onSuccess?: VoidFunction;
-};
-
-const FormUpdateStatus: FC = ({ title, data, onCancel, onSuccess }) => {
- const [isLoading, setIsLoading] = useState(false)
-
- const { data: statusList, isLoading: isLoadingStatus } = useFetchWithAxios('/project-assignment-status')
- const form = useForm({
- resolver: yupResolver(validationSchema),
- });
-
- const onSubmit = async (payload: FormDataType) => {
-
- setIsLoading(true);
- const newPayload = {
- "project_status_id": Number(payload.project_status_id),
- "date": dayjs(payload.date).format('YYYY-MM-DD'),
- "note": payload.note,
- "remarks": payload.note
- }
- const res = await serverApiCall('PUT', `/project-assignment/status/${data?.id}`, newPayload)
-
- setIsLoading(false)
- if (res.success) {
- toast.success('Client saved successfully')
- onSuccess!()
- } else {
- toast.error(`Fail to save client`, { description: `(${res.code || '-'}) ${res.message}` })
- }
- }
-
- return (
- <>
-
-
-
- Update Status
-
- Update the current status for {title}
-
-
- {isLoadingStatus ?
-
-
-
-
-
-
-
- :
-
-
- }
-
-
- >
- );
-}
-
-export default FormUpdateStatus;
\ No newline at end of file
diff --git a/app/(dashboard)/task/component/HomeTask.tsx b/app/(dashboard)/task/component/HomeTask.tsx
index c389437..0ab0e9e 100644
--- a/app/(dashboard)/task/component/HomeTask.tsx
+++ b/app/(dashboard)/task/component/HomeTask.tsx
@@ -1,4 +1,3 @@
-// app/clients/components/dashboard-shell.tsx
"use client"
import { useState } from 'react';
diff --git a/app/(dashboard)/task/component/UpdateTimelineStatus.tsx b/app/(dashboard)/task/component/UpdateTimelineStatus.tsx
new file mode 100644
index 0000000..1a306c4
--- /dev/null
+++ b/app/(dashboard)/task/component/UpdateTimelineStatus.tsx
@@ -0,0 +1,208 @@
+import { useState, type FC } from 'react';
+import {
+ AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle
+} from "@/components/ui/alert-dialog"
+import { Button } from '@/components/ui/button';
+import { Textarea } from '@/components/ui/textarea';
+import * as Yup from 'yup'
+import { yupResolver } from '@hookform/resolvers/yup';
+import { useForm } from 'react-hook-form';
+import { DatePicker } from '@/components/ui/datepicker';
+import { Edit2, Loader2, Save, X } from 'lucide-react';
+import { useFetchWithAxios } from '@/lib/axios/useFetch';
+import { Skeleton } from '@/components/ui/skeleton';
+import { serverApiCall } from '@/lib/server-api';
+import { toast } from 'sonner';
+import { useRouter } from 'next/navigation';
+import {
+ Table, TableBody, TableCell, TableHead, TableHeader, TableRow
+} from "@/components/ui/table";
+import BadgeStatus from '@/components/ui/badge-status';
+
+const validationSchema = Yup.object().shape({
+ project_status_id: Yup.string().required(),
+ date: Yup.date().required('Date is required'),
+ note: Yup.string().optional().default(''),
+});
+
+type FormDataType = Yup.InferType;
+
+type Props = {
+ assignmentId: string | number
+ onClose?: VoidFunction
+};
+
+const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => {
+ const [editingId, setEditingId] = useState(null);
+ const [draftData, setDraftData] = useState({});
+ const [isSaving, setIsSaving] = useState(false);
+
+ const { data: existTimeline, isLoading: isLoadingTimeline, mutate } = useFetchWithAxios(`project-assignment/status-detail/${assignmentId}`)
+
+ const form = useForm({
+ resolver: yupResolver(validationSchema),
+ });
+
+ const router = useRouter()
+
+ const handleEdit = (row: any) => {
+ setEditingId(row.id);
+
+ setDraftData({
+ start_date_assign: row.start_date_assign,
+ end_date_assign: row.end_date_assign,
+ "note": draftData.note,
+ "remarks": draftData.note
+ });
+ };
+
+ const handleSave = async () => {
+ setIsSaving(true);
+
+ const submitPayload = {
+ "project_status_id": Number(draftData.project_status_id),
+ "start_date": draftData.start_date_assign ? new Date(draftData.start_date_assign).toISOString() : '',
+ "end_date": draftData.end_date_assign ? new Date(draftData.end_date_assign).toISOString() : '',
+ "note": draftData.note,
+ "remarks": draftData.note
+ }
+
+ console.log(submitPayload)
+ const res = await serverApiCall('PUT', `/project-assignment/status/${draftData.id}`, submitPayload)
+
+ setIsSaving(false);
+ if (res.success) {
+ toast.success('Team updated successfully')
+ handleSuccess!()
+ } else {
+ toast.error(`Fail to save team`, { description: `(${res.code || '-'}) ${res.message}` })
+ }
+ };
+
+ const handleDraftChange = (field: any, value: string) => {
+ setDraftData((prev: any) => ({ ...prev, [field]: value }));
+ };
+
+ const handleCancel = () => {
+ setEditingId(null);
+ setDraftData({});
+ };
+
+
+ const handleSuccess = () => {
+ handleCancel()
+ mutate()
+ router.refresh()
+ }
+
+ return (
+ <>
+
+
+
+ Update Status
+
+ Update the timeline status for this assignment. You can also add a note or remark regarding this status change. This will help you keep track of the progress and any important information related to this assignment.
+
+
+
+
+
+
+ Status
+ Start Date
+ End Date
+ Note/Remarks
+ Action
+
+
+
+ {isLoadingTimeline ?
+
+
+
+
+
+
+
+ :
+ existTimeline.length === 0 ?
+
+
+
+ No team members have been added yet. Create a team to get started with project assignments
+
+
+
+ :
+ existTimeline.map((row: any) => {
+ const isEditing = editingId === row.id;
+ const isOtherRowEditing = editingId !== null && editingId !== row.id;
+
+ return (
+
+
+
+
+
+
+ {isEditing ?
+ handleDraftChange("start_date_assign", date as any)} />
+ :
+ {row.start_date_assign}
+ }
+
+
+
+ {isEditing ?
+ handleDraftChange("end_date_assign", date as any)} />
+ :
+ {row.end_date_assign}
+ }
+
+
+
+ {isEditing ?
+
+
+
+
+ {isEditing ?
+ <>
+
+
+ >
+ :
+ !isOtherRowEditing &&
+
+
+ }
+
+
+
+ );
+ })
+ }
+
+
+
+
+ Close
+
+
+
+ >
+ );
+}
+
+export default UpdateTimelineStatus;
\ No newline at end of file
diff --git a/app/(dashboard)/task/page.tsx b/app/(dashboard)/task/page.tsx
index e1c7fcf..381c964 100644
--- a/app/(dashboard)/task/page.tsx
+++ b/app/(dashboard)/task/page.tsx
@@ -1,4 +1,3 @@
-// app/clients/page.tsx
import { Suspense } from 'react';
import HomeTask from './component/HomeTask';
import ClientGrid from './component/ClientGrid';
diff --git a/app/(dashboard)/task/types.ts b/app/(dashboard)/task/types.ts
index 5029b2f..d47691e 100644
--- a/app/(dashboard)/task/types.ts
+++ b/app/(dashboard)/task/types.ts
@@ -10,6 +10,7 @@ export type IEndUser = {
export type IClient = {
id?: string;
name: string;
+ description?: string;
end_user_id?: number
photo?: string
code?: string