mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-23 14:55:44 +00:00
refactor(FE): Remove unused imports and redundant code
This commit is contained in:
@@ -46,15 +46,15 @@ export function DatePicker({
|
||||
});
|
||||
};
|
||||
|
||||
const formatDateInput = (dateStr: string) => {
|
||||
if (!dateStr) return '';
|
||||
const d = new Date(dateStr + 'T00:00:00');
|
||||
return d.toLocaleDateString('en-GB', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
});
|
||||
};
|
||||
// const formatDateInput = (dateStr: string) => {
|
||||
// if (!dateStr) return '';
|
||||
// const d = new Date(dateStr + 'T00:00:00');
|
||||
// return d.toLocaleDateString('en-GB', {
|
||||
// day: '2-digit',
|
||||
// month: '2-digit',
|
||||
// year: 'numeric',
|
||||
// });
|
||||
// };
|
||||
|
||||
const displayFormatter = formatDisplay || defaultFormatDisplay;
|
||||
|
||||
|
||||
@@ -13,11 +13,6 @@ import {
|
||||
} from '@/figma-make/components/base/popover';
|
||||
import { Input } from '@/figma-make/components/base/input';
|
||||
|
||||
interface DateRange {
|
||||
from: string;
|
||||
to: string;
|
||||
}
|
||||
|
||||
interface DateRangePickerProps {
|
||||
dateFrom: string;
|
||||
dateTo: string;
|
||||
|
||||
@@ -86,17 +86,18 @@ export function DailyChecklistContent() {
|
||||
searchParams.get('category') || ''
|
||||
);
|
||||
|
||||
const { options: kandangOptions, isLoadingOptions: isLoadingKandangs } =
|
||||
useSelect(KandangApi.basePath, 'id', 'name', 'search', {
|
||||
const { options: kandangOptions } = useSelect(
|
||||
KandangApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
'search',
|
||||
{
|
||||
page: '1',
|
||||
limit: '100',
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const {
|
||||
data: phases,
|
||||
isLoading: isLoadingPhases,
|
||||
mutate: refreshPhases,
|
||||
} = useSWR<
|
||||
const { data: phases } = useSWR<
|
||||
BaseApiResponse<Phase[] | undefined>,
|
||||
AxiosError<BaseApiResponse>,
|
||||
SWRHttpKey
|
||||
@@ -104,11 +105,7 @@ export function DailyChecklistContent() {
|
||||
keepPreviousData: true,
|
||||
});
|
||||
|
||||
const {
|
||||
data: employeesRes,
|
||||
isLoading: isLoadingEmployees,
|
||||
mutate: refreshEmployees,
|
||||
} = useSWR(
|
||||
const { data: employeesRes } = useSWR(
|
||||
`${EmployeeApi.basePath}?page=1&limit=500&kandang_id=${kandangId}&is_active=true`,
|
||||
EmployeeApi.getAllFetcher,
|
||||
{
|
||||
|
||||
@@ -16,12 +16,7 @@ import {
|
||||
SelectValue,
|
||||
} from '@/figma-make/components/base/select';
|
||||
import { Badge } from '@/figma-make/components/base/badge';
|
||||
import {
|
||||
Calendar as CalendarIcon,
|
||||
Users,
|
||||
AlertCircle,
|
||||
Info,
|
||||
} from 'lucide-react';
|
||||
import { Users, AlertCircle, Info } from 'lucide-react';
|
||||
import { DateRangePicker } from '@/figma-make/components/base/date-range-picker';
|
||||
import {
|
||||
BarChart,
|
||||
@@ -71,11 +66,7 @@ export function Dashboard() {
|
||||
const [kandangFilter, setKandangFilter] = useState('ALL');
|
||||
const [categoryFilter, setCategoryFilter] = useState('ALL');
|
||||
|
||||
const {
|
||||
data: summaryResponse,
|
||||
isLoading: isLoadingSummary,
|
||||
mutate: refreshSummary,
|
||||
} = useSWR<
|
||||
const { data: summaryResponse, isLoading: isLoadingSummary } = useSWR<
|
||||
BaseApiResponse<DailyChecklistSummary | undefined>,
|
||||
AxiosError<BaseApiResponse>,
|
||||
SWRHttpKey
|
||||
@@ -86,11 +77,16 @@ export function Dashboard() {
|
||||
httpClientFetcher
|
||||
);
|
||||
|
||||
const { options: kandangOptions, isLoadingOptions: isLoadingKandangs } =
|
||||
useSelect(KandangApi.basePath, 'id', 'name', 'search', {
|
||||
const { options: kandangOptions } = useSelect(
|
||||
KandangApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
'search',
|
||||
{
|
||||
page: '1',
|
||||
limit: '100',
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const kandangColorMap: { [key: string]: string } = {};
|
||||
(kandangOptions || []).forEach((k, index) => {
|
||||
|
||||
@@ -38,11 +38,6 @@ import { KandangApi } from '@/services/api/master-data';
|
||||
import DebouncedTextInput from '@/components/input/DebouncedTextInput';
|
||||
import RequirePermission from '@/components/helper/RequirePermission';
|
||||
|
||||
interface Kandang {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const STATUS_OPTIONS = [
|
||||
{ value: 'ALL', label: 'Semua Status' },
|
||||
{ value: 'DRAFT', label: 'Draft' },
|
||||
@@ -98,11 +93,16 @@ export function ListDailyChecklistContent() {
|
||||
}
|
||||
);
|
||||
|
||||
const { options: kandangOptions, isLoadingOptions: isLoadingKandangs } =
|
||||
useSelect(KandangApi.basePath, 'id', 'name', 'search', {
|
||||
const { options: kandangOptions } = useSelect(
|
||||
KandangApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
'search',
|
||||
{
|
||||
page: '1',
|
||||
limit: '100',
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const checklistList = isResponseSuccess(checklistListRes)
|
||||
? checklistListRes.data || []
|
||||
|
||||
+14
-17
@@ -17,7 +17,7 @@ import {
|
||||
DialogFooter,
|
||||
} from '@/figma-make/components/base/dialog';
|
||||
import { toast } from 'sonner';
|
||||
import { notFound, useRouter, useSearchParams } from 'next/navigation';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import { DailyChecklistApi } from '@/services/api/daily-checklist/daily-checklist';
|
||||
import { isResponseError } from '@/lib/api-helper';
|
||||
import Link from 'next/link';
|
||||
@@ -90,16 +90,16 @@ interface ChecklistData {
|
||||
};
|
||||
}
|
||||
|
||||
interface AssignmentQueryResult {
|
||||
task_id: number;
|
||||
employee_id: string;
|
||||
checked: boolean;
|
||||
note: string | null;
|
||||
employees: {
|
||||
id: number;
|
||||
name: string;
|
||||
} | null;
|
||||
}
|
||||
// interface AssignmentQueryResult {
|
||||
// task_id: number;
|
||||
// employee_id: string;
|
||||
// checked: boolean;
|
||||
// note: string | null;
|
||||
// employees: {
|
||||
// id: number;
|
||||
// name: string;
|
||||
// } | null;
|
||||
// }
|
||||
|
||||
const CATEGORY_LABELS: { [key: string]: string } = {
|
||||
pullet_open: 'Pullet Open',
|
||||
@@ -124,7 +124,7 @@ export function DetailDailyChecklistContent() {
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [header, setHeader] = useState<ChecklistHeader | null>(null);
|
||||
const [detailRows, setDetailRows] = useState<ChecklistDetailRow[]>([]);
|
||||
const [, setDetailRows] = useState<ChecklistDetailRow[]>([]);
|
||||
const [phaseGroups, setPhaseGroups] = useState<PhaseGroup[]>([]);
|
||||
const [employees, setEmployees] = useState<{ id: string; name: string }[]>(
|
||||
[]
|
||||
@@ -381,7 +381,7 @@ export function DetailDailyChecklistContent() {
|
||||
// Convert to array and group by time_type
|
||||
const grouped: PhaseGroup[] = [];
|
||||
|
||||
phaseMap.forEach((phaseData, phaseId) => {
|
||||
phaseMap.forEach((phaseData) => {
|
||||
const timeGroups: {
|
||||
[timeType: string]: {
|
||||
activities: {
|
||||
@@ -570,9 +570,6 @@ export function DetailDailyChecklistContent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isReadOnly =
|
||||
header.status === 'APPROVED' || header.status === 'REJECTED';
|
||||
|
||||
return (
|
||||
<div className='min-h-screen'>
|
||||
<div className='p-6'>
|
||||
@@ -680,7 +677,7 @@ export function DetailDailyChecklistContent() {
|
||||
{header.status === 'REJECTED' && header.reject_reason && (
|
||||
<div className='mt-6 pt-6 border-t border-gray-200'>
|
||||
<div className='flex items-start gap-3 p-4 bg-red-50 border border-red-200 rounded-lg'>
|
||||
<AlertCircle className='w-5 h-5 text-red-600 mt-0.5 flex-shrink-0' />
|
||||
<AlertCircle className='w-5 h-5 text-red-600 mt-0.5 shrink-0' />
|
||||
<div>
|
||||
<Label className='text-sm font-medium text-red-900'>
|
||||
Alasan Reject
|
||||
|
||||
@@ -69,11 +69,7 @@ export function MasterAktivitasContent() {
|
||||
const [selectedCategory, setSelectedCategory] = useState<string>('');
|
||||
const [selectedPhase, setSelectedPhase] = useState<Phase | null>(null);
|
||||
|
||||
const {
|
||||
data: phases,
|
||||
isLoading: isLoadingPhases,
|
||||
mutate: refreshPhases,
|
||||
} = useSWR<
|
||||
const { data: phases, mutate: refreshPhases } = useSWR<
|
||||
BaseApiResponse<Phase[] | undefined>,
|
||||
AxiosError<BaseApiResponse>,
|
||||
SWRHttpKey
|
||||
@@ -87,11 +83,7 @@ export function MasterAktivitasContent() {
|
||||
}
|
||||
);
|
||||
|
||||
const {
|
||||
data: phaseActivities,
|
||||
isLoading: isLoadingPhaseActivities,
|
||||
mutate: refreshPhaseActivities,
|
||||
} = useSWR<
|
||||
const { data: phaseActivities, mutate: refreshPhaseActivities } = useSWR<
|
||||
BaseApiResponse<PhaseActivity[] | undefined>,
|
||||
AxiosError<BaseApiResponse>,
|
||||
SWRHttpKey
|
||||
@@ -630,7 +622,7 @@ export function MasterAktivitasContent() {
|
||||
<th className='text-left py-3.5 px-6 text-sm font-semibold text-gray-700'>
|
||||
Nama Aktivitas
|
||||
</th>
|
||||
<th className='text-center py-3.5 px-6 text-sm font-semibold text-gray-700 w-[80px]'>
|
||||
<th className='text-center py-3.5 px-6 text-sm font-semibold text-gray-700 w-20'>
|
||||
Aksi
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
+1
-5
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { Plus, MoreVertical, Pencil, Trash2 } from 'lucide-react';
|
||||
import { Card, CardContent } from '@/figma-make/components/base/card';
|
||||
import { Button } from '@/figma-make/components/base/button';
|
||||
@@ -295,10 +295,6 @@ export function MasterConfigurationContent() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleExport = (format: string) => {
|
||||
toast.success(`Data berhasil diekspor ke ${format}`);
|
||||
};
|
||||
|
||||
if (isLoadingDailyChecklistConfigurations && !dailyChecklistConfigurations) {
|
||||
return (
|
||||
<div className='min-h-screen'>
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
Plus,
|
||||
Download,
|
||||
ChevronDown,
|
||||
MoreVertical,
|
||||
Pencil,
|
||||
Trash2,
|
||||
Search,
|
||||
} from 'lucide-react';
|
||||
import { Plus, MoreVertical, Pencil, Trash2, Search } from 'lucide-react';
|
||||
import { Card, CardContent } from '@/figma-make/components/base/card';
|
||||
import { Button } from '@/figma-make/components/base/button';
|
||||
import { Label } from '@/figma-make/components/base/label';
|
||||
@@ -93,11 +85,16 @@ export function MasterEmployeeContent() {
|
||||
keepPreviousData: true,
|
||||
}
|
||||
);
|
||||
const { options: kandangOptions, isLoadingOptions: isLoadingKandangs } =
|
||||
useSelect(KandangApi.basePath, 'id', 'name', 'search', {
|
||||
const { options: kandangOptions } = useSelect(
|
||||
KandangApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
'search',
|
||||
{
|
||||
page: '1',
|
||||
limit: '100',
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||
@@ -373,7 +370,7 @@ export function MasterEmployeeContent() {
|
||||
updateFilter('status', value === 'all' ? '' : value);
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className='w-[160px] border-gray-200'>
|
||||
<SelectTrigger className='w-40 border-gray-200'>
|
||||
<SelectValue placeholder='Semua Status' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import { useMemo } from 'react';
|
||||
import { Card, CardContent } from '@/figma-make/components/base/card';
|
||||
import { Badge } from '@/figma-make/components/base/badge';
|
||||
import { Label } from '@/figma-make/components/base/label';
|
||||
import {
|
||||
Select,
|
||||
@@ -11,8 +10,6 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/figma-make/components/base/select';
|
||||
import { toast } from 'sonner';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useSelect } from '@/components/input/SelectInput';
|
||||
import { AreaApi, KandangApi, LocationApi } from '@/services/api/master-data';
|
||||
import useSWR from 'swr';
|
||||
@@ -26,7 +23,6 @@ import { isResponseSuccess } from '@/lib/api-helper';
|
||||
import { useTableFilter } from '@/services/hooks/useTableFilter';
|
||||
import { cn } from '@/lib/helper';
|
||||
import { ColumnDef } from '@tanstack/react-table';
|
||||
import { report } from 'process';
|
||||
import { PhaseApi } from '@/services/api/daily-checklist/phase';
|
||||
import { EmployeeApi } from '@/services/api/daily-checklist/employee';
|
||||
import { Button } from '@/figma-make/components/base/button';
|
||||
@@ -66,8 +62,6 @@ const YEAR_OPTIONS = [
|
||||
// };
|
||||
|
||||
export function DailyChecklistReportsContent() {
|
||||
const router = useRouter();
|
||||
|
||||
const currentMonth = useMemo(() => new Date().getMonth() + 1, []);
|
||||
const currentYear = useMemo(() => new Date().getFullYear(), []);
|
||||
|
||||
@@ -100,11 +94,7 @@ export function DailyChecklistReportsContent() {
|
||||
},
|
||||
});
|
||||
|
||||
const {
|
||||
data: reportResponse,
|
||||
isLoading: isLoadingReport,
|
||||
mutate: refreshReport,
|
||||
} = useSWR<
|
||||
const { data: reportResponse, isLoading: isLoadingReport } = useSWR<
|
||||
BaseApiResponse<DailyChecklistReport[] | undefined>,
|
||||
AxiosError<BaseApiResponse>,
|
||||
SWRHttpKey
|
||||
@@ -116,7 +106,7 @@ export function DailyChecklistReportsContent() {
|
||||
}
|
||||
);
|
||||
|
||||
const { options: areaOptions, isLoadingOptions: isLoadingAreas } = useSelect(
|
||||
const { options: areaOptions } = useSelect(
|
||||
AreaApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
@@ -127,33 +117,53 @@ export function DailyChecklistReportsContent() {
|
||||
}
|
||||
);
|
||||
|
||||
const { options: locationOptions, isLoadingOptions: isLoadingLocations } =
|
||||
useSelect(LocationApi.basePath, 'id', 'name', 'search', {
|
||||
const { options: locationOptions } = useSelect(
|
||||
LocationApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
'search',
|
||||
{
|
||||
page: '1',
|
||||
limit: '100',
|
||||
area_id: tableFilterState.area_id,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const { options: kandangOptions, isLoadingOptions: isLoadingKandangs } =
|
||||
useSelect(KandangApi.basePath, 'id', 'name', 'search', {
|
||||
const { options: kandangOptions } = useSelect(
|
||||
KandangApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
'search',
|
||||
{
|
||||
page: '1',
|
||||
limit: '100',
|
||||
area_id: tableFilterState.area_id,
|
||||
location_id: tableFilterState.location_id,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const { options: phaseOptions, isLoadingOptions: isLoadingPhases } =
|
||||
useSelect(PhaseApi.basePath, 'id', 'name', 'search', {
|
||||
const { options: phaseOptions } = useSelect(
|
||||
PhaseApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
'search',
|
||||
{
|
||||
page: '1',
|
||||
limit: '100',
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const { options: employeeOptions, isLoadingOptions: isLoadingEmployees } =
|
||||
useSelect(EmployeeApi.basePath, 'id', 'name', 'search', {
|
||||
const { options: employeeOptions } = useSelect(
|
||||
EmployeeApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
'search',
|
||||
{
|
||||
page: '1',
|
||||
limit: '500',
|
||||
kandang_id: tableFilterState.kandang_id,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const currentMonthMaxDay = new Date(
|
||||
Number(tableFilterState.tahun),
|
||||
|
||||
Reference in New Issue
Block a user