mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
fix(FE): fix chickins approvals status
This commit is contained in:
@@ -34,7 +34,7 @@ const ChickinFormKandang = ({
|
||||
isLoading: approvalsLoading,
|
||||
refresh: refreshApprovals,
|
||||
} = useApprovalSteps({
|
||||
latestApproval: initialValues?.approval,
|
||||
latestApproval: initialValues?.chickin_approval,
|
||||
approvalLines: CHICKINS_APPROVAL_LINE,
|
||||
moduleName: 'CHICKINS',
|
||||
moduleId: initialValues?.id.toString() ?? '',
|
||||
|
||||
@@ -60,8 +60,9 @@ const ChickinLogsView = ({
|
||||
</div>
|
||||
) : (
|
||||
(initialValues?.chickins || []).map((chickin, index) => {
|
||||
const isApproved = chickin.usage_qty !== 0;
|
||||
const isPending = chickin.pending_usage_qty !== 0;
|
||||
const isApproved =
|
||||
initialValues.chickin_approval?.step_number === 2;
|
||||
const isPending = initialValues.chickin_approval?.step_number === 1;
|
||||
const quantity = isApproved
|
||||
? chickin.usage_qty
|
||||
: isPending
|
||||
@@ -146,18 +147,19 @@ const ChickinLogsView = ({
|
||||
})
|
||||
)}
|
||||
|
||||
{initialValues?.approval?.step_number <= 2 && (
|
||||
<RequirePermission permissions='lti.production.chickins.approve'>
|
||||
<Button
|
||||
color='success'
|
||||
onClick={handleClickApprove}
|
||||
className='w-full'
|
||||
>
|
||||
<Icon width={24} height={24} icon='material-symbols:check' />
|
||||
Approve Semua Chick In
|
||||
</Button>
|
||||
</RequirePermission>
|
||||
)}
|
||||
{initialValues.chickin_approval &&
|
||||
initialValues?.chickin_approval?.step_number < 2 && (
|
||||
<RequirePermission permissions='lti.production.chickins.approve'>
|
||||
<Button
|
||||
color='success'
|
||||
onClick={handleClickApprove}
|
||||
className='w-full'
|
||||
>
|
||||
<Icon width={24} height={24} icon='material-symbols:check' />
|
||||
Approve Semua Chick In
|
||||
</Button>
|
||||
</RequirePermission>
|
||||
)}
|
||||
|
||||
{chickinErrorMessage && (
|
||||
<div className='w-full' onClick={() => setChickinErrorMessage('')}>
|
||||
|
||||
@@ -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} />
|
||||
|
||||
+3
-10
@@ -10,9 +10,10 @@ export type BaseProjectFlockKandang = {
|
||||
kandang_id: number;
|
||||
kandang: Kandang;
|
||||
project_flock: ProjectFlock;
|
||||
available_qtys?: AvailableQty[];
|
||||
chickins?: Chickin[];
|
||||
approval: BaseApproval;
|
||||
chickins?: Chickin[];
|
||||
available_qtys?: AvailableQty[];
|
||||
chickin_approval?: BaseApproval;
|
||||
};
|
||||
|
||||
export type AvailableQty = {
|
||||
@@ -56,14 +57,6 @@ export type ClosingExpense = {
|
||||
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 = {
|
||||
flag_name: string;
|
||||
product_warehouse_id: number;
|
||||
|
||||
Reference in New Issue
Block a user