diff --git a/src/config/constant.ts b/src/config/constant.ts
index 99c5ff9d..ca0682b4 100644
--- a/src/config/constant.ts
+++ b/src/config/constant.ts
@@ -20,6 +20,7 @@ export const MAIN_DRAWER_LINKS: SidebarMenuItem[] = [
'lti.daily_checklist.master_data.employee',
'lti.daily_checklist.master_data.activity',
'lti.daily_checklist.master_data.configuration',
+ 'lti.daily_checklist.master_data.kandang',
],
submenu: [
{
@@ -66,6 +67,11 @@ export const MAIN_DRAWER_LINKS: SidebarMenuItem[] = [
link: '/daily-checklist/master-data/activity',
permission: ['lti.daily_checklist.master_data.activity'],
},
+ {
+ text: 'Kandang',
+ link: '/daily-checklist/master-data/kandang',
+ permission: ['lti.daily_checklist.master_data.kandang'],
+ },
{
text: 'Konfigurasi',
link: '/daily-checklist/master-data/configuration',
diff --git a/src/config/route-permission.ts b/src/config/route-permission.ts
index dc638b29..8c65a611 100644
--- a/src/config/route-permission.ts
+++ b/src/config/route-permission.ts
@@ -21,6 +21,9 @@ export const ROUTE_PERMISSIONS: Record
= {
'/daily-checklist/master-data/configuration/': [
'lti.daily_checklist.master_data.configuration',
],
+ '/daily-checklist/master-data/kandang/': [
+ 'lti.daily_checklist.master_data.kandang',
+ ],
// Production
// Production - Project Flock
diff --git a/src/figma-make/components/base/multi-select.tsx b/src/figma-make/components/base/multi-select.tsx
index 63ebdd36..656073c6 100644
--- a/src/figma-make/components/base/multi-select.tsx
+++ b/src/figma-make/components/base/multi-select.tsx
@@ -1,7 +1,7 @@
'use client';
import * as React from 'react';
-import { Check, ChevronsUpDown, X } from 'lucide-react';
+import { Check, ChevronsUpDown, X, Loader2 } from 'lucide-react';
import { cn } from '@/lib/helper';
import { Button } from '@/figma-make/components/base/button';
import {
@@ -29,6 +29,8 @@ interface MultiSelectProps {
selected: string[];
onChange: (selected: string[]) => void;
onSearchChange?: (value: string) => void;
+ onLoadMore?: () => void;
+ isLoadingMore?: boolean;
placeholder?: string;
className?: string;
disabled?: boolean;
@@ -39,6 +41,8 @@ export function MultiSelect({
selected,
onChange,
onSearchChange,
+ onLoadMore,
+ isLoadingMore,
placeholder = 'Select items...',
className,
disabled,
@@ -115,7 +119,18 @@ export function MultiSelect({
onValueChange={onSearchChange}
/>
No item found.
-
+ {
+ const target = e.currentTarget;
+ if (
+ target.scrollHeight - target.scrollTop <=
+ target.clientHeight + 1
+ ) {
+ onLoadMore?.();
+ }
+ }}
+ >
{options.map((option) => (
))}
+ {isLoadingMore && (
+
+
+
+ )}
diff --git a/src/figma-make/components/base/select.tsx b/src/figma-make/components/base/select.tsx
index 625cf3d7..16725c04 100644
--- a/src/figma-make/components/base/select.tsx
+++ b/src/figma-make/components/base/select.tsx
@@ -55,7 +55,11 @@ function SelectContent({
children,
position = 'popper',
...props
-}: React.ComponentProps) {
+}: React.ComponentProps & {
+ onScroll?: React.UIEventHandler;
+}) {
+ const { onScroll, ...restProps } = props;
+
return (
{children}
diff --git a/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx b/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx
index 601025ad..1a9b4406 100644
--- a/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx
+++ b/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx
@@ -2,7 +2,16 @@
import * as React from 'react';
import { useState, useEffect } from 'react';
-import { Plus, X, Save, Send, Info, FilePlus, ListChecks } from 'lucide-react';
+import {
+ Plus,
+ X,
+ Save,
+ Send,
+ Info,
+ FilePlus,
+ ListChecks,
+ Loader2,
+} 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';
@@ -26,7 +35,6 @@ import {
import { DatePicker } from '@/figma-make/components/base/date-picker';
import { toast } from 'sonner';
import { useSelect } from '@/components/input/SelectInput';
-import { KandangApi } from '@/services/api/master-data';
import { DailyChecklistApi } from '@/services/api/daily-checklist/daily-checklist';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import useSWR from 'swr';
@@ -43,6 +51,7 @@ import DropFileInput from '@/components/input/DropFileInput';
import Link from 'next/link';
import { useRouter, useSearchParams, usePathname } from 'next/navigation';
import { Icon } from '@iconify/react';
+import { DailyChecklistKandangApi } from '@/services/api/daily-checklist/kandang';
// Static categories
const CATEGORIES = [
@@ -86,16 +95,11 @@ export function DailyChecklistContent() {
searchParams.get('category') || ''
);
- const { options: kandangOptions } = useSelect(
- KandangApi.basePath,
- 'id',
- 'name',
- 'search',
- {
- page: '1',
- limit: '100',
- }
- );
+ const {
+ options: kandangOptions,
+ isLoadingMore: isLoadingMoreKandang,
+ loadMore: loadMoreKandang,
+ } = useSelect(DailyChecklistKandangApi.basePath, 'id', 'name');
const { data: phases } = useSWR<
BaseApiResponse,
@@ -168,6 +172,16 @@ export function DailyChecklistContent() {
const [documents, setDocuments] = useState([]);
const [deletedDocumentIds, setDeletedDocumentIds] = useState([]);
+ const handleKandangScroll = (e: React.UIEvent) => {
+ const target = e.target as HTMLDivElement;
+
+ if (target.scrollHeight - target.scrollTop <= target.clientHeight + 10) {
+ if (!isLoadingMoreKandang) {
+ loadMoreKandang();
+ }
+ }
+ };
+
// Sync state to URL query params
useEffect(() => {
const params = new URLSearchParams(searchParams.toString());
@@ -994,7 +1008,7 @@ export function DailyChecklistContent() {
>
-
+
{kandangOptions.map((kandang) => (
))}
+
+ {isLoadingMoreKandang && (
+
+
+
+ )}
diff --git a/src/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent.tsx b/src/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent.tsx
index 6509a91d..e6127cf0 100644
--- a/src/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent.tsx
+++ b/src/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent.tsx
@@ -1,7 +1,15 @@
'use client';
import { useState } from 'react';
-import { Eye, CheckCircle, XCircle, Search, Trash2, Edit } from 'lucide-react';
+import {
+ Eye,
+ CheckCircle,
+ XCircle,
+ Search,
+ Trash2,
+ Edit,
+ Loader2,
+} from 'lucide-react';
import { Card, CardContent } from '@/figma-make/components/base/card';
import { Button } from '@/figma-make/components/base/button';
import { Badge } from '@/figma-make/components/base/badge';
@@ -34,9 +42,9 @@ import { DailyChecklist } from '@/types/api/daily-checklist/daily-checklist';
import { cn } from '@/lib/helper';
import { ColumnDef } from '@tanstack/react-table';
import { useSelect } from '@/components/input/SelectInput';
-import { KandangApi } from '@/services/api/master-data';
import DebouncedTextInput from '@/components/input/DebouncedTextInput';
import RequirePermission from '@/components/helper/RequirePermission';
+import { DailyChecklistKandangApi } from '@/services/api/daily-checklist/kandang';
const STATUS_OPTIONS = [
{ value: 'ALL', label: 'Semua Status' },
@@ -93,21 +101,25 @@ export function ListDailyChecklistContent() {
}
);
- const { options: kandangOptions } = useSelect(
- KandangApi.basePath,
- 'id',
- 'name',
- 'search',
- {
- page: '1',
- limit: '100',
- }
- );
+ const {
+ options: kandangOptions,
+ isLoadingMore: isLoadingMoreKandang,
+ loadMore: loadMoreKandang,
+ } = useSelect(DailyChecklistKandangApi.basePath, 'id', 'name');
const checklistList = isResponseSuccess(checklistListRes)
? checklistListRes.data || []
: [];
+ const handleKandangScroll = (e: React.UIEvent