mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
chore: add validation in phase selection and sort activity and employee name
This commit is contained in:
@@ -127,6 +127,10 @@ export function DailyChecklistContent() {
|
||||
{ id: number; name: string }[]
|
||||
>([]);
|
||||
|
||||
const sortedSelectedEmployees = selectedEmployees.toSorted((a, b) =>
|
||||
a.name.localeCompare(b.name)
|
||||
);
|
||||
|
||||
const [dailyChecklistId, setDailyChecklistId] = useState<string | null>(null);
|
||||
const [checklistStatus, setChecklistStatus] = useState<string>('DRAFT');
|
||||
// const [isEditMode, setIsEditMode] = useState(false);
|
||||
@@ -486,6 +490,11 @@ export function DailyChecklistContent() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tempSelectedPhaseIds.length) {
|
||||
toast.error('Pilih minimal satu fase');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Insert new phase links
|
||||
const setDailyChecklistPhaseRes =
|
||||
@@ -1146,7 +1155,7 @@ export function DailyChecklistContent() {
|
||||
<th className='text-left py-3 px-4 text-sm font-semibold text-gray-700 border-r border-gray-200 min-w-[200px]'>
|
||||
Aktivitas
|
||||
</th>
|
||||
{selectedEmployees.map((emp) => (
|
||||
{sortedSelectedEmployees.map((emp) => (
|
||||
<th
|
||||
key={emp.id}
|
||||
className='text-center py-3 px-4 text-sm font-semibold text-gray-700 border-r border-gray-200 min-w-[100px]'
|
||||
@@ -1232,6 +1241,14 @@ export function DailyChecklistContent() {
|
||||
}
|
||||
|
||||
// ACTIVITY rows (Child rows with checkboxes)
|
||||
activities.sort((a, b) =>
|
||||
a.name.localeCompare(b.name, undefined, {
|
||||
sensitivity: 'base',
|
||||
})
|
||||
);
|
||||
|
||||
console.log(activities);
|
||||
|
||||
activities.forEach((activity, index) => {
|
||||
const taskId =
|
||||
taskIdsByPhaseActivityId[activity.id];
|
||||
@@ -1260,7 +1277,7 @@ export function DailyChecklistContent() {
|
||||
</p>
|
||||
)}
|
||||
</td>
|
||||
{selectedEmployees.map((emp) => (
|
||||
{sortedSelectedEmployees.map((emp) => (
|
||||
<td
|
||||
key={emp.id}
|
||||
className='text-center py-3 px-4 border-r border-gray-200'
|
||||
|
||||
Reference in New Issue
Block a user