diff --git a/.env.production.local b/.env.production.local
deleted file mode 100644
index c1256b2..0000000
--- a/.env.production.local
+++ /dev/null
@@ -1,21 +0,0 @@
-BASE_PATH = ""
-NEXT_PUBLIC_APP_URL="https://dev-hats.hisnutech.my.id"
-
-BASE_URL_API = https://api-hats-dev.hisnutech.my.id/api/v1
-BASE_URL_IMG = https://api-hats.hisnutech.my.id/
-
-NEXTAUTH_URL = https://dev-hats.hisnutech.my.id
-NEXTAUTH_URL_INTERNAL = http://36.66.3.44:7005
-
-NEXTAUTH_SECRET = 4339d50684523526005c1fcb34be0bb1
-
-FIREBASE_API_KEY = AIzaSyAEkZCHhnyatsNiZ2dpjeaz6JqXYknKKHk
-FIREBASE_APP_ID = "1:422528660020:web:db16e1cba4d357e32f1061"
-
-DEVICE_CODE = "40001"
-NEXT_PUBLIC_HATS_SUPPORT_NAME = "Amalia"
-NEXT_PUBLIC_HATS_SUPPORT_PHONE = "6285214074002"
-NEXT_PUBLIC_APP_VERSION = "v1.2.0"
-NEXT_PUBLIC_MANAGER_USER_ID = '2'
-
-NEXT_PUBLIC_S3_IMAGE_URL = https://cdn.hisnutech.my.id/public
\ 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 9d11605..622b66d 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
@@ -15,7 +15,7 @@ import Link from 'next/link';
import { useRouter } from 'next/navigation';
import dayjs from 'dayjs';
import {
- ArrowLeft, Briefcase, Calendar, ChevronDown, ClipboardCheck, Clock, ExternalLink, FileText,
+ ArrowLeft, ArrowUpRight, Briefcase, Calendar, ChevronDown, ClipboardCheck, Clock, ExternalLink, FileText,
FolderGit2, History, LayoutGrid, List, Mail, Phone, UserPlus, Users,
} from 'lucide-react';
import { Button } from '@/components/ui/button';
@@ -146,6 +146,18 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
+ {!isWorkOrder && (
+
+
+
+ Promote to Project
+
+
+ )}
setAction('UPDATE_ADMIN_STATUS')}
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 9190d28..1a376df 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,13 +1,13 @@
"use client"
import { useState, useEffect } from 'react';
-import { useRouter } from 'next/navigation';
+import { useRouter, useSearchParams } 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, CheckCircle,
- Plus, CheckCircle2, RotateCcw, X, ChevronDown, FolderGit2
+ Plus, CheckCircle2, RotateCcw, X, ChevronDown, FolderGit2, ArrowUpRight
} from 'lucide-react';
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
@@ -56,7 +56,7 @@ export const assignmentSchema = yup.object({
code: yup.string().required('Project code is required'),
year: yup.string().required('Year is required'),
startDate: yup.date().required('Start date is required'),
- endDate: yup.date().required().min(yup.ref('startDate'), 'End date cannot be before start date'),
+ endDate: yup.date().required('End date is required').min(yup.ref('startDate'), 'End date cannot be before start date'),
description: yup.string().optional().nullable().max(500, 'Description cannot exceed 500 characters').default(''),
// Work Orders Step (Conditional based on 'type')
@@ -66,7 +66,7 @@ export const assignmentSchema = yup.object({
name: yup.string().required('Work order name is required'),
code: yup.string().required('Work order code is required'),
startDate: yup.date().required('Start date is required'),
- endDate: yup.date().required('Start date is required').min(yup.ref('startDate'), 'End date cannot be before start date'),
+ endDate: yup.date().required('End date is required').min(yup.ref('startDate'), 'End date cannot be before start date'),
description: yup.string().optional().nullable().max(500, 'Description cannot exceed 500 characters').default(''),
}),
otherwise: (schema) => schema.nullable().notRequired()
@@ -76,21 +76,22 @@ export const assignmentSchema = yup.object({
// Infer the TypeScript type from the Yup schema
export type AssignmentFormValues = yup.InferType;
-export default function ProjectAssignmentForm({ client, clientId, isEdit, assignmentId }: { client?: IClient, clientId?: string, isEdit?: boolean, assignmentId?: string }) {
- const [existAssignment, setIsExistAssignment] = useState(null)
+export default function ProjectAssignmentForm(
+ { client, clientId, isEdit, assignmentId, isPromote }: { client?: IClient; clientId?: string; isEdit?: boolean; assignmentId?: string; isPromote?: boolean; }
+) {
+ const router = useRouter();
+ const [existAssignment, setIsExistAssignment] = useState(null);
const [step, setStep] = useState('type');
const [loading, setIsLoading] = useState(false);
- const [isFullLoading, setIsFullLoading] = useState(false)
- const [isExistProject, setIsExistProject] = useState(false)
+ const [isFullLoading, setIsFullLoading] = useState(false);
+ const [isExistProject, setIsExistProject] = useState(null);
const [openProjectSearch, setOpenProjectSearch] = useState(false);
- const [showEndUserForm, setShowEndUserForm] = useState(false)
- const [showClientForm, setShowClientForm] = useState(false)
- const [selectedClient, setSelectedClient] = useState(client || null)
- const [selectedEndUser, setSelectedEndUser] = useState(null)
+ const [showEndUserForm, setShowEndUserForm] = useState(false);
+ const [showClientForm, setShowClientForm] = useState(false);
+ const [selectedClient, setSelectedClient] = useState(client || null);
+ const [selectedEndUser, setSelectedEndUser] = useState(null);
const [isSameAsProject, setIsSameAsProject] = useState(false);
- const router = useRouter();
-
const form = useForm({
resolver: yupResolver(assignmentSchema),
defaultValues: {
@@ -130,18 +131,21 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
form.setValue('startDate', undefined as any, { shouldValidate: false });
form.setValue('endDate', undefined as any, { shouldValidate: false });
form.setValue('description', '', { shouldValidate: false });
- setIsExistProject(false);
- toast.info('Project form cleared');
+
+ setIsExistProject(null);
+ toast.warning('Project form cleared');
};
const handleClearWorkOrder = () => {
setIsSameAsProject(false);
+
form.setValue('workOrder.name' as any, '', { shouldValidate: false });
form.setValue('workOrder.code' as any, '', { shouldValidate: false });
form.setValue('workOrder.startDate' as any, undefined as any, { shouldValidate: false });
form.setValue('workOrder.endDate' as any, undefined as any, { shouldValidate: false });
form.setValue('workOrder.description' as any, '', { shouldValidate: false });
- toast.info('Work order form cleared');
+
+ toast.warning('Work order form cleared');
};
// 3. Navigation & Validation Logic
@@ -156,54 +160,61 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
const currentStepIndex = steps.findIndex(s => s.id === step);
useEffect(() => {
- if (!isEdit) return
+ if (!isEdit) return;
async function getAssignmentDetail() {
- setIsFullLoading(true)
- const res: any = await serverApiCall('GET', `/project-assignment/${assignmentId}`)
+ setIsFullLoading(true);
+ const res: any = await serverApiCall('GET', `/project-assignment/${assignmentId}`);
+ console.log(res)
if (res.success) {
- const data: IProjectAssignment = res.data.data
- form.setValue('type', data.project?.code ? 'Project' : 'IM')
+ const data: IProjectAssignment = res.data.data;
+ form.setValue('type', isPromote ? 'Project' : data.project?.code ? 'Project' : 'IM');
- form.setValue('client_id', data.client.id)
- form.setValue('end_user_id', data.end_user.id)
+ form.setValue('client_id', data.client?.id);
+ form.setValue('end_user_id', data.end_user?.id);
+ 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', data.project?.year || data.im_year)
- form.setValue('startDate', data.project?.start_date || data.im_start_date)
- form.setValue('endDate', data.project?.end_date || data.im_end_date)
- form.setValue('description', data.project?.description || data.im_description)
+ 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 || '');
- form.setValue('workOrder.name' as any, data.wo_name)
+ 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)
- form.setValue('workOrder.startDate' as any, data.wo_start_date)
- form.setValue('workOrder.endDate' as any, data.wo_end_date)
- form.setValue('workOrder.description' as any, data.wo_description)
+ 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 (data.wo_name && (data.project?.name || data.im_name) && data.wo_name === (data.project?.name || data.im_name)) {
+ if (defaultWoName.toLowerCase() === data.project?.name.toLowerCase()) {
setIsSameAsProject(true);
}
- setStep('clients')
-
- setIsExistAssignment(res.data.data)
+ setStep(isPromote ? 'details' : 'clients');
+ setIsExistAssignment(res.data.data);
} else {
toast.error('Fail to get detail assignment', {
description: `(${res.code || '-'}) ${res.message}`
- })
+ });
}
- setIsFullLoading(false)
+ setIsFullLoading(false);
}
- getAssignmentDetail()
- }, [isEdit, assignmentId])
+ getAssignmentDetail();
+ }, [isEdit, assignmentId, isPromote]);
const handleNext = async () => {
let isStepValid = false;
@@ -228,8 +239,14 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
};
const handleBack = () => {
- if (step === 'clients') setStep('type');
- if (step === 'details') setStep('clients');
+ if (step === 'clients') {
+ if (isPromote) {
+ toast.info('Assignment type is locked to Project during promotion');
+ return;
+ }
+ setStep('type');
+ }
+ else if (step === 'details') setStep('clients');
else if (step === 'work-orders') setStep('details');
else if (step === 'review') setStep(assignmentType === 'Project' ? 'work-orders' : 'details');
};
@@ -246,7 +263,7 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
: `${projectCode}-${rawWoCode}`;
}
- const newPayload = {
+ const newPayload: any = {
"client_id": Number(payload.client_id),
"end_user_id": payload.end_user_id ? Number(payload.end_user_id) : null,
@@ -274,28 +291,52 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
"project_assignment_status_id": isEdit ? existAssignment?.project_assignment_status?.id : 1,
"note": isEdit ? existAssignment?.note : "",
+ };
+
+ if (existAssignment || isExistProject) {
+ newPayload['project_id'] = isExistProject?.id || existAssignment?.project?.id
}
- let res: any
- if (isEdit) {
- res = await serverApiCall('PUT', `/project-assignment/${assignmentId}`, newPayload)
+ if (isPromote && existAssignment) {
+ newPayload['im_id'] = existAssignment?.im_id || existAssignment?.id
+ }
+
+ let res: any;
+ if (isPromote) {
+ res = await serverApiCall('POST', '/project-assignment', newPayload);
} else {
- res = await serverApiCall('POST', '/project-assignment', newPayload)
+ if (isEdit) {
+ res = await serverApiCall('PUT', `/project-assignment/${assignmentId}`, newPayload);
+ } else {
+ res = await serverApiCall('POST', '/project-assignment', newPayload);
+ }
}
- setIsLoading(false)
+ setIsLoading(false);
if (res.success) {
- toast.success(`${payload.type} saved successfully`);
+ toast.success(isPromote ? 'Internal Memo successfully promoted to Project' : `${payload.type} saved successfully`);
if (clientId) {
router.replace(`/task/client-detail/${clientId}`);
} else {
router.replace(`/task?tab=assignments`);
}
} else {
- toast.error(`Fail to save assignment`, { description: `(${res.code || '-'}) ${res.message}` })
+ toast.error(`Fail to save assignment`, { description: `(${res.code || '-'}) ${res.message}` });
}
};
+ useEffect(() => {
+ if (!isExistProject) return
+
+ 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, "")
+ }
+
+ getWOCode();
+ }, [isExistProject])
+
return (
<>
-
{isEdit ? 'Update' : 'Create Project'} Assignment
-
{clientId ? `For ${client?.name}` : 'Manage the creation and modification of assignment information'}
+
+
{isPromote ? 'Promote to Project' : isEdit ? 'Update Assignment' : 'Create Project Assignment'}
+ {isPromote && (
+
+ Promote Action
+
+ )}
+
+
+ {isPromote
+ ? 'Convert this Internal Memo into a Project with Work Orders'
+ : clientId
+ ? `For ${client?.name}`
+ : 'Manage the creation and modification of assignment information'}
+
@@ -355,8 +409,13 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
field.onChange('Project')}
- className={cn("cursor-pointer transition-all hover:border-his dark:hover:border-his duration-400", field.value === 'Project' && "ring-2 ring-his/10 border-his dark:ring-his/10 dark:border-his")}
+ className={cn("cursor-pointer transition-all hover:border-his dark:hover:border-his duration-400 relative", field.value === 'Project' && "ring-2 ring-his/10 border-his dark:ring-his/10 dark:border-his")}
>
+ {isPromote && (
+
+ Locked for Promotion
+
+ )}
@@ -370,9 +429,24 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
-
field.onChange('IM')}
- className={cn("cursor-pointer transition-all hover:border-his dark:hover:border-his duration-400", field.value === 'IM' && "ring-2 ring-his/10 border-his dark:ring-his/10 dark:border-his")}
+ {
+ if (isPromote) {
+ toast.info('Cannot select Internal Memo while promoting to Project');
+ return;
+ }
+ field.onChange('IM');
+ }}
+ className={cn(
+ "cursor-pointer transition-all hover:border-his dark:hover:border-his duration-400 relative",
+ field.value === 'IM' && "ring-2 ring-his/10 border-his dark:ring-his/10 dark:border-his",
+ isPromote && "opacity-40 cursor-not-allowed hover:border-border"
+ )}
>
+ {isPromote && (
+
+ Unavailable
+
+ )}
@@ -511,12 +585,12 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
- Import Existing Project
+ Import Existing Project
Optional
-
+
Select an existing project for {selectedClient?.name || 'this client'} to autofill information, or create a new one below.
@@ -553,7 +627,7 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
form.setValue('description', p.description || '', { shouldValidate: true });
setOpenProjectSearch(false);
- setIsExistProject(true);
+ setIsExistProject(p);
toast.info(`Autofilled details from ${p.name}`);
}}
className="cursor-pointer py-2.5 px-3"
@@ -561,11 +635,11 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
-
+
{p.name}
-
-
+
+
# {p.code}
•
@@ -624,7 +698,7 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
form.setValue('description', p.description || '', { shouldValidate: true });
setOpenProjectSearch(false);
- setIsExistProject(true);
+ setIsExistProject(p);
toast.info(`Switched project to ${p.name}`);
}}
className="cursor-pointer py-2.5 px-3"
@@ -632,12 +706,12 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
-
+
{p.name}
-
-
- {p.code}
+
+
+ # {p.code}
•
Year: {p.year}
@@ -655,10 +729,10 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
type="button"
variant="ghost"
size="sm"
- className="h-7 px-2 text-xs text-muted-foreground hover:text-destructive hover:bg-destructive/10"
+ className="h-7 px-2 text-xs text-destructive hover:bg-destructive"
onClick={handleClearProject}
>
- Clear / Create New
+ Clear / Create New
@@ -683,7 +757,7 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
-
+
Fields below are locked and autofilled from this existing project. Click Clear / Create New to enter new project details manually.
@@ -878,7 +952,7 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
Full work order code will be submitted as:
- {projectCode}-{field.value?.trim() || '...'}
+ # {projectCode}-{field.value?.trim() || '...'}
diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-assignments/page.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-assignments/page.tsx
index 278a946..1eecdb2 100644
--- a/app/(dashboard)/task/client-detail/[client_id]/project-assignments/page.tsx
+++ b/app/(dashboard)/task/client-detail/[client_id]/project-assignments/page.tsx
@@ -8,14 +8,22 @@ type Props = {
export default async function CreateAssignmentPage({ params, searchParams }: Props) {
const { client_id } = await params;
- const isEdit = (await searchParams)!.is_edit
- const assignmentId = (await searchParams)!.assignment_id
+ const resolvedSearchParams = await searchParams;
+ const isEdit = resolvedSearchParams?.is_edit;
+ const assignmentId = resolvedSearchParams?.assignment_id;
+ const isPromote = resolvedSearchParams?.promote === 'true' || resolvedSearchParams?.is_promote === 'true';
- const client = await fetchData(`/client/${client_id}`)
+ const client = await fetchData(`/client/${client_id}`);
return (
);
}
\ No newline at end of file
diff --git a/app/(dashboard)/task/component/UpdateAdministrationStatus.tsx b/app/(dashboard)/task/component/UpdateAdministrationStatus.tsx
index 00cdaa6..317f863 100644
--- a/app/(dashboard)/task/component/UpdateAdministrationStatus.tsx
+++ b/app/(dashboard)/task/component/UpdateAdministrationStatus.tsx
@@ -85,10 +85,11 @@ export default function UpdateAdministrationStatus({
}, [initialStatusId]);
useEffect(() => {
- const initialRemark = assignment?.project_assignment_status?.remark || assignment?.project_assignment_status?.description || assignment?.note || '';
+ const initialRemark = assignment?.project_assignment_status_notes || assignment?.project_assignment_status?.remark || assignment?.project_assignment_status?.description || assignment?.note || '';
setDescription(initialRemark);
}, [assignment]);
+
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (!effectiveId) {
@@ -105,9 +106,7 @@ export default function UpdateAdministrationStatus({
try {
const payload = {
project_assignment_status_id: Number(selectedStatusId),
- remark: description.trim(),
- description: description.trim(),
- note: description.trim(),
+ notes: description.trim(),
};
const res = await serverApiCall('PUT', `/project-assignment/status/${effectiveId}`, payload);
diff --git a/app/(dashboard)/task/component/project-assignment/AssignmentGrid.tsx b/app/(dashboard)/task/component/project-assignment/AssignmentGrid.tsx
index b7cda15..89b3d4f 100644
--- a/app/(dashboard)/task/component/project-assignment/AssignmentGrid.tsx
+++ b/app/(dashboard)/task/component/project-assignment/AssignmentGrid.tsx
@@ -13,7 +13,7 @@ import {
Tooltip, TooltipContent, TooltipTrigger,
} from '@/components/ui/tooltip';
import { LazyImage } from '@/components/ui/lazy-image';
-import { Briefcase, Calendar, ExternalLink, MoreVertical, FolderGit2, FileText } from 'lucide-react';
+import { Briefcase, Calendar, ExternalLink, MoreVertical, FolderGit2, FileText, ArrowUpRight } from 'lucide-react';
import Link from 'next/link';
import BadgeStatus from '@/components/ui/badge-status';
import { formatAssignmentDate } from './AssignmentList';
@@ -47,17 +47,18 @@ export default function AssignmentGrid({
const assignmentDesc = assignment.wo_description || assignment.im_description || assignment.project?.description;
const assignmentStatus = assignment.project_assignment_status?.name || assignment.project?.status;
- const illustrationSrc = isProject
- ? '/assets/illustrations/work_order.jpg'
- : '/assets/illustrations/internal_memo.jpg';
+ const illustrationSrc = isProject ? '/assets/illustrations/work_order.jpg' : '/assets/illustrations/internal_memo.jpg';
const effectiveClientId = clientId || assignment.client?.id;
const assignmentDetailUrl = effectiveClientId ? `/task/client-detail/${effectiveClientId}/${assignment.id}` : '#';
- const projectDetailUrl = effectiveClientId && assignment.project?.id
- ? `/task/client-detail/${effectiveClientId}/project-detail/${assignment.project.id}`
- : null;
+ const projectDetailUrl = effectiveClientId && assignment.project?.id ? `/task/client-detail/${effectiveClientId}/project-detail/${assignment.project.id}` : null;
const editAssignmentUrl = effectiveClientId
? `/task/client-detail/${effectiveClientId}/project-assignments?is_edit=true&assignment_id=${assignment.id}`
+ : `/task/project-assignment?is_edit=true&assignment_id=${assignment.id}`;
+ const promoteAssignmentUrl = !isProject
+ ? (effectiveClientId
+ ? `/task/client-detail/${effectiveClientId}/project-assignments?is_edit=true&assignment_id=${assignment.id}&promote=true`
+ : `/task/project-assignment?is_edit=true&assignment_id=${assignment.id}&promote=true`)
: null;
return (
@@ -122,7 +123,14 @@ export default function AssignmentGrid({
-
+ {promoteAssignmentUrl && (
+
+
+
+ Promote to Project
+
+
+ )}
View Assignment Details
diff --git a/app/(dashboard)/task/component/project-assignment/AssignmentList.tsx b/app/(dashboard)/task/component/project-assignment/AssignmentList.tsx
index 7c562a4..445557d 100644
--- a/app/(dashboard)/task/component/project-assignment/AssignmentList.tsx
+++ b/app/(dashboard)/task/component/project-assignment/AssignmentList.tsx
@@ -12,7 +12,7 @@ import {
Tooltip, TooltipContent, TooltipTrigger,
} from '@/components/ui/tooltip';
import { LazyImage } from '@/components/ui/lazy-image';
-import { Briefcase, Calendar, MoreVertical, FolderGit2, FileText, BuildingComplex } from 'lucide-react';
+import { Briefcase, Calendar, MoreVertical, FolderGit2, FileText, BuildingComplex, ArrowUpRight } from 'lucide-react';
import Link from 'next/link';
import BadgeStatus from '@/components/ui/badge-status';
@@ -59,11 +59,14 @@ export default function AssignmentList({
const effectiveClientId = clientId || assignment.client?.id;
const assignmentDetailUrl = effectiveClientId ? `/task/client-detail/${effectiveClientId}/${assignment.id}` : '#';
- const projectDetailUrl = effectiveClientId && assignment.project?.id
- ? `/task/client-detail/${effectiveClientId}/project-detail/${assignment.project.id}`
- : null;
+ const projectDetailUrl = effectiveClientId && assignment.project?.id ? `/task/client-detail/${effectiveClientId}/project-detail/${assignment.project.id}` : null;
const editAssignmentUrl = effectiveClientId
? `/task/client-detail/${effectiveClientId}/project-assignments?is_edit=true&assignment_id=${assignment.id}`
+ : `/task/project-assignment?is_edit=true&assignment_id=${assignment.id}`;
+ const promoteAssignmentUrl = !isProject
+ ? (effectiveClientId
+ ? `/task/client-detail/${effectiveClientId}/project-assignments?is_edit=true&assignment_id=${assignment.id}&promote=true`
+ : `/task/project-assignment?is_edit=true&assignment_id=${assignment.id}&promote=true`)
: null;
return (
@@ -234,6 +237,14 @@ export default function AssignmentList({
+ {promoteAssignmentUrl && (
+
+
+
+ Promote to Project
+
+
+ )}
View Assignment Details
diff --git a/app/(dashboard)/task/project-assignment/page.tsx b/app/(dashboard)/task/project-assignment/page.tsx
index 95872e3..1508bb8 100644
--- a/app/(dashboard)/task/project-assignment/page.tsx
+++ b/app/(dashboard)/task/project-assignment/page.tsx
@@ -1,16 +1,22 @@
import ProjectAssignmentForm from "../client-detail/[client_id]/project-assignments/ProjectAssignmentForm";
type Props = {
- searchParams: Promise<{ is_edit?: string; assignment_id?: string }>
+ searchParams: Promise<{ is_edit?: string; assignment_id?: string; promote?: string; is_promote?: string }>
};
export default async function CreateAssignmentPage({ searchParams }: Props) {
- const isEdit = (await searchParams)!.is_edit
- const assignmentId = (await searchParams)!.assignment_id
+ const resolvedSearchParams = await searchParams;
+ const isEdit = resolvedSearchParams?.is_edit;
+ const assignmentId = resolvedSearchParams?.assignment_id;
+ const isPromote = resolvedSearchParams?.promote === 'true' || resolvedSearchParams?.is_promote === 'true';
return (
);
}
\ No newline at end of file
diff --git a/app/(dashboard)/task/type.assignment.ts b/app/(dashboard)/task/type.assignment.ts
index df55797..82e7160 100644
--- a/app/(dashboard)/task/type.assignment.ts
+++ b/app/(dashboard)/task/type.assignment.ts
@@ -2,6 +2,7 @@ import { IUser } from "@/app/admin/administration/user/component/type"
export interface IProjectAssignment {
id: number
+ im_id?: any
im_code?: any
im_description?: any
im_end_date?: any
@@ -13,6 +14,7 @@ export interface IProjectAssignment {
end_user: EndUser
project?: Project
project_assignment_status: ProjectStatus
+ project_assignment_status_notes?: string
wo_code: string
wo_description: string
wo_name: string