mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
feat(FE): adding production standard select options for project flock
This commit is contained in:
@@ -618,7 +618,7 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
|||||||
<ConfirmationModal
|
<ConfirmationModal
|
||||||
ref={deleteModal.ref}
|
ref={deleteModal.ref}
|
||||||
type='error'
|
type='error'
|
||||||
text={`Apakah anda yakin ingin menghapus data Project Flock ini (${selectedProjectFlock?.flock_name})?`}
|
text={`Apakah anda yakin ingin menghapus data Project Flock ini (${selectedRowIds?.length} data)?`}
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Tidak',
|
text: 'Tidak',
|
||||||
}}
|
}}
|
||||||
@@ -633,7 +633,7 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
|||||||
<ConfirmationModalWithNotes
|
<ConfirmationModalWithNotes
|
||||||
ref={confirmModal.ref}
|
ref={confirmModal.ref}
|
||||||
type={approvalAction == 'APPROVED' ? 'success' : 'error'}
|
type={approvalAction == 'APPROVED' ? 'success' : 'error'}
|
||||||
text={`Apakah anda yakin ingin ${approvalAction == 'APPROVED' ? 'approve' : 'reject'} data Project Flock ini (${selectedRowIds.length} data)?`}
|
text={`Apakah anda yakin ingin ${approvalAction == 'APPROVED' ? 'approve' : 'reject'} data Project Flock ini (${selectedRowIds?.length} data)?`}
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Tidak',
|
text: 'Tidak',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ type ProjectFlockFormSchemaType = {
|
|||||||
label: string;
|
label: string;
|
||||||
} | null;
|
} | null;
|
||||||
fcr_id: number;
|
fcr_id: number;
|
||||||
|
production_standard: {
|
||||||
|
value: number | string;
|
||||||
|
label: string;
|
||||||
|
} | null;
|
||||||
|
production_standard_id: number;
|
||||||
location: {
|
location: {
|
||||||
value: number | string;
|
value: number | string;
|
||||||
label: string;
|
label: string;
|
||||||
@@ -100,6 +105,15 @@ export const ProjectFlockFormSchema: Yup.ObjectSchema<ProjectFlockFormSchemaType
|
|||||||
.min(1, 'FCR wajib diisi!')
|
.min(1, 'FCR wajib diisi!')
|
||||||
.required('FCR wajib diisi!'),
|
.required('FCR wajib diisi!'),
|
||||||
|
|
||||||
|
// Production Standard
|
||||||
|
production_standard: Yup.object({
|
||||||
|
value: Yup.number().required('ID Standar Produksi wajib diisi!'),
|
||||||
|
label: Yup.string().required('Nama Standar Produksi wajib diisi!'),
|
||||||
|
}).nullable(),
|
||||||
|
production_standard_id: Yup.number()
|
||||||
|
.min(1, 'Standar Produksi wajib diisi!')
|
||||||
|
.required('Standar Produksi wajib diisi!'),
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
location: Yup.object({
|
location: Yup.object({
|
||||||
value: Yup.number().required('ID Lokasi wajib diisi!'),
|
value: Yup.number().required('ID Lokasi wajib diisi!'),
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
KandangApi,
|
KandangApi,
|
||||||
LocationApi,
|
LocationApi,
|
||||||
NonstockApi,
|
NonstockApi,
|
||||||
|
ProductionStandardApi,
|
||||||
} from '@/services/api/master-data';
|
} from '@/services/api/master-data';
|
||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
import { FormikErrors, useFormik } from 'formik';
|
import { FormikErrors, useFormik } from 'formik';
|
||||||
@@ -136,6 +137,11 @@ const ProjectFlockForm = ({
|
|||||||
'name'
|
'name'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const {
|
||||||
|
options: optionsProductionStandards,
|
||||||
|
isLoadingOptions: isLoadingProductionStandards,
|
||||||
|
} = useSelect(ProductionStandardApi.basePath, 'id', 'name');
|
||||||
|
|
||||||
const kandangUrl = `${KandangApi.basePath}?${new URLSearchParams({
|
const kandangUrl = `${KandangApi.basePath}?${new URLSearchParams({
|
||||||
search: '',
|
search: '',
|
||||||
location_id: selectedLocation == '' ? '0' : selectedLocation,
|
location_id: selectedLocation == '' ? '0' : selectedLocation,
|
||||||
@@ -341,6 +347,12 @@ const ProjectFlockForm = ({
|
|||||||
label: initialValues.fcr.name,
|
label: initialValues.fcr.name,
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
|
production_standard: initialValues?.production_standard
|
||||||
|
? {
|
||||||
|
value: initialValues.production_standard?.id,
|
||||||
|
label: initialValues.production_standard.name,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
location: initialValues?.location
|
location: initialValues?.location
|
||||||
? {
|
? {
|
||||||
value: initialValues.location?.id,
|
value: initialValues.location?.id,
|
||||||
@@ -356,6 +368,7 @@ const ProjectFlockForm = ({
|
|||||||
'GROWING' | 'LAYING' | undefined
|
'GROWING' | 'LAYING' | undefined
|
||||||
>,
|
>,
|
||||||
fcr_id: initialValues?.fcr?.id ?? 0,
|
fcr_id: initialValues?.fcr?.id ?? 0,
|
||||||
|
production_standard_id: initialValues?.production_standard?.id ?? 0,
|
||||||
location_id: initialValues?.location?.id ?? 0,
|
location_id: initialValues?.location?.id ?? 0,
|
||||||
kandang_ids: initialValues?.kandangs?.map(
|
kandang_ids: initialValues?.kandangs?.map(
|
||||||
(k: Kandang) => k.id
|
(k: Kandang) => k.id
|
||||||
@@ -400,6 +413,7 @@ const ProjectFlockForm = ({
|
|||||||
area_id: values.area_id as number,
|
area_id: values.area_id as number,
|
||||||
category: values.category as string,
|
category: values.category as string,
|
||||||
fcr_id: values.fcr_id as number,
|
fcr_id: values.fcr_id as number,
|
||||||
|
production_standard_id: values.production_standard_id as number,
|
||||||
location_id: values.location_id as number,
|
location_id: values.location_id as number,
|
||||||
kandang_ids: values.kandang_ids as number[],
|
kandang_ids: values.kandang_ids as number[],
|
||||||
project_budgets: values.project_budgets.flatMap((budget) => {
|
project_budgets: values.project_budgets.flatMap((budget) => {
|
||||||
@@ -858,6 +872,23 @@ const ProjectFlockForm = ({
|
|||||||
isClearable
|
isClearable
|
||||||
isDisabled={formType != 'add'}
|
isDisabled={formType != 'add'}
|
||||||
/>
|
/>
|
||||||
|
<SelectInput
|
||||||
|
required
|
||||||
|
label='Standar Produksi'
|
||||||
|
value={formik.values.production_standard as OptionType}
|
||||||
|
onChange={(val) => {
|
||||||
|
optionChangeHandler(val, 'production_standard');
|
||||||
|
}}
|
||||||
|
options={optionsProductionStandards}
|
||||||
|
isLoading={isLoadingProductionStandards}
|
||||||
|
isError={
|
||||||
|
formik.touched.production_standard &&
|
||||||
|
Boolean(formik.errors.production_standard)
|
||||||
|
}
|
||||||
|
errorMessage={formik.errors.production_standard as string}
|
||||||
|
isClearable
|
||||||
|
isDisabled={formType != 'add'}
|
||||||
|
/>
|
||||||
<SelectInput
|
<SelectInput
|
||||||
required
|
required
|
||||||
label='Kategori'
|
label='Kategori'
|
||||||
|
|||||||
+3
@@ -16,6 +16,8 @@ export type BaseProjectFlock = {
|
|||||||
category: string;
|
category: string;
|
||||||
fcr: Fcr;
|
fcr: Fcr;
|
||||||
fcr_id: number;
|
fcr_id: number;
|
||||||
|
production_standard: ProductionStandard;
|
||||||
|
production_standard_id: number;
|
||||||
location: Location;
|
location: Location;
|
||||||
location_id: number;
|
location_id: number;
|
||||||
period: number;
|
period: number;
|
||||||
@@ -48,6 +50,7 @@ export type CreateProjectFlockPayload = {
|
|||||||
area_id: number;
|
area_id: number;
|
||||||
category: string;
|
category: string;
|
||||||
fcr_id: number;
|
fcr_id: number;
|
||||||
|
production_standard_id: number;
|
||||||
location_id: number;
|
location_id: number;
|
||||||
kandang_ids: number[];
|
kandang_ids: number[];
|
||||||
project_budgets?: ProjectFlockBudget[];
|
project_budgets?: ProjectFlockBudget[];
|
||||||
|
|||||||
Reference in New Issue
Block a user