mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 21:41:57 +00:00
feat(FE-208): replace product name input with select dropdown for better usability
This commit is contained in:
@@ -8,6 +8,7 @@ import { useSearchParams } from 'next/navigation';
|
||||
import Button from '@/components/Button';
|
||||
import TextInput from '@/components/input/TextInput';
|
||||
import NumberInput from '@/components/input/NumberInput';
|
||||
import SelectInput, { OptionType } from '@/components/input/SelectInput';
|
||||
|
||||
import {
|
||||
PurchaseRequestStaffApprovalFormDefaultValues,
|
||||
@@ -237,6 +238,13 @@ const PurchaseOrderStaffApprovalForm = ({
|
||||
return Object.values(warehouseGroups);
|
||||
}, [purchaseItems]);
|
||||
|
||||
const productOptions = useMemo(() => {
|
||||
return purchaseItems.map((item) => ({
|
||||
value: item.product_id,
|
||||
label: item.product.name,
|
||||
}));
|
||||
}, [purchaseItems]);
|
||||
|
||||
useEffect(() => {
|
||||
if (purchaseItems.length > 0 && initialValues?.items) {
|
||||
const updatedItems = purchaseItems.map((purchaseItem, idx) => {
|
||||
@@ -357,16 +365,20 @@ const PurchaseOrderStaffApprovalForm = ({
|
||||
return (
|
||||
<tr key={`purchase-item-${purchaseItem.id}`}>
|
||||
<td>
|
||||
<TextInput
|
||||
name={`items.${purchaseItem.id}.product_name`}
|
||||
type='text'
|
||||
value={purchaseItem?.product?.name || ''}
|
||||
readOnly={true}
|
||||
<SelectInput
|
||||
key={`product-${purchaseItem.id}`}
|
||||
value={{
|
||||
value: purchaseItem?.product_id || 0,
|
||||
label:
|
||||
purchaseItem?.product?.name || '',
|
||||
}}
|
||||
options={productOptions}
|
||||
isClearable={false}
|
||||
isSearchable={false}
|
||||
className={{
|
||||
wrapper:
|
||||
'min-w-52 md:min-w-72 lg:min-w-80',
|
||||
}}
|
||||
disabled={true}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user