Skip to content

Commit

Permalink
Use separate isSubmitting flag
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNeshi committed Jan 15, 2024
1 parent 3c11011 commit 82c2b88
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function Checkout({ onBack }: { onBack: () => void }) {
const { handleError } = useErrorContext();

const [isLoading, setLoading] = useState(true);
const [isSubmitting, setSubmitting] = useState(true);

const handleSubmit: FormEventHandler<HTMLFormElement> = async (e) => {
e.preventDefault();
Expand All @@ -27,7 +28,7 @@ export default function Checkout({ onBack }: { onBack: () => void }) {
return;
}

setLoading(true);
setSubmitting(true);

const { error } = await stripe.confirmPayment({
elements,
Expand All @@ -47,7 +48,7 @@ export default function Checkout({ onBack }: { onBack: () => void }) {
handleError("An unexpected error occurred.");
}

setLoading(false);
setSubmitting(false);
};

return (
Expand Down Expand Up @@ -82,7 +83,7 @@ export default function Checkout({ onBack }: { onBack: () => void }) {
disabled={!stripe || !elements}
type="submit"
>
<LoadText text="Processing..." isLoading={isLoading}>
<LoadText text="Processing..." isLoading={isSubmitting}>
Pay Now
</LoadText>
</button>
Expand Down

0 comments on commit 82c2b88

Please sign in to comment.