Skip to content

Commit

Permalink
[feat] add validation (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
TkymHrt committed Nov 11, 2023
1 parent c372a96 commit 03552fc
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ export default function AddModal(props: ModalProps) {
await del(deletePurchaseOrderUrl);
};

const [itemName, setItemName] = useState('');
const handler =
(stepNumber: number, input: string) =>
(e: React.ChangeEvent<HTMLSelectElement> | React.ChangeEvent<HTMLInputElement>) => {
props.setFormDataList(
props.formDataList.map((formData: PurchaseItem) =>
formData.id === stepNumber ? { ...formData, [input]: e.target.value } : formData,
),
);
};
(stepNumber: number, input: string) =>
(e: React.ChangeEvent<HTMLSelectElement> | React.ChangeEvent<HTMLInputElement>) => {
props.setFormDataList(
props.formDataList.map((formData: PurchaseItem) =>
formData.id === stepNumber ? { ...formData, [input]: e.target.value } : formData,
),
);
if (input === 'item') {
setItemName(e.target.value);
}
};

const addPurchaseItem = async (data: PurchaseItem[]) => {
const addPurchaseItemUrl = process.env.CSR_API_URI + '/purchaseitems';
Expand Down Expand Up @@ -304,6 +308,7 @@ export default function AddModal(props: ModalProps) {
activeStep === steps.length ? setIsDone(true) : nextStep();
}
}}
disabled={itemName.trim() === ''}
>
<div className={clsx('flex')}>
{activeStep === steps.length ? '申請の確認' : '次へ'}
Expand Down

0 comments on commit 03552fc

Please sign in to comment.