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
@@ -11,6 +11,10 @@ export const KandangFormSchema = Yup.object({
label: Yup.string().required(),
}).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!'),
pic: Yup.object({
value: Yup.number().min(1).required(),
@@ -27,6 +27,7 @@ import {
import { LocationApi, KandangApi } from '@/services/api/master-data';
import { cn } from '@/lib/helper';
import { UserApi } from '@/services/api/user';
import NumberInput from '@/components/input/NumberInput';
interface KandangFormProps {
type?: 'add' | 'edit' | 'detail';
@@ -81,6 +82,7 @@ const KandangForm = ({ type = 'add', initialValues }: KandangFormProps) => {
label: initialValues.location.name,
}
: null,
capacity: initialValues?.capacity ?? 0,
picId: initialValues?.pic?.id ?? 0,
pic: initialValues?.pic
? {
@@ -101,6 +103,7 @@ const KandangForm = ({ type = 'add', initialValues }: KandangFormProps) => {
const kandangPayload: CreateKandangPayload = {
name: values.name,
location_id: values.locationId,
capacity: values.capacity,
pic_id: values.picId,
};
@@ -249,6 +252,20 @@ const KandangForm = ({ type = 'add', initialValues }: KandangFormProps) => {
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
required
label='PIC'