mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
feat(FE): adding stok information in form repeater SO and DO
This commit is contained in:
@@ -682,7 +682,7 @@ const MarketingTable = () => {
|
|||||||
<Modal
|
<Modal
|
||||||
ref={productsModal.ref}
|
ref={productsModal.ref}
|
||||||
className={{
|
className={{
|
||||||
modalBox: 'max-w-2/5 z-100',
|
modalBox: 'xs:max-w-2/5 z-100',
|
||||||
}}
|
}}
|
||||||
closeOnBackdrop
|
closeOnBackdrop
|
||||||
>
|
>
|
||||||
@@ -724,6 +724,7 @@ const MarketingTable = () => {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
className={{
|
className={{
|
||||||
|
containerClassName: 'p-6',
|
||||||
tableWrapperClassName: 'overflow-x-auto min-h-full!',
|
tableWrapperClassName: 'overflow-x-auto min-h-full!',
|
||||||
tableClassName: 'font-inter w-full table-auto min-h-full!',
|
tableClassName: 'font-inter w-full table-auto min-h-full!',
|
||||||
headerRowClassName: 'border-b border-b-gray-200',
|
headerRowClassName: 'border-b border-b-gray-200',
|
||||||
|
|||||||
+14
-3
@@ -15,6 +15,7 @@ import { BaseSalesOrder } from '@/types/api/marketing/marketing';
|
|||||||
import Badge from '@/components/Badge';
|
import Badge from '@/components/Badge';
|
||||||
import { SalesProductToFieldValues } from '@/components/pages/marketing/form/MarketingForm';
|
import { SalesProductToFieldValues } from '@/components/pages/marketing/form/MarketingForm';
|
||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
|
import { isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
|
||||||
const DeliveryOrderProductForm = ({
|
const DeliveryOrderProductForm = ({
|
||||||
formState,
|
formState,
|
||||||
@@ -208,7 +209,7 @@ const DeliveryOrderProductForm = ({
|
|||||||
...formik.values,
|
...formik.values,
|
||||||
marketing_product_id: undefined,
|
marketing_product_id: undefined,
|
||||||
marketing_product: null,
|
marketing_product: null,
|
||||||
qty: formik.values.qty || '',
|
qty: '',
|
||||||
unit_price: '',
|
unit_price: '',
|
||||||
total_price: '',
|
total_price: '',
|
||||||
avg_weight: '',
|
avg_weight: '',
|
||||||
@@ -222,7 +223,7 @@ const DeliveryOrderProductForm = ({
|
|||||||
...formik.values,
|
...formik.values,
|
||||||
marketing_product_id: selected.value as number,
|
marketing_product_id: selected.value as number,
|
||||||
marketing_product: SalesProductToFieldValues(so),
|
marketing_product: SalesProductToFieldValues(so),
|
||||||
qty: formik.values.qty || so.qty,
|
qty: so.qty,
|
||||||
unit_price: so.unit_price,
|
unit_price: so.unit_price,
|
||||||
total_price: so.total_price,
|
total_price: so.total_price,
|
||||||
avg_weight: so.avg_weight,
|
avg_weight: so.avg_weight,
|
||||||
@@ -298,8 +299,18 @@ const DeliveryOrderProductForm = ({
|
|||||||
isError={Boolean(formik.errors.qty)}
|
isError={Boolean(formik.errors.qty)}
|
||||||
errorMessage={formik.errors.qty}
|
errorMessage={formik.errors.qty}
|
||||||
placeholder='Masukan Kuantitas'
|
placeholder='Masukan Kuantitas'
|
||||||
|
bottomLabel={
|
||||||
|
formik.values.marketing_product_id
|
||||||
|
? 'Stok dijual: ' +
|
||||||
|
salesOrders?.find(
|
||||||
|
(item) => item.id === formik.values.marketing_product_id
|
||||||
|
)?.qty
|
||||||
|
: ''
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='divider my-6'></div>
|
||||||
|
<div className='grid sm:grid-cols-2 gap-4'>
|
||||||
<NumberInput
|
<NumberInput
|
||||||
required
|
required
|
||||||
label='Avg. Bobot (Kg)'
|
label='Avg. Bobot (Kg)'
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ import { ProductWarehouseApi } from '@/services/api/inventory';
|
|||||||
import NumberInput from '@/components/input/NumberInput';
|
import NumberInput from '@/components/input/NumberInput';
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
import { isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseSuccess } from '@/lib/api-helper';
|
||||||
import { formatVechicleNumber } from '@/lib/helper';
|
import {
|
||||||
|
formatCurrency,
|
||||||
|
formatNumber,
|
||||||
|
formatVechicleNumber,
|
||||||
|
} from '@/lib/helper';
|
||||||
import PatternInput from '@/components/input/PatternInput';
|
import PatternInput from '@/components/input/PatternInput';
|
||||||
import Alert from '@/components/Alert';
|
import Alert from '@/components/Alert';
|
||||||
|
|
||||||
@@ -34,6 +38,7 @@ const SalesOrderProductForm = ({
|
|||||||
const [formErrorMessage, setFormErrorMessage] = useState('');
|
const [formErrorMessage, setFormErrorMessage] = useState('');
|
||||||
const [currentInput, setCurrentInput] = useState<string>('');
|
const [currentInput, setCurrentInput] = useState<string>('');
|
||||||
|
|
||||||
|
// ============ Formik ============
|
||||||
const formik = useFormik<SalesOrderProductFormValues>({
|
const formik = useFormik<SalesOrderProductFormValues>({
|
||||||
enableReinitialize: true,
|
enableReinitialize: true,
|
||||||
initialValues: {
|
initialValues: {
|
||||||
@@ -58,6 +63,7 @@ const SalesOrderProductForm = ({
|
|||||||
isInitialValid: false,
|
isInitialValid: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ===== Options =====
|
||||||
const {
|
const {
|
||||||
options: kandangSourceOptions,
|
options: kandangSourceOptions,
|
||||||
isLoadingOptions: isLoadingKandangSourceOptions,
|
isLoadingOptions: isLoadingKandangSourceOptions,
|
||||||
@@ -86,12 +92,13 @@ const SalesOrderProductForm = ({
|
|||||||
);
|
);
|
||||||
}, [warehouseSourceOptions, exisitingValues]);
|
}, [warehouseSourceOptions, exisitingValues]);
|
||||||
|
|
||||||
|
// ===== Handler =====
|
||||||
const kandangChangeHandler = (val: OptionType | OptionType[] | null) => {
|
const kandangChangeHandler = (val: OptionType | OptionType[] | null) => {
|
||||||
formik.setFieldValue('kandang', val as OptionType);
|
formik.setFieldValue('kandang', val as OptionType);
|
||||||
formik.setFieldValue('kandang_id', (val as OptionType)?.value);
|
formik.setFieldValue('kandang_id', (val as OptionType)?.value);
|
||||||
formik.setFieldValue('product_warehouse_id', null);
|
formik.setFieldValue('product_warehouse_id', null);
|
||||||
formik.setFieldValue('product_warehouse', null);
|
formik.setFieldValue('product_warehouse', null);
|
||||||
formik.setFieldValue('qty', null);
|
formik.setFieldValue('qty', '');
|
||||||
};
|
};
|
||||||
|
|
||||||
const warehouseChangeHandler = (val: OptionType | OptionType[] | null) => {
|
const warehouseChangeHandler = (val: OptionType | OptionType[] | null) => {
|
||||||
@@ -106,7 +113,7 @@ const SalesOrderProductForm = ({
|
|||||||
formik.setFieldValue('qty', productWarehouse?.quantity);
|
formik.setFieldValue('qty', productWarehouse?.quantity);
|
||||||
handleBlurField('qty');
|
handleBlurField('qty');
|
||||||
} else {
|
} else {
|
||||||
formik.setFieldValue('qty', null);
|
formik.setFieldValue('qty', '');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -248,7 +255,24 @@ const SalesOrderProductForm = ({
|
|||||||
isError={formik.touched.qty && Boolean(formik.errors.qty)}
|
isError={formik.touched.qty && Boolean(formik.errors.qty)}
|
||||||
errorMessage={formik.errors.qty}
|
errorMessage={formik.errors.qty}
|
||||||
placeholder='Masukan Kuantitas'
|
placeholder='Masukan Kuantitas'
|
||||||
|
bottomLabel={
|
||||||
|
isResponseSuccess(warehouseSourceRawData) &&
|
||||||
|
formik.values.product_warehouse_id
|
||||||
|
? `Stok tersedia: ${formatNumber(
|
||||||
|
warehouseSourceRawData?.data?.find(
|
||||||
|
(item) => item.id === formik.values.product_warehouse_id
|
||||||
|
)?.quantity ?? 0
|
||||||
|
)} ${
|
||||||
|
warehouseSourceRawData?.data?.find(
|
||||||
|
(item) => item.id === formik.values.product_warehouse_id
|
||||||
|
)?.product?.uom?.name ?? ''
|
||||||
|
}`
|
||||||
|
: ''
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='divider my-6'></div>
|
||||||
|
<div className='grid sm:grid-cols-2 gap-4 z-200'>
|
||||||
<NumberInput
|
<NumberInput
|
||||||
required
|
required
|
||||||
label='Avg. Bobot (Kg)'
|
label='Avg. Bobot (Kg)'
|
||||||
|
|||||||
Reference in New Issue
Block a user