Skip to content

Commit

Permalink
fix(payment): clear the order after closing the checkout modal
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristiaanScheermeijer committed Jun 1, 2022
1 parent 6e2671a commit 3f590d7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/containers/AccountModal/forms/Checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ const Checkout = () => {
const [couponCodeApplied, setCouponCodeApplied] = useState(false);
const [paymentMethodId, setPaymentMethodId] = useState<number | undefined>(undefined);

const { order, offer, paymentMethods } = useCheckoutStore(({ order, offer, paymentMethods }) => ({ order, offer, paymentMethods }), shallow);
const { order, offer, paymentMethods, setOrder } = useCheckoutStore(
({ order, offer, paymentMethods, setOrder }) => ({
order,
offer,
paymentMethods,
setOrder,
}),
shallow,
);
const offerType = offer && !isSVODOffer(offer) ? 'tvod' : 'svod';

const paymentSuccessUrl = useMemo(() => {
Expand Down Expand Up @@ -79,6 +87,11 @@ const Checkout = () => {
create();
}, [history, offer]);

// clear the order after closing the checkout modal
useEffect(() => {
return () => setOrder(null);
}, [setOrder]);

const backButtonClickHandler = () => {
history.push(addQueryParam(history, 'u', 'choose-offer'));
};
Expand Down

0 comments on commit 3f590d7

Please sign in to comment.