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