Fix: issue 2 modal closing if theres an error
This commit is contained in:
@@ -46,6 +46,8 @@ export default function AddCardMethodModal({
|
||||
setError(
|
||||
r.error?.message ? r.error?.message : r?.trace?.raw?.message
|
||||
);
|
||||
setLoading(false);
|
||||
return;
|
||||
} else {
|
||||
await sdk.createCustomerStripeCard(
|
||||
{ sourceToken: r ? r.token.id : result.token.id },
|
||||
@@ -74,7 +76,11 @@ export default function AddCardMethodModal({
|
||||
|
||||
return (
|
||||
<Transition appear show={modalOpen} as={Fragment}>
|
||||
<Dialog as='div' className='relative z-50' onClose={closeModal}>
|
||||
<Dialog
|
||||
as='div'
|
||||
className='relative z-50'
|
||||
onClose={error ? () => {} : closeModal}
|
||||
>
|
||||
<Transition.Child
|
||||
as={Fragment}
|
||||
enter='ease-out duration-300'
|
||||
@@ -136,7 +142,10 @@ export default function AddCardMethodModal({
|
||||
<button
|
||||
type='button'
|
||||
className='rounded bg-gray-200 px-4 py-2 text-gray-700 hover:bg-gray-300'
|
||||
onClick={closeModal}
|
||||
onClick={() => {
|
||||
setError("");
|
||||
closeModal();
|
||||
}}
|
||||
disabled={loading}
|
||||
>
|
||||
Cancel
|
||||
|
||||
Reference in New Issue
Block a user