refactor(FE-84-87) refactor checkbox using reuseable component checkboxinput

This commit is contained in:
randy-ar
2025-10-25 13:58:46 +07:00
parent 4f3dfb4221
commit f0f6ec53cb
10 changed files with 476 additions and 275 deletions
+6 -9
View File
@@ -15,7 +15,7 @@ import { Kandang } from '@/types/api/master-data/kandang';
import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
import { Icon } from '@iconify/react';
import { useRouter, useSearchParams } from 'next/navigation';
import { use, useEffect, useState } from 'react';
import { useState } from 'react';
import useSWR from 'swr';
@@ -34,9 +34,8 @@ const AddChickin = () => {
const [selectedKandang, setSelectedKandang] = useState<Kandang | undefined>(
undefined
);
const [projectFlockKandang, setProjectFlockKandang] = useState<
BaseApiResponse<ProjectFlockKandang>
>();
const [projectFlockKandang, setProjectFlockKandang] =
useState<BaseApiResponse<ProjectFlockKandang>>();
const [isLoadingProjectFlockKandang, setIsLoadingProjectFlockKandang] =
useState(false);
const [searchProjectFlock, setSearchProjectFlock] = useState('');
@@ -87,7 +86,7 @@ const AddChickin = () => {
}
// Handle Function
const handleChickinClick = async (kandang: Kandang) => {
const handleChickinClick = async (kandang: Kandang) => {
setIsLoadingProjectFlockKandang(true);
setSelectedKandang(kandang);
const ProjectFlockKandangRes = await ProjectFlockApi.customRequest<
@@ -100,9 +99,7 @@ const AddChickin = () => {
kandang_id: kandang.id,
},
});
if (
isResponseSuccess(ProjectFlockKandangRes)
) {
if (isResponseSuccess(ProjectFlockKandangRes)) {
setProjectFlockKandang(ProjectFlockKandangRes);
setIsLoadingProjectFlockKandang(false);
if (
@@ -110,7 +107,7 @@ const AddChickin = () => {
ProjectFlockKandangRes.data.available_quantity > 0
) {
chickinModal.openModal();
}else{
} else {
alertModal.openModal();
}
}