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 b6d0bac..902a271 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx @@ -8,14 +8,40 @@ import { Badge } from '@/components/ui/badge'; import Link from 'next/link'; import { IProjectAssignment } from '../../../type.assignment'; import { useRouter, useSearchParams } from 'next/navigation'; +import dynamic from 'next/dynamic'; import FilterComponent from '../../../component/FilterComponent'; -import { ConfirmDeleteWithInput } from '@/components/modal/ConfirmDeleteWithInput'; -import UpdateTechnicalStatus from '../../../component/UpdateTechnicalStatus'; -import UpdateAdministrationStatus from '../../../component/UpdateAdministrationStatus'; -import { ManageTeam } from '../../../component/ManageTeam'; import AssignmentGrid from '../../../component/project-assignment/AssignmentGrid'; import AssignmentList from '../../../component/project-assignment/AssignmentList'; +const ModalActionLoader = () => ( +
+
+ + Loading action... +
+
+); + +const ManageTeam = dynamic( + () => import('../../../component/ManageTeam').then((mod) => mod.ManageTeam), + { ssr: false, loading: () => } +); + +const UpdateAdministrationStatus = dynamic( + () => import('../../../component/UpdateAdministrationStatus'), + { ssr: false, loading: () => } +); + +const UpdateTechnicalStatus = dynamic( + () => import('../../../component/UpdateTechnicalStatus'), + { ssr: false, loading: () => } +); + +const ConfirmDeleteWithInput = dynamic( + () => import('@/components/modal/ConfirmDeleteWithInput').then((mod) => mod.ConfirmDeleteWithInput), + { ssr: false, loading: () => } +); + interface Props { clientId: string; assignmentLists: IProjectAssignment[]; 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 622b66d..7f41302 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 @@ -22,14 +22,37 @@ import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { LazyImage } from '@/components/ui/lazy-image'; import BadgeStatus from '@/components/ui/badge-status'; +import dynamic from 'next/dynamic'; import { cn } from '@/lib/utils'; import { IClient, CLIENT_FALLBACK_IMAGE, END_USER_FALLBACK_IMAGE } from '../../../types'; import { IProjectAssignment, ProjectAssignmentWorkOrderDetail } from '../../../type.assignment'; -import { ManageTeam } from '../../../component/ManageTeam'; -import UpdateTechnicalStatus from '../../../component/UpdateTechnicalStatus'; -import UpdateAdministrationStatus from '../../../component/UpdateAdministrationStatus'; +import ConvertedAssignmentBadge from '../../../component/project-assignment/ConvertedAssignmentBadge'; import Reveal from '@/components/ui/reveal'; +const ModalActionLoader = () => ( +
+
+ + Loading action... +
+
+); + +const ManageTeam = dynamic( + () => import('../../../component/ManageTeam').then((mod) => mod.ManageTeam), + { ssr: false, loading: () => } +); + +const UpdateAdministrationStatus = dynamic( + () => import('../../../component/UpdateAdministrationStatus'), + { ssr: false, loading: () => } +); + +const UpdateTechnicalStatus = dynamic( + () => import('../../../component/UpdateTechnicalStatus'), + { ssr: false, loading: () => } +); + interface Props { client: IClient | undefined; initialAssignment: IProjectAssignment; @@ -125,6 +148,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment {isWorkOrder ? : } {assignmentType} + {assignmentStatus ? : null} {assignmentCode ? ( 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 1a376df..a9c64b2 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 @@ -1,7 +1,7 @@ "use client" import { useState, useEffect } from 'react'; -import { useRouter, useSearchParams } from 'next/navigation'; +import { useRouter } from 'next/navigation'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import { motion, AnimatePresence } from 'motion/react'; @@ -176,34 +176,37 @@ export default function ProjectAssignmentForm( setSelectedClient(data.client as any); setSelectedEndUser(data.end_user as any); - form.setValue('name', data.project?.name || data.im_name || ''); - form.setValue('code', data.project?.code || data.im_code || ''); - form.setValue('year', String(data.project?.year || data.im_year || new Date().getFullYear())); - const sDate = data.project?.start_date || data.im_start_date; - const eDate = data.project?.end_date || data.im_end_date; - form.setValue('startDate', sDate ? new Date(sDate) : undefined as any); - form.setValue('endDate', eDate ? new Date(eDate) : undefined as any); - form.setValue('description', data.project?.description || data.im_description || ''); + if (!isPromote) { + form.setValue('name', data.project?.name || data.im_name || ''); + form.setValue('code', data.project?.code || data.im_code || ''); + form.setValue('year', String(data.project?.year || data.im_year || new Date().getFullYear())); + const sDate = data.project?.start_date || data.im_start_date; + const eDate = data.project?.end_date || data.im_end_date; + form.setValue('startDate', sDate ? new Date(sDate) : undefined as any); + form.setValue('endDate', eDate ? new Date(eDate) : undefined as any); + form.setValue('description', data.project?.description || data.im_description || ''); - const defaultWoName = data.wo_name; - form.setValue('workOrder.name' as any, data.wo_name); - let initialWoCode = data.wo_code || ''; - const prjCode = data.project?.code || data.im_code || ''; - if (prjCode && initialWoCode.startsWith(`${prjCode}-`)) { - initialWoCode = initialWoCode.slice(prjCode.length + 1); - } - form.setValue('workOrder.code' as any, initialWoCode); - const woSDate = data.wo_start_date; - const woEDate = data.wo_end_date; - form.setValue('workOrder.startDate' as any, woSDate ? new Date(woSDate) : undefined as any); - form.setValue('workOrder.endDate' as any, woEDate ? new Date(woEDate) : undefined as any); - form.setValue('workOrder.description' as any, data.wo_description); + const defaultWoName = data.wo_name; + form.setValue('workOrder.name' as any, data.wo_name); + let initialWoCode = data.wo_code || ''; + const prjCode = data.project?.code || data.im_code || ''; + if (prjCode && initialWoCode.startsWith(`${prjCode}-`)) { + initialWoCode = initialWoCode.slice(prjCode.length + 1); + } + form.setValue('workOrder.code' as any, initialWoCode); + const woSDate = data.wo_start_date; + const woEDate = data.wo_end_date; + form.setValue('workOrder.startDate' as any, woSDate ? new Date(woSDate) : undefined as any); + form.setValue('workOrder.endDate' as any, woEDate ? new Date(woEDate) : undefined as any); + form.setValue('workOrder.description' as any, data.wo_description); - if (defaultWoName.toLowerCase() === data.project?.name.toLowerCase()) { - setIsSameAsProject(true); + if (defaultWoName?.toLowerCase() === data.project?.name?.toLowerCase()) { + setIsSameAsProject(true); + } + } else { + setStep(isPromote ? 'details' : 'clients'); } - setStep(isPromote ? 'details' : 'clients'); setIsExistAssignment(res.data.data); } else { toast.error('Fail to get detail assignment', { @@ -579,7 +582,7 @@ export default function ProjectAssignmentForm( {/* Existing Project Selector / Linked Hero Card */} - {assignmentType === 'Project' && ( + {!isPromote && assignmentType === 'Project' && ( !isExistProject ? (
diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/WorkOrderCard.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/WorkOrderCard.tsx index 94ba271..4c2bd4c 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/WorkOrderCard.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/WorkOrderCard.tsx @@ -17,14 +17,36 @@ import { LazyImage } from '@/components/ui/lazy-image'; import StatusTimeline from './StatusTimeline'; import AssignedPeople from './AssignedPeople'; import BadgeStatus from '@/components/ui/badge-status'; +import dynamic from 'next/dynamic'; import { IProjectAssignment } from '@/app/(dashboard)/task/type.assignment'; -import UpdateTimelineStatus from '@/app/(dashboard)/task/component/UpdateTechnicalStatus'; -import UpdateAdministrationStatus from '@/app/(dashboard)/task/component/UpdateAdministrationStatus'; -import { ManageTeam } from '@/app/(dashboard)/task/component/ManageTeam'; import { cn } from '@/lib/utils'; import { COMPLETE_STATUS_LIST, ONPROGRESS_STATUS_LIST } from '@/app/(dashboard)/task/data'; import { avatarSrc, formatDate, formatSpan } from './format'; +const ModalActionLoader = () => ( +
+
+ + Loading action... +
+
+); + +const UpdateTimelineStatus = dynamic( + () => import('@/app/(dashboard)/task/component/UpdateTechnicalStatus'), + { ssr: false, loading: () => } +); + +const UpdateAdministrationStatus = dynamic( + () => import('@/app/(dashboard)/task/component/UpdateAdministrationStatus'), + { ssr: false, loading: () => } +); + +const ManageTeam = dynamic( + () => import('@/app/(dashboard)/task/component/ManageTeam').then((mod) => mod.ManageTeam), + { ssr: false, loading: () => } +); + interface WorkOrderCardProps { workOrder: IProjectAssignment; index: number;