fix(FE-41): Menambahkan kolom kapasitas di tabel kandang

This commit is contained in:
randy-ar
2025-10-31 14:57:15 +07:00
parent b6991652ac
commit 495e11c6fe
8 changed files with 62 additions and 2 deletions
@@ -27,6 +27,7 @@ const DUMMY_TRANSFER_TO_LAYING_EDIT: TransferToLaying = {
{ {
kandang: { kandang: {
id: 1, id: 1,
capacity: 1000,
name: 'Kandang test', name: 'Kandang test',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -56,6 +57,7 @@ const DUMMY_TRANSFER_TO_LAYING_EDIT: TransferToLaying = {
kandang: { kandang: {
id: 1, id: 1,
name: 'Kandang test 2', name: 'Kandang test 2',
capacity: 3000,
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
id: 1, id: 1,
@@ -27,6 +27,7 @@ const DUMMY_TRANSFER_TO_LAYING_DETAIL: TransferToLaying = {
{ {
kandang: { kandang: {
id: 1, id: 1,
capacity: 1000,
name: 'Kandang test', name: 'Kandang test',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -55,6 +56,7 @@ const DUMMY_TRANSFER_TO_LAYING_DETAIL: TransferToLaying = {
{ {
kandang: { kandang: {
id: 1, id: 1,
capacity: 3000,
name: 'Kandang test 2', name: 'Kandang test 2',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -22,7 +22,7 @@ import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import { Kandang } from '@/types/api/master-data/kandang'; import { Kandang } from '@/types/api/master-data/kandang';
import { KandangApi } from '@/services/api/master-data'; import { KandangApi } from '@/services/api/master-data';
import { cn } from '@/lib/helper'; import { cn, formatNumber } from '@/lib/helper';
import { isResponseSuccess } from '@/lib/api-helper'; import { isResponseSuccess } from '@/lib/api-helper';
import { useTableFilter } from '@/services/hooks/useTableFilter'; import { useTableFilter } from '@/services/hooks/useTableFilter';
import { ROWS_OPTIONS } from '@/config/constant'; import { ROWS_OPTIONS } from '@/config/constant';
@@ -93,12 +93,19 @@ const KandangsTable = () => {
setPageSize, setPageSize,
toQueryString: getTableFilterQueryString, toQueryString: getTableFilterQueryString,
} = useTableFilter({ } = useTableFilter({
initial: { search: '', nameSort: '', locationSort: '', picSort: '' }, initial: {
search: '',
nameSort: '',
locationSort: '',
capacitySort: '',
picSort: '',
},
paramMap: { paramMap: {
page: 'page', page: 'page',
pageSize: 'limit', pageSize: 'limit',
nameSort: 'sort_name', nameSort: 'sort_name',
locationSort: 'sort_location', locationSort: 'sort_location',
capacitySort: 'sort_capacity',
picSort: ' sort_pic', picSort: ' sort_pic',
}, },
}); });
@@ -138,6 +145,11 @@ const KandangsTable = () => {
header: 'Lokasi', header: 'Lokasi',
cell: (props) => props.row.original.location.name, cell: (props) => props.row.original.location.name,
}, },
{
accessorKey: 'capacity',
header: 'Kapasitas',
cell: (props) => formatNumber(props.row.original.capacity ?? 0),
},
{ {
accessorKey: 'pic', accessorKey: 'pic',
header: 'PIC', header: 'PIC',
@@ -11,6 +11,10 @@ export const KandangFormSchema = Yup.object({
label: Yup.string().required(), label: Yup.string().required(),
}).nullable(), }).nullable(),
capacity: Yup.number()
.min(1, 'Kapasitas wajib diisi!')
.required('Kapasitas wajib diisi!'),
picId: Yup.number().min(1, 'PIC wajib diisi!').required('PIC wajib diisi!'), picId: Yup.number().min(1, 'PIC wajib diisi!').required('PIC wajib diisi!'),
pic: Yup.object({ pic: Yup.object({
value: Yup.number().min(1).required(), value: Yup.number().min(1).required(),
@@ -27,6 +27,7 @@ import {
import { LocationApi, KandangApi } from '@/services/api/master-data'; import { LocationApi, KandangApi } from '@/services/api/master-data';
import { cn } from '@/lib/helper'; import { cn } from '@/lib/helper';
import { UserApi } from '@/services/api/user'; import { UserApi } from '@/services/api/user';
import NumberInput from '@/components/input/NumberInput';
interface KandangFormProps { interface KandangFormProps {
type?: 'add' | 'edit' | 'detail'; type?: 'add' | 'edit' | 'detail';
@@ -81,6 +82,7 @@ const KandangForm = ({ type = 'add', initialValues }: KandangFormProps) => {
label: initialValues.location.name, label: initialValues.location.name,
} }
: null, : null,
capacity: initialValues?.capacity ?? 0,
picId: initialValues?.pic?.id ?? 0, picId: initialValues?.pic?.id ?? 0,
pic: initialValues?.pic pic: initialValues?.pic
? { ? {
@@ -101,6 +103,7 @@ const KandangForm = ({ type = 'add', initialValues }: KandangFormProps) => {
const kandangPayload: CreateKandangPayload = { const kandangPayload: CreateKandangPayload = {
name: values.name, name: values.name,
location_id: values.locationId, location_id: values.locationId,
capacity: values.capacity,
pic_id: values.picId, pic_id: values.picId,
}; };
@@ -249,6 +252,20 @@ const KandangForm = ({ type = 'add', initialValues }: KandangFormProps) => {
isClearable isClearable
/> />
<NumberInput
required
name='capacity'
label='Kapasitas'
value={formik.values.capacity ?? undefined}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={
formik.touched.capacity && Boolean(formik.errors.capacity)
}
errorMessage={formik.errors.capacity as string}
readOnly={type === 'detail'}
/>
<SelectInput <SelectInput
required required
label='PIC' label='PIC'
@@ -52,6 +52,7 @@ const dummyRecordings: Recording[] = [
}, },
coop: { coop: {
id: 1, id: 1,
capacity: 1000,
name: 'Coop 1', name: 'Coop 1',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -33,6 +33,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 11, id: 11,
capacity: 1000,
name: 'KDG-11', name: 'KDG-11',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -61,6 +62,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 12, id: 12,
capacity: 1000,
name: 'KDG-12', name: 'KDG-12',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -107,6 +109,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 13, id: 13,
capacity: 1000,
name: 'KDG-13', name: 'KDG-13',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -135,6 +138,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 14, id: 14,
capacity: 1000,
name: 'KDG-14', name: 'KDG-14',
status: 'MAINTENANCE', status: 'MAINTENANCE',
location: { location: {
@@ -181,6 +185,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 21, id: 21,
capacity: 1000,
name: 'KDG-21', name: 'KDG-21',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -209,6 +214,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 22, id: 22,
capacity: 1000,
name: 'KDG-22', name: 'KDG-22',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -255,6 +261,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 15, id: 15,
capacity: 1000,
name: 'KDG-15', name: 'KDG-15',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -301,6 +308,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 23, id: 23,
capacity: 1000,
name: 'KDG-23', name: 'KDG-23',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -329,6 +337,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 24, id: 24,
capacity: 1000,
name: 'KDG-24', name: 'KDG-24',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -375,6 +384,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 16, id: 16,
capacity: 1000,
name: 'KDG-16', name: 'KDG-16',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -403,6 +413,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 17, id: 17,
capacity: 1000,
name: 'KDG-17', name: 'KDG-17',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -449,6 +460,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 18, id: 18,
capacity: 1000,
name: 'KDG-18', name: 'KDG-18',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -477,6 +489,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 19, id: 19,
capacity: 1000,
name: 'KDG-19', name: 'KDG-19',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -523,6 +536,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 25, id: 25,
capacity: 1000,
name: 'KDG-25', name: 'KDG-25',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -551,6 +565,7 @@ const GET_ALL_TRANSFER_TO_LAYING_DUMMY_DATA: BaseApiResponse<
{ {
kandang: { kandang: {
id: 26, id: 26,
capacity: 1000,
name: 'KDG-26', name: 'KDG-26',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -610,6 +625,7 @@ const FLOCK_SOURCE_DUMMY_DATA: BaseApiResponse<FlockWithKandangs[]> = {
{ {
kandang: { kandang: {
id: 3, id: 3,
capacity: 1000,
name: 'Cikaum 1', name: 'Cikaum 1',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -633,6 +649,7 @@ const FLOCK_SOURCE_DUMMY_DATA: BaseApiResponse<FlockWithKandangs[]> = {
{ {
kandang: { kandang: {
id: 4, id: 4,
capacity: 1000,
name: 'Cikaum 2', name: 'Cikaum 2',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -656,6 +673,7 @@ const FLOCK_SOURCE_DUMMY_DATA: BaseApiResponse<FlockWithKandangs[]> = {
{ {
kandang: { kandang: {
id: 5, id: 5,
capacity: 1000,
name: 'Cikaum 3', name: 'Cikaum 3',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -687,6 +705,7 @@ const FLOCK_SOURCE_DUMMY_DATA: BaseApiResponse<FlockWithKandangs[]> = {
{ {
kandang: { kandang: {
id: 3, id: 3,
capacity: 1000,
name: 'Cikaum 1', name: 'Cikaum 1',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
@@ -710,6 +729,7 @@ const FLOCK_SOURCE_DUMMY_DATA: BaseApiResponse<FlockWithKandangs[]> = {
{ {
kandang: { kandang: {
id: 4, id: 4,
capacity: 1000,
name: 'Cikaum 2', name: 'Cikaum 2',
status: 'ACTIVE', status: 'ACTIVE',
location: { location: {
+2
View File
@@ -7,6 +7,7 @@ export type BaseKandang = {
name: string; name: string;
status: string; status: string;
location: BaseLocation; location: BaseLocation;
capacity: number;
pic: BaseUser; pic: BaseUser;
}; };
@@ -15,6 +16,7 @@ export type Kandang = BaseMetadata & BaseKandang;
export type CreateKandangPayload = { export type CreateKandangPayload = {
name: string; name: string;
location_id: number; location_id: number;
capacity: number;
pic_id: number; pic_id: number;
}; };