mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:46:29 +00:00
Add activity log timeline
Show assignment history on a date-based milestone timeline and refine milestone date positioning. Update activity log submission and description limits, refresh progress editing controls, and adjust the system log badge color.
This commit is contained in:
+418
@@ -0,0 +1,418 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useMemo } from 'react';
|
||||
import { IProjectAssignmentHistory } from '../../../type.assignment';
|
||||
import dayjs from 'dayjs';
|
||||
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
||||
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
||||
import { History, Activity, Calendar, Clock, User, ChevronRight, Info } from 'lucide-react';
|
||||
import {
|
||||
HoverCard,
|
||||
HoverCardTrigger,
|
||||
HoverCardContent,
|
||||
} from '@/components/ui/hover-card';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
|
||||
dayjs.extend(isSameOrAfter);
|
||||
dayjs.extend(isSameOrBefore);
|
||||
|
||||
interface ActivityLogMilestoneTimelineProps {
|
||||
history?: IProjectAssignmentHistory[];
|
||||
startDate?: string | null;
|
||||
endDate?: string | null;
|
||||
}
|
||||
|
||||
interface IMonthBoundary {
|
||||
date: string;
|
||||
label: string;
|
||||
percent: number;
|
||||
}
|
||||
|
||||
interface IDateActivityGroup {
|
||||
dateKey: string;
|
||||
compactDate: string;
|
||||
fullDate: string;
|
||||
percent: number;
|
||||
activities: IProjectAssignmentHistory[];
|
||||
}
|
||||
|
||||
export function ActivityLogMilestoneTimeline({
|
||||
history = [],
|
||||
startDate,
|
||||
endDate,
|
||||
}: ActivityLogMilestoneTimelineProps) {
|
||||
const [hoveredKey, setHoveredKey] = useState<string | null>(null);
|
||||
|
||||
// Extract valid history items with valid timestamps
|
||||
const validHistory = useMemo(() => {
|
||||
return history
|
||||
.filter((item) => Boolean(item?.created_at && dayjs(item.created_at).isValid()))
|
||||
.sort((a, b) => dayjs(a.created_at).valueOf() - dayjs(b.created_at).valueOf());
|
||||
}, [history]);
|
||||
|
||||
// Boundary dates: WO or IM start date to WO end date (falling back to earliest/latest activity date)
|
||||
const effectiveStart = useMemo(() => {
|
||||
if (startDate && dayjs(startDate).isValid()) return startDate;
|
||||
if (validHistory.length > 0) return dayjs(validHistory[0].created_at).format('YYYY-MM-DD');
|
||||
return dayjs().format('YYYY-MM-DD');
|
||||
}, [startDate, validHistory]);
|
||||
|
||||
const effectiveEnd = useMemo(() => {
|
||||
if (endDate && dayjs(endDate).isValid()) return endDate;
|
||||
if (validHistory.length > 0) return dayjs(validHistory[validHistory.length - 1].created_at).format('YYYY-MM-DD');
|
||||
return dayjs(effectiveStart).add(60, 'day').format('YYYY-MM-DD');
|
||||
}, [endDate, validHistory, effectiveStart]);
|
||||
|
||||
// Day boundaries for exact calendar day percentage calculation
|
||||
const startDay = useMemo(() => dayjs(effectiveStart).startOf('day'), [effectiveStart]);
|
||||
const endDay = useMemo(() => dayjs(effectiveEnd).startOf('day'), [effectiveEnd]);
|
||||
const totalDays = useMemo(() => Math.max(1, endDay.diff(startDay, 'day')), [endDay, startDay]);
|
||||
|
||||
const startFormatted = effectiveStart && dayjs(effectiveStart).isValid() ? dayjs(effectiveStart).format('D MMM YYYY') : '';
|
||||
const endFormatted = effectiveEnd && dayjs(effectiveEnd).isValid() ? dayjs(effectiveEnd).format('D MMM YYYY') : '';
|
||||
|
||||
const todayDay = useMemo(() => dayjs().startOf('day'), []);
|
||||
const todayFormatted = dayjs().format('D MMM YYYY');
|
||||
|
||||
// Today in range calculation
|
||||
const isTodayInRange = useMemo(() => {
|
||||
if (!effectiveStart || !effectiveEnd) return false;
|
||||
return (todayDay.isSame(startDay, 'day') || todayDay.isAfter(startDay)) &&
|
||||
(todayDay.isSame(endDay, 'day') || todayDay.isBefore(endDay));
|
||||
}, [effectiveStart, effectiveEnd, todayDay, startDay, endDay]);
|
||||
|
||||
const todayPercent = useMemo(() => {
|
||||
if (!isTodayInRange) return 0;
|
||||
const diff = todayDay.diff(startDay, 'day');
|
||||
const pct = (diff / totalDays) * 100;
|
||||
return Math.min(100, Math.max(0, pct));
|
||||
}, [isTodayInRange, todayDay, startDay, totalDays]);
|
||||
|
||||
// Calculate month boundary vertical ticks (e.g. 1 Oct, 1 Nov, 1 Dec)
|
||||
const monthBoundaries = useMemo<IMonthBoundary[]>(() => {
|
||||
if (!effectiveStart || !effectiveEnd) return [];
|
||||
const list: IMonthBoundary[] = [];
|
||||
let cur = startDay.startOf('month');
|
||||
const limit = endDay.endOf('month');
|
||||
|
||||
while (cur.isSameOrBefore(limit, 'day')) {
|
||||
if ((cur.isSame(startDay, 'day') || cur.isAfter(startDay)) && (cur.isSame(endDay, 'day') || cur.isBefore(endDay))) {
|
||||
const diff = cur.diff(startDay, 'day');
|
||||
const pct = (diff / totalDays) * 100;
|
||||
list.push({
|
||||
date: cur.format('YYYY-MM-DD'),
|
||||
label: cur.format('1 MMM'),
|
||||
percent: Math.min(100, Math.max(0, pct)),
|
||||
});
|
||||
}
|
||||
cur = cur.add(1, 'month').startOf('month');
|
||||
}
|
||||
return list;
|
||||
}, [effectiveStart, effectiveEnd, startDay, endDay, totalDays]);
|
||||
|
||||
// Group activities by date (YYYY-MM-DD) and calculate proportional position
|
||||
const dateGroups = useMemo<IDateActivityGroup[]>(() => {
|
||||
const groupsMap = new Map<string, IProjectAssignmentHistory[]>();
|
||||
|
||||
validHistory.forEach((item) => {
|
||||
const dateKey = dayjs(item.created_at).format('YYYY-MM-DD');
|
||||
const list = groupsMap.get(dateKey) || [];
|
||||
list.push(item);
|
||||
groupsMap.set(dateKey, list);
|
||||
});
|
||||
|
||||
const result: IDateActivityGroup[] = [];
|
||||
|
||||
groupsMap.forEach((activities, dateKey) => {
|
||||
const targetDay = dayjs(dateKey).startOf('day');
|
||||
const diff = targetDay.diff(startDay, 'day');
|
||||
const pct = (diff / totalDays) * 100;
|
||||
|
||||
// Sort newest first within the date
|
||||
activities.sort((a, b) => dayjs(b.created_at).valueOf() - dayjs(a.created_at).valueOf());
|
||||
|
||||
result.push({
|
||||
dateKey,
|
||||
compactDate: dayjs(dateKey).format('D MMM'),
|
||||
fullDate: dayjs(dateKey).format('dddd, D MMMM YYYY'),
|
||||
percent: Math.min(100, Math.max(0, pct)),
|
||||
activities,
|
||||
});
|
||||
});
|
||||
|
||||
// Sort chronologically by date
|
||||
return result.sort((a, b) => dayjs(a.dateKey).valueOf() - dayjs(b.dateKey).valueOf());
|
||||
}, [validHistory, startDay, totalDays]);
|
||||
|
||||
const isAnyHovered = hoveredKey !== null;
|
||||
const totalActivities = validHistory.length;
|
||||
|
||||
return (
|
||||
<section className="rounded-2xl border border-border/80 bg-card p-5 sm:p-6 pb-0 sm:pb-0 transition-all duration-200">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between gap-3 flex-wrap">
|
||||
<div className="flex items-center gap-2.5">
|
||||
<span className="flex h-7 w-7 items-center justify-center rounded-lg bg-his/10 text-his">
|
||||
<Activity className="h-4 w-4" />
|
||||
</span>
|
||||
<h2 className="text-base font-semibold tracking-tight text-foreground">
|
||||
Milestone Activity Log
|
||||
</h2>
|
||||
{totalActivities > 0 && (
|
||||
<span className="rounded-lg bg-muted px-2 py-0.5 font-mono text-xs font-medium text-muted-foreground">
|
||||
{totalActivities} {totalActivities === 1 ? 'activity' : 'activities'} · {dateGroups.length} {dateGroups.length === 1 ? 'date' : 'dates'}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-2 font-mono text-xs text-muted-foreground">
|
||||
<span>{startFormatted}</span>
|
||||
<span>→</span>
|
||||
<span className="font-semibold text-foreground">{endFormatted}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Continuous Timeline Rail Container with Horizontal Scroll */}
|
||||
<div className="overflow-x-auto overflow-y-hidden scrollbar-thin">
|
||||
<div className={`min-w-255 px-12 ${isTodayInRange ? 'pt-7' : 'pt-4'} pb-10 flex items-center`}>
|
||||
{/* The Proportional Rail Area */}
|
||||
<div className="relative flex-1 h-18">
|
||||
{/* Base Track Line */}
|
||||
<div className="absolute left-0 right-0 top-1/2 -translate-y-1/2 h-1 bg-muted/80 rounded-full" />
|
||||
|
||||
{/* Active Milestone Progress Track (colored green from Start to Today if today is in milestone) */}
|
||||
{isTodayInRange && todayPercent > 0 && (
|
||||
<div
|
||||
className={`absolute left-0 top-1/2 -translate-y-1/2 h-1 bg-emerald-500 rounded-full transition-all duration-300 ${isAnyHovered ? 'opacity-40' : 'opacity-100'
|
||||
}`}
|
||||
style={{ width: `${todayPercent}%` }}
|
||||
/>
|
||||
)}
|
||||
{todayDay.isAfter(endDay) && (
|
||||
<div
|
||||
className={`absolute left-0 right-0 top-1/2 -translate-y-1/2 h-1 bg-emerald-500 rounded-full transition-all duration-300 ${isAnyHovered ? 'opacity-40' : 'opacity-100'
|
||||
}`}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Month Boundary Vertical Tick Marks (e.g. 1 Oct, 1 Nov, 1 Dec) */}
|
||||
{monthBoundaries.map((mb, idx) => {
|
||||
if (mb.percent <= 1 || mb.percent >= 99) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
key={`month-tick-${idx}`}
|
||||
className={`absolute top-1/2 -translate-y-1/2 -translate-x-1/2 flex flex-col items-center pointer-events-none z-5 transition-opacity duration-200 ${isAnyHovered ? 'opacity-30' : 'opacity-80'
|
||||
}`}
|
||||
style={{ left: `${mb.percent}%` }}
|
||||
>
|
||||
{/* Vertical tick line passing across the rail */}
|
||||
<div className="w-0.5 h-8 translate-y-4 bg-zinc-300 dark:bg-zinc-700 rounded-full" />
|
||||
|
||||
{/* Month milestone label underneath */}
|
||||
<div className="absolute top-12 flex flex-col items-center">
|
||||
<span className="text-[10px] font-mono font-bold text-zinc-600 dark:text-zinc-200 bg-muted/60 px-1.5 py-0.5 rounded border border-border/70 shadow-2xs whitespace-nowrap">
|
||||
{mb.label}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* 1. START BOUNDARY NODE (at 0%) */}
|
||||
<div
|
||||
className={`absolute top-1/2 -translate-y-1/2 -translate-x-1/2 flex flex-col items-center z-10 transition-opacity duration-200 ${isAnyHovered ? 'opacity-40' : 'opacity-100'
|
||||
}`}
|
||||
style={{ left: '0%' }}
|
||||
>
|
||||
<div className="absolute -top-7 flex flex-col items-center pointer-events-none">
|
||||
<span className="text-xs font-semibold text-foreground whitespace-nowrap">
|
||||
Start
|
||||
</span>
|
||||
</div>
|
||||
<div className="h-4 w-4 rounded-full border-2 border-emerald-500 bg-emerald-500 z-10 shadow-xs" />
|
||||
{startFormatted && (
|
||||
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
|
||||
<span className="text-[10px] font-mono text-muted-foreground whitespace-nowrap font-medium">
|
||||
{dayjs(effectiveStart).format('D MMM')}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 2. DYNAMIC TODAY MARKER (Only if in range) */}
|
||||
{isTodayInRange && (
|
||||
<div
|
||||
className={`absolute top-1/2 -translate-y-1/2 -translate-x-1/2 flex flex-col items-center z-25 pointer-events-none transition-all duration-200 ${isAnyHovered ? 'opacity-35 scale-95' : 'opacity-100'
|
||||
}`}
|
||||
style={{ left: `${todayPercent}%` }}
|
||||
>
|
||||
<div className="absolute -top-12.5 flex flex-col items-center z-30 w-max">
|
||||
<div className="rounded-full bg-his px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
|
||||
Today, {todayFormatted}
|
||||
</div>
|
||||
<div className="w-0.5 h-7.5 bg-his" />
|
||||
</div>
|
||||
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-his z-20 shadow-xs" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 3. ACTIVITY LOG NODES (Vertical small line with dot beneath containing activity count) */}
|
||||
{dateGroups.map((group) => {
|
||||
const isHovered = hoveredKey === group.dateKey;
|
||||
const isDimmed = isAnyHovered && !isHovered;
|
||||
const count = group.activities.length;
|
||||
|
||||
return (
|
||||
<HoverCard
|
||||
key={group.dateKey}
|
||||
openDelay={0}
|
||||
closeDelay={150}
|
||||
onOpenChange={(open) => setHoveredKey(open ? group.dateKey : null)}
|
||||
>
|
||||
<HoverCardTrigger asChild>
|
||||
<div
|
||||
onMouseEnter={() => setHoveredKey(group.dateKey)}
|
||||
onMouseLeave={() => setHoveredKey(null)}
|
||||
className={`group absolute top-1/2 -translate-x-1/2 flex flex-col items-center cursor-pointer transition-all duration-200 ${isHovered
|
||||
? 'z-50 scale-105'
|
||||
: isDimmed
|
||||
? 'z-10 opacity-30 blur-[0.2px] scale-95'
|
||||
: 'z-20 opacity-100 hover:scale-110'
|
||||
}`}
|
||||
style={{ left: `${group.percent}%` }}
|
||||
>
|
||||
{/* Extended vertical hover hit zone */}
|
||||
<div className="absolute -top-12 -bottom-14 -left-4 -right-4 z-0 pointer-events-auto" />
|
||||
|
||||
{/* Vertical Small Line (Garis vertikal kecil di bawah rail) */}
|
||||
<div
|
||||
className={`w-0.5 transition-all duration-200 rounded-full ${isHovered
|
||||
? 'h-3.5 bg-his shadow-xs ring-2 ring-his/30'
|
||||
: 'h-3 bg-zinc-400 dark:bg-zinc-500 group-hover:bg-his'
|
||||
}`}
|
||||
/>
|
||||
|
||||
{/* Dot beneath the vertical line containing the activity count */}
|
||||
<div
|
||||
className={`flex items-center justify-center rounded-full border-2 border-white dark:border-zinc-950 font-mono font-bold transition-all duration-200 z-10 shadow-xs ${count >= 10
|
||||
? 'min-w-6 h-6 px-1 text-[10px]'
|
||||
: 'w-5.5 h-5.5 text-[10px]'
|
||||
} ${isHovered
|
||||
? 'scale-115 bg-his text-white ring-4 ring-his/40 shadow-lg'
|
||||
: 'bg-his text-white shadow-2xs group-hover:ring-2 group-hover:ring-his/30'
|
||||
}`}
|
||||
>
|
||||
{count}
|
||||
</div>
|
||||
|
||||
{/* Date beneath the dot */}
|
||||
<div className="absolute top-10 flex flex-col items-center pointer-events-none transition-all duration-200">
|
||||
{isHovered &&
|
||||
<span className="text-[11px] font-mono font-black text-his bg-card/95 border border-his/50 shadow-xl px-2 py-0.5 rounded-md whitespace-nowrap z-50">
|
||||
{group.compactDate}
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</HoverCardTrigger>
|
||||
|
||||
{/* Hover Card Content displaying all activities for this date */}
|
||||
<HoverCardContent
|
||||
side="top"
|
||||
align="center"
|
||||
sideOffset={18}
|
||||
className="w-88 sm:w-96 p-4 border-2 border-his/40 bg-popover/98 backdrop-blur-md shadow-2xl rounded-2xl z-50 text-foreground animate-in zoom-in-95 duration-150"
|
||||
>
|
||||
<div className="space-y-3">
|
||||
{/* Header */}
|
||||
<div className="flex items-start justify-between gap-3 border-b border-border/70 pb-2.5">
|
||||
<div>
|
||||
<h4 className="text-xs font-bold text-foreground flex items-center gap-1.5">
|
||||
<Calendar className="h-3.5 w-3.5 text-his shrink-0" />
|
||||
<span>{group.fullDate}</span>
|
||||
</h4>
|
||||
<p className="text-[11px] font-mono text-muted-foreground mt-0.5">
|
||||
{count} {count === 1 ? 'activity logged' : 'activities logged'} on this date
|
||||
</p>
|
||||
</div>
|
||||
<span className="rounded-full bg-his/10 text-his font-mono font-bold text-[10px] px-2 py-0.5 border border-his/30">
|
||||
{count} {count === 1 ? 'activity' : 'activities'}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Scrollable list of activities on this date */}
|
||||
<div className="space-y-2.5 max-h-60 overflow-y-auto pr-1 scrollbar-thin">
|
||||
{group.activities.map((item, idx) => {
|
||||
const timeStr = dayjs(item.created_at).format('HH:mm');
|
||||
const authorName = item.user?.fullname || item.user?.nickname || 'System';
|
||||
|
||||
return (
|
||||
<div
|
||||
key={item.id || idx}
|
||||
className="rounded-xl border border-border/70 bg-muted/30 p-2.5 text-xs space-y-1.5 transition-colors hover:bg-muted/50"
|
||||
>
|
||||
{/* Activity Meta Header */}
|
||||
<div className="flex items-center justify-between gap-2 flex-wrap">
|
||||
<div className="flex items-center gap-1.5 font-mono text-[11px] text-muted-foreground">
|
||||
<Clock className="h-3 w-3 text-muted-foreground/70" />
|
||||
<span className="font-semibold text-foreground">{timeStr}</span>
|
||||
<span>·</span>
|
||||
<span className="truncate max-w-30 text-foreground font-medium flex items-center gap-1">
|
||||
<User className="h-2.5 w-2.5 text-muted-foreground" />
|
||||
{authorName}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{item.type && (
|
||||
<BadgeStatus status={item.type} />
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Description text */}
|
||||
<p className="text-xs text-foreground/90 leading-relaxed font-normal">
|
||||
{item.description}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</HoverCardContent>
|
||||
</HoverCard>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* 4. END BOUNDARY NODE (at 100%) */}
|
||||
<div
|
||||
className={`absolute top-1/2 -translate-y-1/2 -translate-x-1/2 flex flex-col items-center z-10 transition-opacity duration-200 ${isAnyHovered ? 'opacity-40' : 'opacity-100'
|
||||
}`}
|
||||
style={{ left: '100%' }}
|
||||
>
|
||||
<div className="absolute -top-7 flex flex-col items-center pointer-events-none">
|
||||
<span className="text-xs font-semibold text-foreground whitespace-nowrap">
|
||||
End
|
||||
</span>
|
||||
</div>
|
||||
<div className="h-4 w-4 rounded-full border-2 border-violet-500 bg-violet-500 z-10 shadow-xs" />
|
||||
{endFormatted && (
|
||||
<div className="absolute top-6 flex flex-col items-center pointer-events-none">
|
||||
<span className="text-[10px] font-mono text-muted-foreground whitespace-nowrap font-medium">
|
||||
{dayjs(effectiveEnd).format('D MMM')}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Empty state notification if no logs exist */}
|
||||
{dateGroups.length === 0 && (
|
||||
<div className="p-4 text-center text-xs text-muted-foreground flex items-center justify-center gap-2 border-t border-border/60">
|
||||
<Info className="h-3.5 w-3.5 text-muted-foreground" />
|
||||
<span>Belum ada riwayat aktivitas (activity log) yang tercatat pada rentang timeline ini.</span>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
+8
-30
@@ -54,10 +54,7 @@ export default function AddActivityLogModal({
|
||||
const [description, setDescription] = useState<string>('');
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
// Fetch types from GET v1/project-assignment-status?type=log
|
||||
const { data: fetchedData, isLoading: isLoadingTypes } = useFetchWithAxios(
|
||||
open ? '/project-assignment-status?type=log' : null
|
||||
);
|
||||
const { data: fetchedData, isLoading: isLoadingTypes } = useFetchWithAxios(open ? '/project-assignment-status?type=log' : null);
|
||||
|
||||
const logTypes: IActivityLogType[] = useMemo(() => {
|
||||
if (Array.isArray(fetchedData) && fetchedData.length > 0) {
|
||||
@@ -93,17 +90,10 @@ export default function AddActivityLogModal({
|
||||
const payload = {
|
||||
project_assignment_id: Number(assignmentId),
|
||||
type: typeName,
|
||||
project_assignment_status_id: activeType?.id ? Number(activeType.id) : undefined,
|
||||
description: description.trim(),
|
||||
};
|
||||
|
||||
// Try primary endpoint POST /project-assignment/history
|
||||
let res = await serverApiCall('POST', '/project-assignment/history', payload);
|
||||
|
||||
// Fallback endpoint if 404
|
||||
if (!res.success && res.message?.includes('404')) {
|
||||
res = await serverApiCall('POST', `/project-assignment/${assignmentId}/history`, payload);
|
||||
}
|
||||
let res = await serverApiCall('POST', '/project-assignment-history', payload);
|
||||
|
||||
setIsSubmitting(false);
|
||||
|
||||
@@ -165,11 +155,7 @@ export default function AddActivityLogModal({
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Select
|
||||
value={selectedTypeId}
|
||||
onValueChange={setSelectedTypeId}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
<Select value={selectedTypeId} onValueChange={setSelectedTypeId} disabled={isSubmitting}>
|
||||
<SelectTrigger id="log-type-select" className="w-full h-10 text-sm">
|
||||
<SelectValue placeholder="Select activity type">
|
||||
{activeType && (
|
||||
@@ -182,20 +168,12 @@ export default function AddActivityLogModal({
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{logTypes.map((type) => (
|
||||
<SelectItem
|
||||
key={type.id}
|
||||
value={String(type.id)}
|
||||
className="py-2.5 cursor-pointer"
|
||||
>
|
||||
<SelectItem key={type.id} value={String(type.id)} className="py-2.5 cursor-pointer">
|
||||
<div className="flex items-center justify-between gap-4 w-full">
|
||||
<div className="flex flex-col text-left">
|
||||
<span className="font-medium text-foreground capitalize text-xs">
|
||||
{type.name}
|
||||
</span>
|
||||
<span className="font-medium text-foreground capitalize text-xs">{type.name}</span>
|
||||
{type.description && type.description !== type.name && (
|
||||
<span className="text-[11px] text-muted-foreground line-clamp-1">
|
||||
{type.description}
|
||||
</span>
|
||||
<span className="text-[11px] text-muted-foreground line-clamp-1">{type.description}</span>
|
||||
)}
|
||||
</div>
|
||||
<BadgeStatus status={type.name} />
|
||||
@@ -213,13 +191,13 @@ export default function AddActivityLogModal({
|
||||
Description <span className="text-destructive">*</span>
|
||||
</Label>
|
||||
<span className="text-[11px] text-muted-foreground font-mono">
|
||||
{description.length} / 1000
|
||||
{description.length} / 500
|
||||
</span>
|
||||
</div>
|
||||
<Textarea
|
||||
id="log-description"
|
||||
value={description}
|
||||
onChange={(e) => setDescription(e.target.value.slice(0, 1000))}
|
||||
onChange={(e) => setDescription(e.target.value.slice(0, 500))}
|
||||
placeholder="Detail the activity, bug fix, deployment action, or task completed..."
|
||||
rows={4}
|
||||
required
|
||||
|
||||
+17
-6
@@ -30,6 +30,11 @@ const ProjectMilestoneTimeline = dynamic(
|
||||
{ ssr: false, loading: () => <div className="h-44 w-full animate-pulse rounded-2xl border border-border/80 bg-card p-6" /> }
|
||||
);
|
||||
|
||||
const ActivityLogMilestoneTimeline = dynamic(
|
||||
() => import('./ActivityLogMilestoneTimeline').then((mod) => mod.ActivityLogMilestoneTimeline),
|
||||
{ ssr: false, loading: () => <div className="h-44 w-full animate-pulse rounded-2xl border border-border/80 bg-card p-6" /> }
|
||||
);
|
||||
|
||||
const DevelopmentActivityLog = dynamic(
|
||||
() => import('./DevelopmentActivityLog').then((mod) => mod.DevelopmentActivityLog),
|
||||
{ ssr: false, loading: () => <div className="h-64 w-full animate-pulse rounded-2xl border border-border/80 bg-card p-6" /> }
|
||||
@@ -98,7 +103,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
const assignmentName = assignment.wo_name || assignment.im_name || 'Untitled Assignment';
|
||||
const assignmentCode = assignment.wo_code || assignment.im_code;
|
||||
const assignmentStartDate = assignment.wo_start_date || assignment.im_start_date;
|
||||
const assignmentEndDate = assignment.wo_end_date || assignment.im_end_date;
|
||||
const assignmentEndDate = assignment.wo_end_date || assignment.im_end_date || assignment.project?.end_date;
|
||||
const assignmentDesc = assignment.wo_description || assignment.im_description;
|
||||
|
||||
const assignmentStatus = assignment.project_assignment_status.name
|
||||
@@ -180,10 +185,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
</div>
|
||||
|
||||
{/* Assignment Title */}
|
||||
<h1
|
||||
id="assignment-title"
|
||||
className="text-balance text-2xl font-bold tracking-tight text-foreground md:text-3xl wrap-break-word"
|
||||
>
|
||||
<h1 id="assignment-title" className="text-balance text-2xl font-bold tracking-tight text-foreground md:text-3xl wrap-break-word">
|
||||
{assignmentName}
|
||||
</h1>
|
||||
|
||||
@@ -359,7 +361,16 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
/>
|
||||
</Reveal>
|
||||
|
||||
{/* 3. Development Activity Log (with pagination & clean modal) */}
|
||||
{/* 3. Milestone Activity Log Timeline */}
|
||||
<Reveal delay={0.10}>
|
||||
<ActivityLogMilestoneTimeline
|
||||
history={assignment.project_assignment_history}
|
||||
startDate={assignmentStartDate}
|
||||
endDate={assignmentEndDate}
|
||||
/>
|
||||
</Reveal>
|
||||
|
||||
{/* 4. Development Activity Log (with pagination & clean modal) */}
|
||||
<Reveal delay={0.12}>
|
||||
<DevelopmentActivityLog
|
||||
history={assignment.project_assignment_history}
|
||||
|
||||
+66
-70
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useMemo } from 'react';
|
||||
import { useState, useMemo, useCallback } from 'react';
|
||||
import { ProjectAssignmentStatusDetail, ProjectAssignmentStatus } from '../../../type.assignment';
|
||||
import dayjs from 'dayjs';
|
||||
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
||||
@@ -152,30 +152,26 @@ export function ProjectMilestoneTimeline({
|
||||
const bastRange = getDetailDateRange(bastDetail);
|
||||
const warrantyDates = getDetailDateRange(warrantyDetail);
|
||||
|
||||
// Determine earliest start date (WO/IM start date or earliest agenda date)
|
||||
const rawStart = startDate || devRange.start;
|
||||
const earliestAgenda = [devRange.start, sitRange.start, uatRange.start].filter(Boolean)[0];
|
||||
// Determine start date: strictly use WO/IM start date if available
|
||||
const effectiveStart = useMemo(() => {
|
||||
if (rawStart && earliestAgenda) {
|
||||
return dayjs(earliestAgenda).isBefore(dayjs(rawStart)) ? earliestAgenda : rawStart;
|
||||
}
|
||||
return rawStart || earliestAgenda || dayjs().format('YYYY-MM-DD');
|
||||
}, [rawStart, earliestAgenda]);
|
||||
if (startDate && dayjs(startDate).isValid()) return startDate;
|
||||
if (devRange.start && dayjs(devRange.start).isValid()) return devRange.start;
|
||||
const earliestAgenda = [sitRange.start, uatRange.start].filter(Boolean)[0];
|
||||
return earliestAgenda || dayjs().format('YYYY-MM-DD');
|
||||
}, [startDate, devRange.start, sitRange.start, uatRange.start]);
|
||||
|
||||
// Determine latest end date (WO end date or latest agenda date)
|
||||
const rawEnd = endDate || bastRange.end || goLiveRange.end;
|
||||
const latestAgenda = [bastRange.end, bastRange.start, goLiveRange.end, ptrRange.end, uatRange.end].filter(Boolean)[0];
|
||||
// Determine end date: strictly use WO/IM end date if available
|
||||
const effectiveEnd = useMemo(() => {
|
||||
if (rawEnd && latestAgenda) {
|
||||
return dayjs(latestAgenda).isAfter(dayjs(rawEnd)) ? latestAgenda : rawEnd;
|
||||
}
|
||||
return rawEnd || latestAgenda || dayjs(effectiveStart).add(60, 'day').format('YYYY-MM-DD');
|
||||
}, [rawEnd, latestAgenda, effectiveStart]);
|
||||
if (endDate && dayjs(endDate).isValid()) return endDate;
|
||||
if (bastRange.end && dayjs(bastRange.end).isValid()) return bastRange.end;
|
||||
const latestAgenda = [goLiveRange.end, ptrRange.end, uatRange.end].filter(Boolean)[0];
|
||||
return latestAgenda || dayjs(effectiveStart).add(60, 'day').format('YYYY-MM-DD');
|
||||
}, [endDate, bastRange.end, goLiveRange.end, ptrRange.end, uatRange.end, effectiveStart]);
|
||||
|
||||
// Timestamp boundaries for percentage calculation
|
||||
const startMs = useMemo(() => dayjs(effectiveStart).startOf('day').valueOf(), [effectiveStart]);
|
||||
const endMs = useMemo(() => dayjs(effectiveEnd).endOf('day').valueOf(), [effectiveEnd]);
|
||||
const totalDuration = useMemo(() => Math.max(1, endMs - startMs), [endMs, startMs]);
|
||||
// Day boundaries for exact calendar day percentage calculation
|
||||
const startDay = useMemo(() => dayjs(effectiveStart).startOf('day'), [effectiveStart]);
|
||||
const endDay = useMemo(() => dayjs(effectiveEnd).startOf('day'), [effectiveEnd]);
|
||||
const totalDays = useMemo(() => Math.max(1, endDay.diff(startDay, 'day')), [endDay, startDay]);
|
||||
|
||||
const startFormatted = effectiveStart && dayjs(effectiveStart).isValid() ? dayjs(effectiveStart).format('D MMM YYYY') : '';
|
||||
const endFormatted = effectiveEnd && dayjs(effectiveEnd).isValid() ? dayjs(effectiveEnd).format('D MMM YYYY') : '';
|
||||
@@ -193,7 +189,7 @@ export function ProjectMilestoneTimeline({
|
||||
else if (techId === 11 || techName.includes('bast') || techName.includes('handover')) baseTechRank = 6;
|
||||
else if (techId === 12 || techName.includes('warranty')) baseTechRank = 7;
|
||||
|
||||
const todayVal = dayjs().valueOf();
|
||||
const todayDay = useMemo(() => dayjs().startOf('day'), []);
|
||||
const todayFormatted = dayjs().format('D MMM YYYY');
|
||||
|
||||
// Rule: Hapus agenda warranty jika tidak ada data pada technical status
|
||||
@@ -211,31 +207,28 @@ export function ProjectMilestoneTimeline({
|
||||
// Rule: Hapus thick atau dot today jika tanggal hari ini tidak ada dalam range tanggal WO tersebut
|
||||
const isTodayInRange = useMemo(() => {
|
||||
if (!effectiveStart || !effectiveEnd) return false;
|
||||
const sVal = dayjs(effectiveStart).startOf('day').valueOf();
|
||||
const eVal = dayjs(effectiveEnd).endOf('day').valueOf();
|
||||
return todayVal >= sVal && todayVal <= eVal;
|
||||
}, [effectiveStart, effectiveEnd, todayVal]);
|
||||
return (todayDay.isSame(startDay, 'day') || todayDay.isAfter(startDay)) &&
|
||||
(todayDay.isSame(endDay, 'day') || todayDay.isBefore(endDay));
|
||||
}, [effectiveStart, effectiveEnd, todayDay, startDay, endDay]);
|
||||
|
||||
const todayPercent = useMemo(() => {
|
||||
if (!isTodayInRange) return 0;
|
||||
const pct = ((todayVal - startMs) / totalDuration) * 100;
|
||||
return Math.min(99.5, Math.max(0.5, pct));
|
||||
}, [isTodayInRange, todayVal, startMs, totalDuration]);
|
||||
const diff = todayDay.diff(startDay, 'day');
|
||||
const pct = (diff / totalDays) * 100;
|
||||
return Math.min(100, Math.max(0, pct));
|
||||
}, [isTodayInRange, todayDay, startDay, totalDays]);
|
||||
|
||||
// Calculate month boundaries (1 Oct, 1 Nov, 1 Dec, etc.) for vertical tick marks
|
||||
const monthBoundaries = useMemo<IMonthBoundary[]>(() => {
|
||||
if (!effectiveStart || !effectiveEnd) return [];
|
||||
const list: IMonthBoundary[] = [];
|
||||
const startObj = dayjs(effectiveStart);
|
||||
const endObj = dayjs(effectiveEnd);
|
||||
|
||||
let cur = startObj.startOf('month');
|
||||
const limit = endObj.endOf('month');
|
||||
let cur = startDay.startOf('month');
|
||||
const limit = endDay.endOf('month');
|
||||
|
||||
while (cur.isSameOrBefore(limit, 'day')) {
|
||||
const firstVal = cur.startOf('day').valueOf();
|
||||
if (firstVal >= startMs && firstVal <= endMs) {
|
||||
const pct = ((firstVal - startMs) / totalDuration) * 100;
|
||||
if ((cur.isSame(startDay, 'day') || cur.isAfter(startDay)) && (cur.isSame(endDay, 'day') || cur.isBefore(endDay))) {
|
||||
const diff = cur.diff(startDay, 'day');
|
||||
const pct = (diff / totalDays) * 100;
|
||||
list.push({
|
||||
date: cur.format('YYYY-MM-DD'),
|
||||
label: cur.format('1 MMM'),
|
||||
@@ -245,7 +238,7 @@ export function ProjectMilestoneTimeline({
|
||||
cur = cur.add(1, 'month').startOf('month');
|
||||
}
|
||||
return list;
|
||||
}, [effectiveStart, effectiveEnd, startMs, endMs, totalDuration]);
|
||||
}, [effectiveStart, effectiveEnd, startDay, endDay, totalDays]);
|
||||
|
||||
// Active status highlights matching technical progression colors
|
||||
const isDevActive = baseTechRank === 1 || techName.includes('dev');
|
||||
@@ -256,16 +249,28 @@ export function ProjectMilestoneTimeline({
|
||||
const isBastActive = baseTechRank === 6;
|
||||
const isWarrantyActive = baseTechRank === 7;
|
||||
|
||||
// Proportional positioning helper
|
||||
const calcDatePercent = (dateStr: string | null | undefined, fallbackPct: number): number => {
|
||||
// Proportional positioning helper based on calendar days
|
||||
const calcDatePercent = useCallback((dateStr: string | null | undefined, fallbackPct: number): number => {
|
||||
if (!dateStr || !dayjs(dateStr).isValid()) return fallbackPct;
|
||||
const dVal = dayjs(dateStr).valueOf();
|
||||
const pct = ((dVal - startMs) / totalDuration) * 100;
|
||||
return Math.min(99.5, Math.max(0.5, pct));
|
||||
};
|
||||
const targetDay = dayjs(dateStr).startOf('day');
|
||||
const diff = targetDay.diff(startDay, 'day');
|
||||
const pct = (diff / totalDays) * 100;
|
||||
return Math.min(100, Math.max(0, pct));
|
||||
}, [startDay, totalDays]);
|
||||
|
||||
// Calculate precise percentages for each agenda
|
||||
const devPercent = useMemo(() => calcDatePercent(devRange.start, 12), [devRange.start, calcDatePercent]);
|
||||
// If DEV started before effectiveStart (e.g. DEV was 1 Oct, but WO starts 14 Oct),
|
||||
// on this milestone timeline DEV spans from effectiveStart (14 Oct) to its end_date (16 Oct).
|
||||
// Thus its milestone marker dot is positioned at its end date (or effectiveStart if ended before).
|
||||
const devPercent = useMemo(() => {
|
||||
let targetDate = devRange.end || devRange.start;
|
||||
if (devRange.start && dayjs(devRange.start).isBefore(dayjs(effectiveStart))) {
|
||||
targetDate = (devRange.end && dayjs(devRange.end).isAfter(dayjs(effectiveStart)))
|
||||
? devRange.end
|
||||
: effectiveStart;
|
||||
}
|
||||
return calcDatePercent(targetDate, 12);
|
||||
}, [devRange, effectiveStart, calcDatePercent]);
|
||||
const sitPercent = useMemo(() => calcDatePercent(sitRange.start, 28), [sitRange.start, calcDatePercent]);
|
||||
const uatPercent = useMemo(() => calcDatePercent(uatRange.start, 44), [uatRange.start, calcDatePercent]);
|
||||
const ptrPercent = useMemo(() => calcDatePercent(ptrRange.start, 60), [ptrRange.start, calcDatePercent]);
|
||||
@@ -281,7 +286,7 @@ export function ProjectMilestoneTimeline({
|
||||
const uatDateCompact = formatCompactDayDate(uatDetail);
|
||||
const ptrDateCompact = formatCompactDayDate(ptrDetail);
|
||||
const goLiveDateCompact = formatCompactDayDate(goLiveDetail);
|
||||
const bastDateCompact = formatCompactDayDate(bastDetail) || (effectiveEnd ? dayjs(effectiveEnd).format('D') : '');
|
||||
const bastDateCompact = formatCompactDayDate(bastDetail) || (effectiveEnd ? dayjs(effectiveEnd).format('D MMM') : '');
|
||||
|
||||
const devDateCompact = formatCompactDayDate(devDetail);
|
||||
|
||||
@@ -440,8 +445,10 @@ export function ProjectMilestoneTimeline({
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between gap-3 flex-wrap">
|
||||
<h2 className="flex items-center gap-2.5 text-base font-semibold tracking-tight text-foreground">
|
||||
<TrendingUp className="h-4 w-4 text-muted-foreground" />
|
||||
<span>Project Milestone Timeline</span>
|
||||
<span className="flex h-7 w-7 items-center justify-center rounded-lg bg-his/10 text-his">
|
||||
<TrendingUp className="h-4 w-4" />
|
||||
</span>
|
||||
<span>Assignment Milestone Timeline</span>
|
||||
</h2>
|
||||
<div className="flex items-center gap-2 font-mono text-xs text-muted-foreground">
|
||||
<span>{startFormatted}</span>
|
||||
@@ -452,7 +459,7 @@ export function ProjectMilestoneTimeline({
|
||||
|
||||
{/* Continuous Timeline Rail Container with Horizontal Scroll */}
|
||||
<div className="overflow-x-auto scrollbar-thin">
|
||||
<div className="min-w-255 px-12 pt-5 pb-10 flex items-center">
|
||||
<div className={`min-w-255 px-12 ${isTodayInRange ? 'pt-7' : 'pt-4'} pb-10 flex items-center`}>
|
||||
{/* The Proportional Rail Area */}
|
||||
<div className="relative flex-1 h-16">
|
||||
{/* Base Background Track Line */}
|
||||
@@ -475,7 +482,7 @@ export function ProjectMilestoneTimeline({
|
||||
|
||||
{/* Month milestone label underneath */}
|
||||
<div className="absolute top-12 flex flex-col items-center">
|
||||
<span className="text-[10px] font-mono font-bold text-muted-foreground bg-muted/60 px-1.5 py-0.5 rounded border border-border/70 shadow-2xs whitespace-nowrap">
|
||||
<span className="text-[10px] font-mono font-bold text-zinc-600 dark:text-zinc-200 bg-muted/60 px-1.5 py-0.5 rounded border border-border/70 shadow-2xs whitespace-nowrap">
|
||||
{mb.label}
|
||||
</span>
|
||||
</div>
|
||||
@@ -487,19 +494,14 @@ export function ProjectMilestoneTimeline({
|
||||
{lineSegments.map((seg, idx) => (
|
||||
<div
|
||||
key={`seg-${idx}`}
|
||||
className={`absolute top-1/2 -translate-y-1/2 h-1 ${seg.lineClass} transition-all duration-300 ${isAnyHovered ? 'opacity-40' : 'opacity-100'
|
||||
}`}
|
||||
style={{
|
||||
left: `${seg.left}%`,
|
||||
width: `${seg.width}%`,
|
||||
}}
|
||||
className={`absolute top-1/2 -translate-y-1/2 h-1 ${seg.lineClass} transition-all duration-300 ${isAnyHovered ? 'opacity-40' : 'opacity-100'}`}
|
||||
style={{ left: `${seg.left}%`, width: `${seg.width}%`, }}
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* 1. START NODE (at 0%) */}
|
||||
<div
|
||||
className={`absolute top-1/2 -translate-y-1/2 -translate-x-1/2 flex flex-col items-center z-10 transition-opacity duration-200 ${isAnyHovered ? 'opacity-40' : 'opacity-100'
|
||||
}`}
|
||||
className={`absolute top-1/2 -translate-y-1/2 -translate-x-1/2 flex flex-col items-center z-10 transition-opacity duration-200 ${isAnyHovered ? 'opacity-40' : 'opacity-100'}`}
|
||||
style={{ left: '0%' }}
|
||||
>
|
||||
<div className="absolute -top-7 flex flex-col items-center pointer-events-none">
|
||||
@@ -513,22 +515,16 @@ export function ProjectMilestoneTimeline({
|
||||
{/* 2. DYNAMIC TODAY MARKER (Only if in range) */}
|
||||
{isTodayInRange && (
|
||||
<div
|
||||
className={`absolute top-1/2 -translate-y-1/2 -translate-x-1/2 flex flex-col items-center z-25 pointer-events-none transition-all duration-200 ${isAnyHovered ? 'opacity-35 scale-95' : 'opacity-100'
|
||||
}`}
|
||||
className={`absolute top-1/2 -translate-y-1/2 -translate-x-1/2 flex flex-col items-center z-25 pointer-events-none transition-all duration-200 ${isAnyHovered ? 'opacity-35 scale-95' : 'opacity-100'}`}
|
||||
style={{ left: `${todayPercent}%` }}
|
||||
>
|
||||
<div className="absolute -top-10 flex flex-col items-center z-30">
|
||||
<div className="absolute -top-12.5 flex flex-col items-center z-30 w-max">
|
||||
<div className="rounded-full bg-his px-2.5 py-0.5 text-[10px] font-bold text-white shadow-xs">
|
||||
Today
|
||||
Today, {todayFormatted}
|
||||
</div>
|
||||
<div className="w-0.5 h-3 bg-his" />
|
||||
<div className="w-0.5 h-7.5 bg-his" />
|
||||
</div>
|
||||
<div className="h-3.5 w-3.5 rounded-full border-2 border-white bg-his z-20 shadow-xs" />
|
||||
<div className="absolute top-6 flex flex-col items-center">
|
||||
<span className="text-[10px] font-mono font-semibold text-foreground whitespace-nowrap">
|
||||
{todayFormatted}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -560,7 +556,7 @@ export function ProjectMilestoneTimeline({
|
||||
>
|
||||
|
||||
{/* Top Label (Expands and gets protective card shield on hover) */}
|
||||
<div className="absolute -top-7 flex flex-col items-center pointer-events-none transition-all duration-200">
|
||||
<div className="absolute -top-5 flex flex-col items-center pointer-events-none transition-all duration-200">
|
||||
<span
|
||||
className={`text-xs whitespace-nowrap transition-colors ${agenda.activeTextClass} ${agenda.isActive
|
||||
? `font-bold`
|
||||
@@ -626,7 +622,7 @@ export function ProjectMilestoneTimeline({
|
||||
|
||||
{/* Detail Activities List */}
|
||||
<div className="space-y-2">
|
||||
<span className="text-[11px] font-semibold text-muted-foreground uppercase tracking-wider block">
|
||||
<span className="text-[11px] font-semibold text-muted-foreground tracking-wider block">
|
||||
Activity Details {hasActivities && `(${entries.length})`}
|
||||
</span>
|
||||
|
||||
|
||||
+81
-28
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { serverApiCall } from '@/lib/server-api';
|
||||
import { toast } from 'sonner';
|
||||
@@ -40,6 +40,16 @@ export default function UpdateRealProgressModal({
|
||||
const [description, setDescription] = useState<string>('');
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
const val = typeof currentProgress === 'number' && !isNaN(currentProgress)
|
||||
? Math.min(100, Math.max(0, currentProgress))
|
||||
: 0;
|
||||
setProgress(val);
|
||||
setDescription('');
|
||||
}
|
||||
}, [open, currentProgress]);
|
||||
|
||||
const presetValues = [0, 25, 50, 75, 100];
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
@@ -105,21 +115,60 @@ export default function UpdateRealProgressModal({
|
||||
|
||||
{/* Form Body */}
|
||||
<form onSubmit={handleSubmit} className="space-y-5 px-6 py-5">
|
||||
{/* Draggable Progress Control */}
|
||||
<div className="space-y-3 rounded-xl border border-border/70 bg-muted/20 p-4">
|
||||
{/* Modern Filled Progress Slider Control */}
|
||||
<div className="space-y-4 rounded-xl border border-border/80 bg-muted/20 p-4.5">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label htmlFor="progress-slider" className="text-xs font-semibold text-foreground">
|
||||
Completion Percentage
|
||||
</Label>
|
||||
<div className="flex items-center gap-1.5 font-mono">
|
||||
<span className="text-2xl font-extrabold text-primary tracking-tight">
|
||||
{progress}%
|
||||
</span>
|
||||
<div>
|
||||
<Label htmlFor="progress-slider" className="text-xs font-semibold text-foreground">
|
||||
Completion Percentage
|
||||
</Label>
|
||||
<p className="text-[11px] text-muted-foreground mt-0.5">
|
||||
Drag slider or enter percentage directly
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-1 bg-background border border-border/80 rounded-lg px-2.5 py-1 shadow-2xs focus-within:ring-2 focus-within:ring-his/30 focus-within:border-his transition-all">
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
max={100}
|
||||
value={progress}
|
||||
onChange={(e) => {
|
||||
const v = parseInt(e.target.value, 10);
|
||||
if (isNaN(v)) {
|
||||
setProgress(0);
|
||||
} else {
|
||||
setProgress(Math.min(100, Math.max(0, v)));
|
||||
}
|
||||
}}
|
||||
disabled={isSaving}
|
||||
className="w-11 text-right font-mono font-bold text-base bg-transparent text-foreground focus:outline-none"
|
||||
/>
|
||||
<span className="font-mono font-bold text-sm text-his select-none">%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Interactive Range Slider */}
|
||||
<div className="relative py-2">
|
||||
{/* Custom Filled Slider Component */}
|
||||
<div className="relative py-2.5 select-none">
|
||||
{/* Track container */}
|
||||
<div className="relative h-3 w-full rounded-full bg-zinc-200/90 dark:bg-zinc-800 border border-zinc-300/70 dark:border-zinc-700/60 overflow-hidden">
|
||||
{/* Active filled track (0% to progress%) */}
|
||||
<div
|
||||
className="h-full bg-his transition-[width] duration-75 rounded-full"
|
||||
style={{ width: `${progress}%` }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Draggable thumb positioned precisely along the track */}
|
||||
<div
|
||||
className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 pointer-events-none transition-all duration-75 z-10"
|
||||
style={{ left: `${progress}%` }}
|
||||
>
|
||||
<div className="h-5 w-5 rounded-full bg-white dark:bg-zinc-900 border-2 border-his shadow-md flex items-center justify-center">
|
||||
<div className="h-1.5 w-1.5 rounded-full bg-his" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Transparent native range input overlay for seamless drag, click, and keyboard accessibility */}
|
||||
<input
|
||||
id="progress-slider"
|
||||
type="range"
|
||||
@@ -129,26 +178,30 @@ export default function UpdateRealProgressModal({
|
||||
value={progress}
|
||||
onChange={(e) => setProgress(Number(e.target.value))}
|
||||
disabled={isSaving}
|
||||
className="w-full h-2.5 bg-zinc-200 dark:bg-zinc-700 rounded-lg appearance-none cursor-pointer accent-his focus:outline-none focus:ring-2 focus:ring-his/30 transition-all"
|
||||
className="absolute inset-0 w-full h-full opacity-0 cursor-pointer z-20 focus:outline-none"
|
||||
aria-label="Completion percentage slider"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Quick Presets */}
|
||||
<div className="flex items-center justify-between gap-1 pt-1">
|
||||
{presetValues.map((val) => (
|
||||
<button
|
||||
key={val}
|
||||
type="button"
|
||||
onClick={() => setProgress(val)}
|
||||
disabled={isSaving}
|
||||
className={`px-2.5 py-1 text-[11px] font-mono rounded-md border transition-all ${progress === val
|
||||
? 'bg-his text-white border-his font-bold shadow-xs'
|
||||
: 'bg-background hover:bg-muted text-muted-foreground border-border/70 hover:text-foreground'
|
||||
}`}
|
||||
>
|
||||
{val}%
|
||||
</button>
|
||||
))}
|
||||
<div className="grid grid-cols-5 gap-1.5 pt-0.5">
|
||||
{presetValues.map((val) => {
|
||||
const isSelected = progress === val;
|
||||
return (
|
||||
<button
|
||||
key={val}
|
||||
type="button"
|
||||
onClick={() => setProgress(val)}
|
||||
disabled={isSaving}
|
||||
className={`py-1.5 text-xs font-mono rounded-lg border transition-all ${isSelected
|
||||
? 'bg-his text-white border-his font-bold shadow-xs'
|
||||
: 'bg-background hover:bg-muted text-muted-foreground border-border/70 hover:text-foreground font-medium'
|
||||
}`}
|
||||
>
|
||||
{val}%
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ const badgeVariants = cva(
|
||||
logUpdate: "border-transparent bg-sky-500 text-white dark:bg-sky-600 hover:opacity-85",
|
||||
logAction: "border-transparent bg-emerald-500 text-white dark:bg-emerald-600 hover:opacity-85",
|
||||
logIssue: "border-transparent bg-red-500 text-white dark:bg-red-600 hover:opacity-85",
|
||||
logSystem: "border-transparent text-white bg-his hover:opacity-85",
|
||||
logSystem: "border-transparent text-white bg-zinc-400 dark:bg-zinc-600 hover:opacity-85",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
|
||||
Reference in New Issue
Block a user