From d61e424012b198bf844ca67ad4e1958f778d01d8 Mon Sep 17 00:00:00 2001 From: Ichsan Kurniawan Date: Mon, 27 Apr 2026 18:33:20 +0700 Subject: [PATCH] Refactor task UI, forms and team/status flows Consolidate and improve client/task UI and related forms: - Replace/rename modal components: use ManageTeam and UpdateTimelineStatus consistently (replace previous ManageEmployee/FormUpdateStatus imports/usages). - ClientDetail: update grid layout, add End User column in table view, guard status with optional chaining, adjust avatar size, and minor label tweaks. - Project/Assignment forms: add end_user_id to assignment schema and form, fetch end-users, integrate ComboboxCustomUI and lazy image rendering for end-user selection, allow creating end-user inline, and fix autofill mappings for project selection. Improve loading handling and payload construction for create/update flows. - Project assignments page: switch to fetching project list endpoint and pass correct project type to form. - WorkOrderCard & AssignmentDetail: optional chaining for status, use correct selected IDs for modals, and ensure ManageTeam receives real assignment id. - ManageTeam: update data shape (field renames: fullname, position, start_date, end_date, status strings), change PUT endpoint for updating assignment user, improve empty-state copy and avatar/fallback handling, adjust status select values. - UpdateTimelineStatus: remove unused form, adjust payload mapping, make dialog scrollable, tweak layout and textarea sizing. - AssignmentTable & ClientDetail table: adjust column widths, truncation classes, and use assignment.end_user where appropriate. - Small UX/cleanup: hide category filter on HomeTask, comment out end_user in FormClient, minor spacing/formatting cleanups, and a temporary console.log in page.tsx. These changes improve UI consistency, add explicit end-user handling across forms, harden status access with optional chaining, and align API usages and data shapes for team/status operations. --- .../(main)/ClientDetailComponent.tsx | 28 +++--- .../client-detail/[client_id]/(main)/page.tsx | 15 +-- .../AssignmentDetailComponent.tsx | 6 +- .../ProjectAssignmentForm.tsx | 92 ++++++++++++++----- .../[client_id]/project-assignments/page.tsx | 5 +- .../[project_id]/WorkOrderCard.tsx | 7 +- .../project-detail/[project_id]/page.tsx | 4 +- app/(dashboard)/task/component/AddTeam.tsx | 10 +- .../task/component/AssignmentTable.tsx | 24 ++--- app/(dashboard)/task/component/ClientGrid.tsx | 1 - app/(dashboard)/task/component/FormClient.tsx | 8 +- app/(dashboard)/task/component/HomeTask.tsx | 2 +- app/(dashboard)/task/component/ManageTeam.tsx | 49 +++++----- .../task/component/UpdateTimelineStatus.tsx | 23 ++--- app/(dashboard)/task/type.assignment.ts | 2 +- components/ui/combobox-custom-ui.tsx | 2 +- 16 files changed, 155 insertions(+), 123 deletions(-) diff --git a/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx b/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx index 1031522..1ab1946 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx @@ -13,12 +13,12 @@ import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; import Link from 'next/link'; import { LazyImage } from '@/components/ui/lazy-image'; import { IProjectAssignment } from '../../../type.assignment'; -import ManageEmployee from '../../../component/AddTeam'; import { useRouter } from 'next/navigation'; -import FormUpdateStatus from '../../../component/UpdateTimelineStatus'; import BadgeStatus from '@/components/ui/badge-status'; import FilterComponent from '../../../component/FilterComponent'; import { ConfirmDeleteWithInput } from '@/components/modal/ConfirmDeleteWithInput'; +import UpdateTimelineStatus from '../../../component/UpdateTimelineStatus'; +import { ManageTeam } from '../../../component/ManageTeam'; interface Props { clientId: string; @@ -84,7 +84,7 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro : viewMode === 'grid' ? /* --- GRID VIEW --- */ -
+
{assignmentLists.map((assignment) => { const isProject = assignment.wo_name @@ -93,12 +93,12 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro const assignmentStartDate = assignment.wo_start_date || assignment.im_start_date const assignmentEndDate = assignment.wo_end_date || assignment.im_end_date const assignmentDesc = assignment.wo_description || assignment.im_description - const assignmentStatus = assignment.project?.status || assignment.project_status.name + const assignmentStatus = assignment.project?.status || assignment.project_status?.name return ( - - - + + +
@@ -109,7 +109,7 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro

{assignmentName}

{!isProject ? {assignmentType} : null} - + {assignmentStatus ? : null}
{assignment.wo_name && @@ -143,7 +143,7 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro
- +
@@ -185,7 +185,7 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro Edit Assignment e.stopPropagation()} onSelect={() => { setSelectedData(assignment); setAction('MANAGE_EMPLOYEE') }}>Manage Team - e.stopPropagation()} onSelect={() => { setSelectedData(assignment); setAction('UPDATE_STATUS') }}>Update Assignment Status + e.stopPropagation()} onSelect={() => { setSelectedData(assignment); setAction('UPDATE_STATUS') }}>Update Status e.stopPropagation()} onSelect={() => { setSelectedData(assignment); setAction('DELETE') }} className="text-destructive">Delete @@ -205,6 +205,7 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro + End User IM Name IM Code Description @@ -230,6 +231,7 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro {assignmentLists.map((assignment) => { return ( + {assignment.end_user?.name} {assignment.im_name} {assignment.im_code || ''} @@ -296,7 +298,7 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro - + @@ -335,12 +337,12 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro } {action === 'MANAGE_EMPLOYEE' ? - + : null } {action === 'UPDATE_STATUS' ? - + : null } diff --git a/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx b/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx index eafbb30..569fba6 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx @@ -32,6 +32,8 @@ export default async function ClientDetailPage({ params, searchParams }: Props) const [client, assignmentList] = await Promise.all([getClientById, getAssignmentsByClient]); + console.log(client) + if (!client) { return (
@@ -105,7 +107,7 @@ export default async function ClientDetailPage({ params, searchParams }: Props)

{client.name}

-

End User: {client.end_user_name}

+

{client?.description || 'No description available for this client!'}

@@ -117,18 +119,19 @@ export default async function ClientDetailPage({ params, searchParams }: Props)
-
+ + {/*
- {/* --- INTERACTIVE CLIENT COMPONENT (Grid/Table & Modals) --- */}
- {/* Pass the server-fetched data as props */}
- {/* --- STATIC SERVER SIDEBAR --- */}
@@ -171,7 +174,7 @@ export default async function ClientDetailPage({ params, searchParams }: Props)
-
+
*/} ); } \ No newline at end of file diff --git a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx index ab3b85b..f053e9f 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx @@ -13,11 +13,11 @@ import { useRouter } from 'next/navigation'; import { IClient } from '../../../types'; import { IProjectAssignment } from '../../../type.assignment'; import { useState } from 'react'; -import FormUpdateStatus from '../../../component/UpdateTimelineStatus'; import BadgeStatus from '@/components/ui/badge-status'; import Link from 'next/link'; import AssignedPeople from '../project-detail/[project_id]/AssignedPeople'; import { ManageTeam } from '../../../component/ManageTeam'; +import UpdateTimelineStatus from '../../../component/UpdateTimelineStatus'; interface Props { client: IClient | undefined; @@ -39,7 +39,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment const assignmentStartDate = assignment.wo_start_date || assignment.im_start_date const assignmentEndDate = assignment.wo_end_date || assignment.im_end_date const assignmentDesc = assignment.wo_description || assignment.im_description - const assignmentStatus = assignment.project?.status || assignment.project_status.name + const assignmentStatus = assignment.project?.status || assignment.project_status?.name const handleClose = () => { setSelectedData(undefined) @@ -235,7 +235,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment {action === 'UPDATE_STATUS' ? - + : null } diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-assignments/ProjectAssignmentForm.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-assignments/ProjectAssignmentForm.tsx index 186330f..4413f82 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/project-assignments/ProjectAssignmentForm.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/project-assignments/ProjectAssignmentForm.tsx @@ -5,7 +5,7 @@ import { useRouter } from 'next/navigation'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import { motion, AnimatePresence } from 'motion/react'; -import { ArrowLeft, ArrowRight, Save, Briefcase, Clock, Search, Check } from 'lucide-react'; +import { ArrowLeft, ArrowRight, Save, Briefcase, Clock, Search, Check, CheckCircle, Plus } from 'lucide-react'; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form'; import { Button } from '@/components/ui/button'; @@ -25,11 +25,16 @@ import { toast } from 'sonner'; import { cn } from '@/lib/utils'; import { Label } from '@/components/ui/label'; import * as yup from 'yup'; -import { IClient } from '../../../types'; +import { IClient, IEndUser } from '../../../types'; import { serverApiCall } from '@/lib/server-api'; import dayjs from 'dayjs'; import PageLoading from '@/components/loader/PageLoading'; import { IProjectAssignment } from '../../../type.assignment'; +import { useFetchWithAxios } from '@/lib/axios/useFetch'; +import { ComboboxCustomUI } from '@/components/ui/combobox-custom-ui'; +import { LazyImage } from '@/components/ui/lazy-image'; +import FormEndUser from '../../../component/FormEndUser'; +import { IProject } from '../../../type.project'; type IStep = 'type' | 'details' | 'work-orders' | 'review'; @@ -37,6 +42,7 @@ export const assignmentSchema = yup.object({ type: yup.string().oneOf(['Project', 'IM']).required('Project type is required'), // Details Step + end_user_id: yup.number().required('End user is required'), name: yup.string().required('Assignment name is required'), code: yup.string().required('Project code is required'), year: yup.string().required('Year is required'), @@ -61,18 +67,19 @@ export const assignmentSchema = yup.object({ // Infer the TypeScript type from the Yup schema export type AssignmentFormValues = yup.InferType; -export default function CreateAssignmentForm({ client, clientId, projectList, isEdit, assignmentId }: { client: IClient, projectList: IProjectAssignment[], clientId: string, isEdit?: boolean, assignmentId?: string }) { +export default function CreateAssignmentForm({ client, clientId, projectList, isEdit, assignmentId }: { client: IClient, projectList: IProject[], clientId: string, isEdit?: boolean, assignmentId?: string }) { const [existAssignment, setIsExistAssignment] = useState(null) - - const router = useRouter(); - const [step, setStep] = useState('type'); const [loading, setIsLoading] = useState(false); const [isFullLoading, setIsFullLoading] = useState(false) const [isExistProject, setIsExistProject] = useState(false) const [openProjectSearch, setOpenProjectSearch] = useState(false); + const [showEndUserForm, setShowEndUserForm] = useState(false) + + const router = useRouter(); + + const { data: endUserList, mutate } = useFetchWithAxios('/end-user') - // 1. Initialize React Hook Form const form = useForm({ resolver: yupResolver(assignmentSchema), defaultValues: { @@ -90,7 +97,6 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is mode: "onChange" }); - // Watch values for dynamic UI rendering const assignmentType = form.watch('type'); const formValues = form.watch(); @@ -111,11 +117,11 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is setIsFullLoading(true) const res: any = await serverApiCall('GET', `/project-assignment/${assignmentId}`) - setIsFullLoading(false) if (res.success) { const data: IProjectAssignment = res.data.data form.setValue('type', data.project?.code ? 'Project' : 'IM') form.setValue('name', data.project?.name || data.im_name) + form.setValue('end_user_id', data.end_user.id) form.setValue('code', data.project?.code || data.im_code) form.setValue('year', data.project?.year || data.im_year) form.setValue('startDate', data.project?.start_date || data.im_start_date) @@ -136,6 +142,7 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is description: `(${res.code || '-'}) ${res.message}` }) } + setIsFullLoading(false) } getAssignmentDetail() @@ -165,13 +172,12 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is else if (step === 'review') setStep(assignmentType === 'Project' ? 'work-orders' : 'details'); }; - // 4. Submission const onSubmit = async (payload: AssignmentFormValues) => { setIsLoading(true); const newPayload = { "client_id": Number(clientId), - "end_user_id": Number(client.end_user_id), + "end_user_id": Number(payload.end_user_id), "im_code": assignmentType === 'IM' ? payload.code : isEdit ? existAssignment?.im_code : "", "im_name": assignmentType === 'IM' ? payload.name : isEdit ? existAssignment?.im_name : "", "im_year": assignmentType === 'IM' ? Number(payload.year) : isEdit ? existAssignment?.im_year : 2026, @@ -197,8 +203,6 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is "note": isEdit ? existAssignment?.note : "", } - console.log(newPayload) - let res: any if (isEdit) { res = await serverApiCall('PUT', `/project-assignment/${assignmentId}`, newPayload) @@ -348,20 +352,20 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is { - form.setValue('name', p.project?.name!, { shouldValidate: true }); - form.setValue('code', p.project?.code!, { shouldValidate: true }); - form.setValue('year', p.project?.year!, { shouldValidate: true }); - form.setValue('startDate', new Date(p.project?.start_date!), { shouldValidate: true }); - form.setValue('endDate', new Date(p.project?.end_date!), { shouldValidate: true }); - form.setValue('description', p.project?.description!, { shouldValidate: true }); + form.setValue('name', p.name!, { shouldValidate: true }); + form.setValue('code', p.code!, { shouldValidate: true }); + form.setValue('year', String(p.year), { shouldValidate: true }); + form.setValue('startDate', new Date(p.start_date!), { shouldValidate: true }); + form.setValue('endDate', new Date(p.end_date!), { shouldValidate: true }); + form.setValue('description', p.description!, { shouldValidate: true }); setOpenProjectSearch(false); setIsExistProject(true) - toast.info(`Autofilled details from ${p.project?.name}`); + toast.info(`Autofilled details from ${p.name}`); }} > - - {p?.project?.name!} + + {p?.name!} ))} @@ -378,6 +382,46 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is )} /> + ( + + End User + +
+ 0 ? endUserList.map((item: IEndUser) => ({ label: item.name, value: item.id, originalData: item })) : []} + value={field.value} onChange={field.onChange} placeholder='Select end user' className='shrink' + + // --- CUSTOM DROPDOWN OPTIONS --- + renderOption={(option, isSelected) => { + const user = option.originalData as IEndUser; + return ( +
+
+ +
+ + {user.name} + + + {user.description} + +
+
+ {isSelected && } +
+ ); + }} + /> + +
+
+ +
+ )} + /> +
( @@ -572,9 +616,6 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is Back - {/* */}
{step !== 'review' ?
@@ -144,12 +145,12 @@ const WorkOrderCard = ({ workOrder, index, defaultOpen = false }: WorkOrderCardP {action === 'UPDATE_STATUS' ? - + : null } {action === 'MANAGE_EMPLOYEE' ? - + : null } diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/page.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/page.tsx index 30559b5..62e2d6e 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/page.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/page.tsx @@ -48,8 +48,8 @@ export default async function ProjectDetailPage({ params, searchParams }: Props) // Aggregate stats const totalWorkOrders = project.project_assignment.length; - const completedWO = project.project_assignment.filter((wo: any) => COMPLETE_STATUS_LIST.includes(wo.project_status.name.toUpperCase())).length; - const inProgressWO = project.project_assignment.filter((wo: any) => ONPROGRESS_STATUS_LIST.includes(wo.project_status.name.toUpperCase())).length; + const completedWO = project.project_assignment.filter((wo: any) => COMPLETE_STATUS_LIST.includes(wo.project_status?.name?.toUpperCase())).length; + const inProgressWO = project.project_assignment.filter((wo: any) => ONPROGRESS_STATUS_LIST.includes(wo.project_status?.name?.toUpperCase())).length; const totalAssigned = new Set( project.project_assignment.flatMap((wo: any) => wo.project_assignment_work_order_detail.map((p: any) => p.id), diff --git a/app/(dashboard)/task/component/AddTeam.tsx b/app/(dashboard)/task/component/AddTeam.tsx index 9b1bf0d..84c1611 100644 --- a/app/(dashboard)/task/component/AddTeam.tsx +++ b/app/(dashboard)/task/component/AddTeam.tsx @@ -16,7 +16,7 @@ import { yupResolver } from '@hookform/resolvers/yup'; import { useForm } from 'react-hook-form'; import { serverApiCall } from '@/lib/server-api'; import { toast } from 'sonner'; -import { Combobox } from '@/components/ui/combobox-custom-ui'; +import { ComboboxCustomUI } from '@/components/ui/combobox-custom-ui'; type Props = { assignmentId: number; @@ -26,7 +26,7 @@ type Props = { }; const validationSchema = Yup.object().shape({ - user: Yup.number().required('Please select at least one user'), + user_id: Yup.number().required('Please select at least one user'), }); type FormDataType = Yup.InferType; @@ -48,7 +48,7 @@ const AddTeam: FC = ({ assignmentId, existingTeam, onCancel, onSuccess }) const submitPayload = { data: [{ "project_assignment_id": assignmentId, - "user_id": payload.user, + "user_id": payload.user_id, "start_date": '', "end_date": '' }] @@ -96,12 +96,12 @@ const AddTeam: FC = ({ assignmentId, existingTeam, onCancel, onSuccess })
- ( Employee to Assign * - { const user = option.originalData as IUser; diff --git a/app/(dashboard)/task/component/AssignmentTable.tsx b/app/(dashboard)/task/component/AssignmentTable.tsx index cc29df9..ad60582 100644 --- a/app/(dashboard)/task/component/AssignmentTable.tsx +++ b/app/(dashboard)/task/component/AssignmentTable.tsx @@ -29,28 +29,28 @@ export default function AssignmentTable({ data }: { data: IProjectAssignment[] }
- Client - End User - IM Name + Client + End User + IM Name IM Code - Description + Description IM Year IM Start IM End - Project Name + Project Name Project Code - Description + Description Year Proj Start Proj End - Work Order + Work Order WO Code WO Start WO End Last Status Status Remarks Team - + @@ -62,10 +62,10 @@ export default function AssignmentTable({ data }: { data: IProjectAssignment[] } {assignment.client?.name} - {assignment.client?.end_user?.name} + {assignment.end_user.name} {assignment.im_name} {assignment.im_code || ''} - + {assignment.im_description} {assignment.im_year || ''} @@ -81,7 +81,7 @@ export default function AssignmentTable({ data }: { data: IProjectAssignment[] } {assignment.project?.code || ''} - + {assignment.project?.description} {assignment.project?.year || ''} @@ -100,7 +100,7 @@ export default function AssignmentTable({ data }: { data: IProjectAssignment[] } {assignment.wo_end_date ? new Date(assignment.wo_end_date).toLocaleDateString() : ''} - + {assignment.project_assignment_status_detail[0]?.status_remarks} diff --git a/app/(dashboard)/task/component/ClientGrid.tsx b/app/(dashboard)/task/component/ClientGrid.tsx index 4a3330c..3aea52d 100644 --- a/app/(dashboard)/task/component/ClientGrid.tsx +++ b/app/(dashboard)/task/component/ClientGrid.tsx @@ -29,7 +29,6 @@ export default function ClientGrid({ clients }: { clients: IClient[] }) { setShowSelectedData(undefined) } - return ( <> {clients.length === 0 ? diff --git a/app/(dashboard)/task/component/FormClient.tsx b/app/(dashboard)/task/component/FormClient.tsx index 0a9e242..7c9255e 100644 --- a/app/(dashboard)/task/component/FormClient.tsx +++ b/app/(dashboard)/task/component/FormClient.tsx @@ -23,7 +23,7 @@ import { Textarea } from '@/components/ui/textarea'; const validationSchema = Yup.object().shape({ name: Yup.string().required(), - end_user_id: Yup.number().required(), + // end_user_id: Yup.number().required(), description: Yup.string().optional().default(''), }); @@ -75,7 +75,7 @@ const FormClient: FC = ({ data, onSuccess, onCancel }) => { resolver: yupResolver(validationSchema), defaultValues: { "name": data?.name || '', - "end_user_id": data?.end_user_id || undefined, + // "end_user_id": data?.end_user_id || undefined, "description": data?.description || '', }, }); @@ -181,7 +181,7 @@ const FormClient: FC = ({ data, onSuccess, onCancel }) => { )} /> - ( End User * @@ -196,7 +196,7 @@ const FormClient: FC = ({ data, onSuccess, onCancel }) => { )} - /> + /> */} ( diff --git a/app/(dashboard)/task/component/HomeTask.tsx b/app/(dashboard)/task/component/HomeTask.tsx index 0ab0e9e..6f12345 100644 --- a/app/(dashboard)/task/component/HomeTask.tsx +++ b/app/(dashboard)/task/component/HomeTask.tsx @@ -64,7 +64,7 @@ export default function HomeTask({ currentView }: ShellProps) { - + {showForm && setShowForm(false)} onSuccess={() => { setShowForm(false); router.refresh() }} />} diff --git a/app/(dashboard)/task/component/ManageTeam.tsx b/app/(dashboard)/task/component/ManageTeam.tsx index 25b8224..4af733f 100644 --- a/app/(dashboard)/task/component/ManageTeam.tsx +++ b/app/(dashboard)/task/component/ManageTeam.tsx @@ -27,17 +27,15 @@ import { toast } from "sonner"; import { serverApiCall } from "@/lib/server-api"; -export type AssignmentStatus = "pending" | "in_progress" | "completed"; - export interface ITableData { id: string; - name: string; + fullname: string; email: string; avatar: string; - position: string; - start_date_assign: string; - end_date_assign: string; - status: AssignmentStatus; + position: any; + start_date: string; + end_date: string; + status: string } @@ -56,8 +54,8 @@ export function ManageTeam({ assignmentId, onClose }: { assignmentId: number, on setEditingId(row.id); setDraftData({ - start_date_assign: row.start_date_assign, - end_date_assign: row.end_date_assign, + start_date: row.start_date, + end_date: row.end_date, status: row.status, }); }; @@ -68,12 +66,12 @@ export function ManageTeam({ assignmentId, onClose }: { assignmentId: number, on const submitPayload = { "project_assignment_id": assignmentId, "status": draftData.status, - "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() : '', + "start_date": draftData.start_date ? new Date(draftData.start_date).toISOString() : '', + "end_date": draftData.end_date ? new Date(draftData.end_date).toISOString() : '', } console.log(submitPayload) - const res = await serverApiCall('PUT', `/project-assignment/assign-user/${draftData.id}`, submitPayload) + const res = await serverApiCall('PUT', `/project-assignment/assign-user/update/${draftData.id}`, submitPayload) setIsSaving(false); if (res.success) { @@ -138,9 +136,9 @@ export function ManageTeam({ assignmentId, onClose }: { assignmentId: number, on : existUserAssign.length === 0 ? - -
- No team members have been added yet. Create a team to get started with project assignments + +
+ No team members have been added yet.
Create a team to get started with project assignments
@@ -155,13 +153,13 @@ export function ManageTeam({ assignmentId, onClose }: { assignmentId: number, on
- - {row.name.charAt(0)} + + {row.fullname?.charAt(0)}
- {row.name} - {row.position} + {row.fullname} + {row.position?.name}
{row.email}
@@ -170,17 +168,17 @@ export function ManageTeam({ assignmentId, onClose }: { assignmentId: number, on {isEditing ? - handleDraftChange("start_date_assign", date as any)} /> + handleDraftChange("start_date", date as any)} /> : - {row.start_date_assign} + {row.start_date} } {isEditing ? - handleDraftChange("end_date_assign", date as any)} /> + handleDraftChange("end_date", date as any)} /> : - {row.end_date_assign} + {row.end_date} } @@ -191,9 +189,8 @@ export function ManageTeam({ assignmentId, onClose }: { assignmentId: number, on - Active - In Active - Completed + Active + In Active : diff --git a/app/(dashboard)/task/component/UpdateTimelineStatus.tsx b/app/(dashboard)/task/component/UpdateTimelineStatus.tsx index 1a306c4..b2f4895 100644 --- a/app/(dashboard)/task/component/UpdateTimelineStatus.tsx +++ b/app/(dashboard)/task/component/UpdateTimelineStatus.tsx @@ -19,13 +19,6 @@ import { } 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 @@ -39,10 +32,6 @@ const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => { 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) => { @@ -60,7 +49,7 @@ const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => { setIsSaving(true); const submitPayload = { - "project_status_id": Number(draftData.project_status_id), + "project_status_id": Number(draftData.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, @@ -98,11 +87,11 @@ const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => { 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. + + Update the timeline status for this assignment. You can also add a note or remark regarding this status change. This will help to keep track of the progress.
@@ -130,7 +119,7 @@ const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => {
- No team members have been added yet. Create a team to get started with project assignments + No team members have been added yet.
Create a team to get started with project assignments
@@ -163,7 +152,7 @@ const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => { {isEditing ? -