merge-checkout-modal-can-be-submitted-if-its-invalid #8

Merged
0Ry5 merged 1 commit from checkout-modal-can-be-submitted-if-its-invalid into main 2024-09-13 19:46:42 +02:00
Showing only changes of commit 6940fab53a - Show all commits

View file

@ -30,6 +30,9 @@ export const CheckoutBookModal = ({
const onSubmit = useCallback(
async (data: Partial<BookCheckoutForm>) => {
if (!formState.isValid) {
return;
}
if (!data.checkoutBy) {
setError("checkoutBy", {
message: `please enter ${
@ -61,7 +64,7 @@ export const CheckoutBookModal = ({
setFailed(await res.text());
}
},
[uuid, onClose, setError, isChechout]
[formState.isValid, isChechout, uuid, setError, onClose]
);
return (
@ -116,6 +119,12 @@ export const CheckoutBookModal = ({
"'null' is not a valid nickname"
);
},
notUndefinedString: (value) => {
return (
value?.toLocaleLowerCase() !== "undefined" ||
"'undefined' is not a valid nickname"
);
},
},
})}
isInvalid={!!formState.errors.checkoutBy}
@ -184,6 +193,7 @@ export const CheckoutBookModal = ({
marginLeft: "auto",
marginRight: "10px",
}}
disabled={!formState.isValid}
onClick={() => onSubmit(values)}
>
{`${isChechout ? "Checkout" : "Return"} book`}