diff --git a/.env.production.local b/.env.production.local new file mode 100644 index 0000000..c1256b2 --- /dev/null +++ b/.env.production.local @@ -0,0 +1,21 @@ +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/component/UpdateTechnicalStatus.tsx b/app/(dashboard)/task/component/UpdateTechnicalStatus.tsx index d6a98d7..72f3421 100644 --- a/app/(dashboard)/task/component/UpdateTechnicalStatus.tsx +++ b/app/(dashboard)/task/component/UpdateTechnicalStatus.tsx @@ -10,6 +10,16 @@ import { Textarea } from '@/components/ui/textarea'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from "@/components/ui/alert-dialog"; import { AlertCircle, Calendar, Edit2, History, Loader2, Plus, Save, Trash2 } from 'lucide-react'; @@ -301,9 +311,16 @@ function EditTechnicalStatusModal({ assignmentId, data, onClose, onSuccess }: Ed ); } -const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => { +interface DeleteTarget { + item: StatusItem; + index: number; + dateEntry: IDateInterval; +} + +const UpdateTechnicalStatus: FC = ({ assignmentId, onClose }) => { const [modalState, setModalState] = useState(null); - const [deletingId, setDeletingId] = useState(null); + const [deleteTarget, setDeleteTarget] = useState(null); + const [isDeleting, setIsDeleting] = useState(false); const { data: existTimeline, isLoading: isLoadingTimeline, mutate } = useFetchWithAxios(`project-assignment/status-detail/${assignmentId}`); const router = useRouter(); @@ -387,28 +404,37 @@ const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => { }); }; - // Handle deleting a specific date entry from the status - const handleDeleteDate = async (item: StatusItem, removeIndex: number) => { - const itemKey = `${item.technicalId}-${removeIndex}`; - setDeletingId(itemKey); + // Handle confirming date deletion from AlertDialog + const handleConfirmDelete = async () => { + if (!deleteTarget) return; + + const { item, index: removeIndex } = deleteTarget; + setIsDeleting(true); const remainingDates = item.dates.filter((_, idx) => idx !== removeIndex); + // If the remaining dates are empty (last date removed), also clear the description + const finalDescription = remainingDates.length === 0 ? '' : item.description.trim(); const submitPayload = { project_assignment_technical_status_id: Number(item.technicalId), project_assignment_status_detail_id: Number(item.detailId), date: remainingDates, - description: item.description.trim() + description: finalDescription }; const res = await serverApiCall('PUT', `/project-assignment/technical-status/${assignmentId}`, submitPayload ); - setDeletingId(null); + setIsDeleting(false); if (res.success) { - toast.success('Schedule interval removed'); + toast.success( + remainingDates.length === 0 + ? 'Schedule interval and notes removed' + : 'Schedule interval removed' + ); + setDeleteTarget(null); mutate(); router.refresh(); } else { @@ -478,7 +504,6 @@ const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => { {hasDates ? (
{item.dates.map((dateEntry, idx) => { - const isDeletingThis = deletingId === `${item.technicalId}-${idx}`; const start = dateEntry.start_date ? dayjs(dateEntry.start_date) : null; const end = dateEntry.end_date ? dayjs(dateEntry.end_date) : null; const spanDays = start && end ? end.diff(start, 'day') + 1 : null; @@ -504,7 +529,7 @@ const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => { -
@@ -564,8 +589,63 @@ const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => { onSuccess={handleSuccess} /> ) : null} + + {/* Confirmation Dialog: Delete Date Interval */} + { + if (!open && !isDeleting) setDeleteTarget(null); + }} + > + + + + + Delete Schedule Interval + + + {deleteTarget && ( + <> + + Are you sure you want to delete the schedule interval{' '} + + {deleteTarget.dateEntry.start_date ? dayjs(deleteTarget.dateEntry.start_date).format('DD MMM YYYY') : 'TBD'} – {deleteTarget.dateEntry.end_date ? dayjs(deleteTarget.dateEntry.end_date).format('DD MMM YYYY') : 'Present'} + {' '} + from {deleteTarget.item.statusName}? + + {deleteTarget.item.dates.length === 1 && ( +
+ Note: This is the last remaining schedule for this status. Deleting it will also remove the description and progress notes. +
+ )} + + )} +
+
+ + Cancel + { + e.preventDefault(); + handleConfirmDelete(); + }} + disabled={isDeleting} + className="bg-destructive text-white hover:bg-destructive/90 gap-1.5" + > + {isDeleting ? ( + <> + + Deleting... + + ) : ( + 'Delete' + )} + + +
+
); }; -export default UpdateTimelineStatus; \ No newline at end of file +export default UpdateTechnicalStatus; \ No newline at end of file diff --git a/components/ui/badge-status.tsx b/components/ui/badge-status.tsx index 5bdaef0..b47fd7c 100644 --- a/components/ui/badge-status.tsx +++ b/components/ui/badge-status.tsx @@ -40,16 +40,32 @@ export function formatStatusText(status?: any): string { .join(" "); } +function getTechnicalBadgeVariant(rawText: string) { + const key = rawText.toLowerCase().trim(); + if (STATUS_BADGE_MAP[key]) return STATUS_BADGE_MAP[key]; + + if (key.includes("development") || key === "dev") return "techDevelopment"; + if (key.includes("sit") || key.includes("system integration")) return "techSIT"; + if (key.includes("uat") || key.includes("user acceptance")) return "techUAT"; + if (key.includes("ptr") || key.includes("production trial")) return "techPTR"; + if (key.includes("go-live") || key.includes("go live") || key.includes("golive")) return "techGoLive"; + if (key.includes("bast") || key.includes("handover")) return "techBAST"; + if (key.includes("warranty")) return "techWarranty"; + + return undefined; +} + export default function BadgeStatus({ status, className }: { status: any, className?: string }) { // e.g. status = "UAT" const raw = extractStatusString(status); const formatted = formatStatusText(raw); if (!formatted) return null; const lookupKey = raw.toLowerCase().trim(); + const variant = getTechnicalBadgeVariant(raw) || STATUS_BADGE_MAP[lookupKey] || "default"; return ( {formatted} diff --git a/components/ui/badge.tsx b/components/ui/badge.tsx index a13b50c..3a04039 100644 --- a/components/ui/badge.tsx +++ b/components/ui/badge.tsx @@ -30,13 +30,22 @@ const badgeVariants = cva( // --- CUSTOM STATUS VARIANTS --- statusNotStarted: "border-transparent bg-slate-500 text-zinc-50 hover:opacity-80", // Gray - statusActive: "border-transparent bg-teal-500 text-zinc-50 hover:opacity-80", // Blue + statusActive: "border-transparent bg-teal-500 text-zinc-50 hover:opacity-80", // Teal statusWarning: "border-transparent bg-amber-500 text-zinc-50 hover:opacity-80", // Yellow/Orange statusDanger: "border-transparent bg-red-500 text-zinc-50 hover:opacity-80", // Red - statusTesting: "border-transparent bg-indigo-500 text-zinc-50 hover:opacity-80", // Indigo/Purple + statusTesting: "border-transparent bg-indigo-500 text-zinc-50 hover:opacity-80", // Indigo statusSuccess: "border-transparent bg-emerald-500 text-zinc-50 hover:opacity-80", // Green - statusMaintenance: "border-transparent bg-blue-500 text-zinc-50 hover:opacity-80", // Teal - statusEnded: "border-transparent bg-stone-500 text-zinc-50 hover:opacity-80", // Dark Gray/Brown + statusMaintenance: "border-transparent bg-blue-500 text-zinc-50 hover:opacity-80", // Blue + statusEnded: "border-transparent bg-stone-500 text-zinc-50 hover:opacity-80", // Dark Gray + + // --- TECHNICAL PROGRESSION STATUS VARIANTS --- + techDevelopment: "border-transparent bg-orange-500 text-white dark:bg-orange-600 hover:opacity-85", // Orange + techSIT: "border-transparent bg-blue-500 text-white dark:bg-blue-600 hover:opacity-85", // Blue + techUAT: "border-transparent bg-purple-500 text-white dark:bg-purple-600 hover:opacity-85", // Purple/Violet + techPTR: "border-transparent bg-teal-500 text-white dark:bg-teal-600 hover:opacity-85", // Mint / Aqua (Teal) + techGoLive: "border-transparent bg-lime-600 text-white dark:bg-lime-700 hover:opacity-85", // Lime Green + techBAST: "border-transparent bg-yellow-500 text-white dark:bg-yellow-600 hover:opacity-85", // Yellow / Amber (BAST) + techWarranty: "border-transparent bg-sky-500 text-white dark:bg-sky-600 hover:opacity-85", // Sky Blue }, }, defaultVariants: { @@ -57,30 +66,44 @@ export const STATUS_BADGE_MAP: Record "issue": "statusDanger", "canceled": "statusDanger", - // Technical progression stages - "development": "info", + // Technical progression stages based on color reference: + // 1. Development -> Orange + "development": "techDevelopment", + "dev": "techDevelopment", - "sit": "statusTesting", - "system integration testing (sit)": "statusTesting", - "system integration testing": "statusTesting", + // 2. System Integration Testing (SIT) -> Blue + "sit": "techSIT", + "(sit)": "techSIT", + "system integration testing (sit)": "techSIT", + "system integration testing": "techSIT", - "uat": "violet", - "user acceptance testing (uat)": "violet", - "user acceptance testing": "violet", + // 3. User Acceptance Testing (UAT) -> Purple/Violet + "uat": "techUAT", + "(uat)": "techUAT", + "user acceptance testing (uat)": "techUAT", + "user acceptance testing": "techUAT", - "ptr": "statusWarning", - "production trial run (ptr)": "statusWarning", - "production trial run": "statusWarning", + // 4. Production Trial Run (PTR) -> Mint / Aqua Green + "ptr": "techPTR", + "(ptr)": "techPTR", + "production trial run (ptr)": "techPTR", + "production trial run": "techPTR", - "go-live": "statusSuccess", - "go live": "statusSuccess", - "golive": "statusSuccess", + // 5. Go-live -> Lime Green + "go-live": "techGoLive", + "go live": "techGoLive", + "golive": "techGoLive", - "bast": "statusActive", - "project handover & bast": "statusActive", - "project handover and bast": "statusActive", + // 6. Project Handover & BAST -> Yellow + "bast": "techBAST", + "(bast)": "techBAST", + "project handover & bast": "techBAST", + "project handover and bast": "techBAST", + "project handover & bast (bast)": "techBAST", + "project handover": "techBAST", - "warranty": "statusMaintenance", + // 7. Warranty -> Light Sky Blue + "warranty": "techWarranty", "end of support": "statusEnded", }