mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
fix(FE): fix chickins approvals status
This commit is contained in:
@@ -66,6 +66,7 @@ const ProjectFlockForm = ({
|
||||
useState('');
|
||||
const [selectedArea, setSelectedArea] = useState('');
|
||||
const [selectedLocation, setSelectedLocation] = useState('');
|
||||
const [selectedCategory, setSelectedCategory] = useState('');
|
||||
const [disabledLocation, setDisabledLocation] = useState(
|
||||
initialValues?.location?.id ? false : true
|
||||
);
|
||||
@@ -125,7 +126,10 @@ const ProjectFlockForm = ({
|
||||
const {
|
||||
options: optionsProductionStandards,
|
||||
isLoadingOptions: isLoadingProductionStandards,
|
||||
} = useSelect(ProductionStandardApi.basePath, 'id', 'name');
|
||||
} = useSelect(ProductionStandardApi.basePath, 'id', 'name', '', {
|
||||
search: '',
|
||||
project_category: selectedCategory,
|
||||
});
|
||||
|
||||
const kandangUrl = `${KandangApi.basePath}?${new URLSearchParams({
|
||||
search: '',
|
||||
@@ -237,9 +241,19 @@ const ProjectFlockForm = ({
|
||||
};
|
||||
|
||||
const categoryChangeHandler = (val: OptionType | OptionType[] | null) => {
|
||||
formik.setFieldValue('category', (val as OptionType)?.value);
|
||||
// Reset production standard when category is changed
|
||||
formik.setFieldValue('production_standard_id', '');
|
||||
formik.setFieldValue('production_standard', '');
|
||||
|
||||
formik.setFieldValue('category_option', val);
|
||||
if (val == null) {
|
||||
formik.setFieldValue('category', val ? (val as OptionType)?.value : '');
|
||||
|
||||
setSelectedCategory((val as OptionType)?.value as string);
|
||||
|
||||
if (Boolean(val)) {
|
||||
formik.setFieldTouched('category', false);
|
||||
formik.setFieldError('category', '');
|
||||
} else {
|
||||
formik.setFieldTouched('category', true);
|
||||
}
|
||||
};
|
||||
@@ -378,8 +392,6 @@ const ProjectFlockForm = ({
|
||||
validationSchema:
|
||||
formType == 'add' ? ProjectFlockFormSchema : UpdateProjectFlockFormSchema,
|
||||
validateOnBlur: true,
|
||||
// validateOnChange: true,
|
||||
// validateOnMount: true,
|
||||
onSubmit: async (values) => {
|
||||
setProjectFlockFormErrorMessage('');
|
||||
const payload: CreateProjectFlockPayload = {
|
||||
@@ -770,23 +782,6 @@ const ProjectFlockForm = ({
|
||||
isClearable
|
||||
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
|
||||
required
|
||||
label='Kategori'
|
||||
@@ -800,6 +795,23 @@ const ProjectFlockForm = ({
|
||||
isClearable
|
||||
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_id &&
|
||||
Boolean(formik.errors.production_standard_id)
|
||||
}
|
||||
errorMessage={formik.errors.production_standard_id as string}
|
||||
isClearable
|
||||
isDisabled={formType != 'add'}
|
||||
/>
|
||||
<NumberInput
|
||||
name='period'
|
||||
label='Periode'
|
||||
@@ -1064,7 +1076,7 @@ const ProjectFlockForm = ({
|
||||
type='submit'
|
||||
color='primary'
|
||||
isLoading={formik.isSubmitting}
|
||||
disabled={!formik.isValid || formik.isSubmitting}
|
||||
disabled={formik.isSubmitting}
|
||||
className='px-4 w-full'
|
||||
>
|
||||
<Icon icon='mdi:plus' width={24} height={24} />
|
||||
|
||||
Reference in New Issue
Block a user