mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
Merge branch 'fix/chickins-approval' into 'development'
[FIX/FE] Fix chickins approval See merge request mbugroup/lti-web-client!143
This commit is contained in:
@@ -34,7 +34,7 @@ const ChickinFormKandang = ({
|
|||||||
isLoading: approvalsLoading,
|
isLoading: approvalsLoading,
|
||||||
refresh: refreshApprovals,
|
refresh: refreshApprovals,
|
||||||
} = useApprovalSteps({
|
} = useApprovalSteps({
|
||||||
latestApproval: initialValues?.approval,
|
latestApproval: initialValues?.chickin_approval,
|
||||||
approvalLines: CHICKINS_APPROVAL_LINE,
|
approvalLines: CHICKINS_APPROVAL_LINE,
|
||||||
moduleName: 'CHICKINS',
|
moduleName: 'CHICKINS',
|
||||||
moduleId: initialValues?.id.toString() ?? '',
|
moduleId: initialValues?.id.toString() ?? '',
|
||||||
|
|||||||
@@ -60,8 +60,9 @@ const ChickinLogsView = ({
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
(initialValues?.chickins || []).map((chickin, index) => {
|
(initialValues?.chickins || []).map((chickin, index) => {
|
||||||
const isApproved = chickin.usage_qty !== 0;
|
const isApproved =
|
||||||
const isPending = chickin.pending_usage_qty !== 0;
|
initialValues.chickin_approval?.step_number === 2;
|
||||||
|
const isPending = initialValues.chickin_approval?.step_number === 1;
|
||||||
const quantity = isApproved
|
const quantity = isApproved
|
||||||
? chickin.usage_qty
|
? chickin.usage_qty
|
||||||
: isPending
|
: isPending
|
||||||
@@ -146,7 +147,8 @@ const ChickinLogsView = ({
|
|||||||
})
|
})
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{initialValues?.approval?.step_number <= 2 && (
|
{initialValues.chickin_approval &&
|
||||||
|
initialValues?.chickin_approval?.step_number < 2 && (
|
||||||
<RequirePermission permissions='lti.production.chickins.approve'>
|
<RequirePermission permissions='lti.production.chickins.approve'>
|
||||||
<Button
|
<Button
|
||||||
color='success'
|
color='success'
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ const ProjectFlockForm = ({
|
|||||||
useState('');
|
useState('');
|
||||||
const [selectedArea, setSelectedArea] = useState('');
|
const [selectedArea, setSelectedArea] = useState('');
|
||||||
const [selectedLocation, setSelectedLocation] = useState('');
|
const [selectedLocation, setSelectedLocation] = useState('');
|
||||||
|
const [selectedCategory, setSelectedCategory] = useState('');
|
||||||
const [disabledLocation, setDisabledLocation] = useState(
|
const [disabledLocation, setDisabledLocation] = useState(
|
||||||
initialValues?.location?.id ? false : true
|
initialValues?.location?.id ? false : true
|
||||||
);
|
);
|
||||||
@@ -125,7 +126,10 @@ const ProjectFlockForm = ({
|
|||||||
const {
|
const {
|
||||||
options: optionsProductionStandards,
|
options: optionsProductionStandards,
|
||||||
isLoadingOptions: isLoadingProductionStandards,
|
isLoadingOptions: isLoadingProductionStandards,
|
||||||
} = useSelect(ProductionStandardApi.basePath, 'id', 'name');
|
} = useSelect(ProductionStandardApi.basePath, 'id', 'name', '', {
|
||||||
|
search: '',
|
||||||
|
project_category: selectedCategory,
|
||||||
|
});
|
||||||
|
|
||||||
const kandangUrl = `${KandangApi.basePath}?${new URLSearchParams({
|
const kandangUrl = `${KandangApi.basePath}?${new URLSearchParams({
|
||||||
search: '',
|
search: '',
|
||||||
@@ -237,9 +241,19 @@ const ProjectFlockForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const categoryChangeHandler = (val: OptionType | OptionType[] | null) => {
|
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);
|
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);
|
formik.setFieldTouched('category', true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -378,8 +392,6 @@ const ProjectFlockForm = ({
|
|||||||
validationSchema:
|
validationSchema:
|
||||||
formType == 'add' ? ProjectFlockFormSchema : UpdateProjectFlockFormSchema,
|
formType == 'add' ? ProjectFlockFormSchema : UpdateProjectFlockFormSchema,
|
||||||
validateOnBlur: true,
|
validateOnBlur: true,
|
||||||
// validateOnChange: true,
|
|
||||||
// validateOnMount: true,
|
|
||||||
onSubmit: async (values) => {
|
onSubmit: async (values) => {
|
||||||
setProjectFlockFormErrorMessage('');
|
setProjectFlockFormErrorMessage('');
|
||||||
const payload: CreateProjectFlockPayload = {
|
const payload: CreateProjectFlockPayload = {
|
||||||
@@ -770,23 +782,6 @@ 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'
|
||||||
@@ -800,6 +795,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_id &&
|
||||||
|
Boolean(formik.errors.production_standard_id)
|
||||||
|
}
|
||||||
|
errorMessage={formik.errors.production_standard_id as string}
|
||||||
|
isClearable
|
||||||
|
isDisabled={formType != 'add'}
|
||||||
|
/>
|
||||||
<NumberInput
|
<NumberInput
|
||||||
name='period'
|
name='period'
|
||||||
label='Periode'
|
label='Periode'
|
||||||
@@ -1064,7 +1076,7 @@ const ProjectFlockForm = ({
|
|||||||
type='submit'
|
type='submit'
|
||||||
color='primary'
|
color='primary'
|
||||||
isLoading={formik.isSubmitting}
|
isLoading={formik.isSubmitting}
|
||||||
disabled={!formik.isValid || formik.isSubmitting}
|
disabled={formik.isSubmitting}
|
||||||
className='px-4 w-full'
|
className='px-4 w-full'
|
||||||
>
|
>
|
||||||
<Icon icon='mdi:plus' width={24} height={24} />
|
<Icon icon='mdi:plus' width={24} height={24} />
|
||||||
|
|||||||
+3
-10
@@ -10,9 +10,10 @@ export type BaseProjectFlockKandang = {
|
|||||||
kandang_id: number;
|
kandang_id: number;
|
||||||
kandang: Kandang;
|
kandang: Kandang;
|
||||||
project_flock: ProjectFlock;
|
project_flock: ProjectFlock;
|
||||||
available_qtys?: AvailableQty[];
|
|
||||||
chickins?: Chickin[];
|
|
||||||
approval: BaseApproval;
|
approval: BaseApproval;
|
||||||
|
chickins?: Chickin[];
|
||||||
|
available_qtys?: AvailableQty[];
|
||||||
|
chickin_approval?: BaseApproval;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AvailableQty = {
|
export type AvailableQty = {
|
||||||
@@ -56,14 +57,6 @@ export type ClosingExpense = {
|
|||||||
reference_number: string;
|
reference_number: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
// "flag_name": "PAKAN",
|
|
||||||
// "product_warehouse_id": 14,
|
|
||||||
// "product_id": 8,
|
|
||||||
// "product_name": "281 SPECIAL STARTER",
|
|
||||||
// "product_category": "Bahan Baku",
|
|
||||||
// "uom": "Kilogram",
|
|
||||||
// "quantity": 1100
|
|
||||||
|
|
||||||
export type StockItem = {
|
export type StockItem = {
|
||||||
flag_name: string;
|
flag_name: string;
|
||||||
product_warehouse_id: number;
|
product_warehouse_id: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user