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 2cbd39d..8671faa 100644
--- a/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx
+++ b/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx
@@ -30,6 +30,7 @@ export default async function ClientDetailPage({ params, searchParams }: Props)
const [client, assignmentList] = await Promise.all([getClientById, getAssignmentsByClient]);
+ console.log(assignmentList)
if (!client) {
return (
diff --git a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/ProjectMilestoneTimeline.tsx b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/ProjectMilestoneTimeline.tsx
index cef9cb9..65f111c 100644
--- a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/ProjectMilestoneTimeline.tsx
+++ b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/ProjectMilestoneTimeline.tsx
@@ -17,8 +17,9 @@ interface ProjectMilestoneTimelineProps {
function formatDetailDate(detail?: ProjectAssignmentStatusDetail | null): string {
if (!detail) return '';
- if (Array.isArray(detail.date) && detail.date.length > 0) {
- const validDates = detail.date.filter((d) => Boolean(d?.start_date || d?.end_date));
+ const dateArray = Array.isArray(detail.data) ? detail.data : Array.isArray(detail.date) ? detail.date : null;
+ if (dateArray && dateArray.length > 0) {
+ const validDates = dateArray.filter((d) => Boolean(d?.start_date || d?.end_date));
if (validDates.length > 0) {
const first = validDates[0];
const last = validDates[validDates.length - 1];
@@ -96,8 +97,9 @@ export function ProjectMilestoneTimeline({
const devDates = useMemo(() => {
const list: string[] = [];
if (devDetail) {
- if (Array.isArray(devDetail.date) && devDetail.date.length > 0) {
- devDetail.date.forEach((item) => {
+ const dateArray = Array.isArray(devDetail.data) ? devDetail.data : Array.isArray(devDetail.date) ? devDetail.date : null;
+ if (dateArray && dateArray.length > 0) {
+ dateArray.forEach((item) => {
if (item?.start_date && dayjs(item.start_date).isValid()) {
const f = dayjs(item.start_date).format('D MMM YYYY');
if (!list.includes(f)) list.push(f);
diff --git a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx
index 5310544..00362b6 100644
--- a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx
+++ b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx
@@ -15,6 +15,7 @@ export default async function AssignmentDetailPage({ params }: Props) {
const [client, assignment] = await Promise.all([getClientById, getAssignmentById]);
+ console.log(assignment)
// 3. Handle 404 Securely on the server
if (!assignment) {
return (
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 59ef240..c6c1301 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
@@ -103,7 +103,7 @@ export default function ProjectAssignmentForm(
description: '',
workOrder: {
name: '',
- code: '',
+ code: 'WO-01',
description: '',
}
},
@@ -115,7 +115,7 @@ export default function ProjectAssignmentForm(
const { data: clientList, mutate: mutateClientList } = useFetchWithAxios('/client')
const { data: endUserList, mutate: mutateEndUserList } = useFetchWithAxios('/end-user')
- const { data: projectList, mutate: mutateProjectList } = useFetchWithAxios(`/client/project/${formValues.client_id}`)
+ const { data: projectList } = useFetchWithAxios(`/client/project/${formValues.client_id}`)
// Sync work order name when "Same as Project Name" is enabled
useEffect(() => {
@@ -333,8 +333,11 @@ export default function ProjectAssignmentForm(
async function getWOCode() {
const res = await serverApiCall('GET', `/project-assignment/project-sequences?project_id=${isExistProject?.id}`)
- if (res.success) form.setValue('workOrder.code' as any, String((res.data as any)?.data))
- else form.setValue('workOrder.code' as any, "")
+ if (res.success) {
+ const squence = (res.data as any)?.data > 9 ? `WO-${(res.data as any)?.data}` : `WO-0${(res.data as any)?.data}`
+ form.setValue('workOrder.code' as any, squence)
+ }
+ else form.setValue('workOrder.code' as any, "WO-01")
}
getWOCode();
@@ -631,7 +634,7 @@ export default function ProjectAssignmentForm(
setOpenProjectSearch(false);
setIsExistProject(p);
- toast.info(`Autofilled details from ${p.name}`, { duration: 1500 });
+ toast.info(`Autofilled details from ${p.name}`, { duration: 1200 });
}}
className="cursor-pointer py-2.5 px-3"
>
@@ -702,7 +705,7 @@ export default function ProjectAssignmentForm(
setOpenProjectSearch(false);
setIsExistProject(p);
- toast.info(`Switched project to ${p.name}`, { duration: 1500 });
+ toast.info(`Switched project to ${p.name}`, { duration: 1200 });
}}
className="cursor-pointer py-2.5 px-3"
>
@@ -929,9 +932,6 @@ export default function ProjectAssignmentForm(
WO Code
-
- Prefix: {projectCode}-
-
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 4c2bd4c..ea7e45d 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
@@ -64,7 +64,7 @@ export default function WorkOrderCard({ workOrder, index, defaultOpen = false }:
setAction(undefined);
};
- const statusList = workOrder.project_assignment_status_detail?.filter(status => Boolean(status.start_date || (Array.isArray(status.date) && status.date.length > 0))) || [];
+ const statusList = workOrder.project_assignment_status_detail?.filter(status => Boolean(status.start_date || (Array.isArray(status.data) && status.data.length > 0) || (Array.isArray(status.date) && status.date.length > 0))) || [];
const team = workOrder.project_assignment_work_order_detail ?? [];
const span = formatSpan(workOrder.wo_start_date, workOrder.wo_end_date);
const shownAvatars = team.slice(0, 4);
diff --git a/app/(dashboard)/task/component/UpdateTechnicalStatus.tsx b/app/(dashboard)/task/component/UpdateTechnicalStatus.tsx
index ae74ca9..e261373 100644
--- a/app/(dashboard)/task/component/UpdateTechnicalStatus.tsx
+++ b/app/(dashboard)/task/component/UpdateTechnicalStatus.tsx
@@ -34,6 +34,7 @@ import dayjs from 'dayjs';
export interface IDateInterval {
start_date: string;
end_date: string;
+ description?: string;
}
export interface IProjectAssignmentTimeline {
@@ -41,6 +42,7 @@ export interface IProjectAssignmentTimeline {
start_date: string | null;
end_date: string | null;
date?: IDateInterval[] | string | null;
+ data?: IDateInterval[] | string | null;
description?: string | null;
updated_at?: string | null;
project_assignment_status: ProjectAssignmentStatus;
@@ -81,7 +83,7 @@ interface ModalState {
function extractDatesFromRow(row: any): IDateInterval[] {
if (!row) return [];
- let rawDate = row.date;
+ let rawDate = row.data ?? row.date;
if (typeof rawDate === 'string') {
try {
rawDate = JSON.parse(rawDate);
@@ -95,7 +97,12 @@ function extractDatesFromRow(row: any): IDateInterval[] {
.filter(Boolean)
.map((item: any) => ({
start_date: item?.start_date ? dayjs(item.start_date).format('YYYY-MM-DD') : '',
- end_date: item?.end_date ? dayjs(item.end_date).format('YYYY-MM-DD') : ''
+ end_date: item?.end_date ? dayjs(item.end_date).format('YYYY-MM-DD') : '',
+ description: typeof item?.description === 'string'
+ ? item.description.trim()
+ : typeof row.description === 'string'
+ ? row.description.trim()
+ : '',
}))
.filter((d: IDateInterval) => Boolean(d.start_date || d.end_date));
}
@@ -103,7 +110,8 @@ function extractDatesFromRow(row: any): IDateInterval[] {
if (row.start_date || row.end_date) {
return [{
start_date: row.start_date ? dayjs(row.start_date).format('YYYY-MM-DD') : '',
- end_date: row.end_date ? dayjs(row.end_date).format('YYYY-MM-DD') : ''
+ end_date: row.end_date ? dayjs(row.end_date).format('YYYY-MM-DD') : '',
+ description: typeof row.description === 'string' ? row.description.trim() : '',
}];
}
@@ -154,6 +162,7 @@ function EditTechnicalStatusModal({ assignmentId, data, onClose, onSuccess }: Ed
const newInterval: IDateInterval = {
start_date: startDate ? dayjs(startDate).format('YYYY-MM-DD') : '',
end_date: endDate ? dayjs(endDate).format('YYYY-MM-DD') : '',
+ description: description.trim(),
};
// Retain all existing dates and append the new one
finalDates.push(newInterval);
@@ -161,6 +170,7 @@ function EditTechnicalStatusModal({ assignmentId, data, onClose, onSuccess }: Ed
const updatedInterval: IDateInterval = {
start_date: startDate ? dayjs(startDate).format('YYYY-MM-DD') : '',
end_date: endDate ? dayjs(endDate).format('YYYY-MM-DD') : '',
+ description: description.trim(),
};
// Update only the targeted date, preserve all other existing dates
finalDates = finalDates.map((item, idx) =>
@@ -171,8 +181,7 @@ function EditTechnicalStatusModal({ assignmentId, data, onClose, onSuccess }: Ed
const submitPayload = {
project_assignment_technical_status_id: Number(data.technicalId),
project_assignment_status_detail_id: Number(data.detailId),
- date: finalDates,
- description: description.trim()
+ data: finalDates,
};
const res = await serverApiCall('PUT', `/project-assignment/technical-status/${assignmentId}`, submitPayload);
@@ -192,8 +201,8 @@ function EditTechnicalStatusModal({ assignmentId, data, onClose, onSuccess }: Ed
const modalTitle = data.mode === 'ADD' ? 'Add Schedule' : 'Edit Schedule';
const modalDescription = data.mode === 'ADD'
- ? `Add a new schedule interval for ${data.statusName}. Previously recorded dates will be retained.`
- : `Update the selected schedule interval and deliverable notes.`;
+ ? `Add a new schedule interval and description for ${data.statusName}. Previously recorded dates will be retained.`
+ : `Update the selected schedule interval and description.`;
return (