Skip to content

Commit

Permalink
ASUB-7844 Bug fix (#1836)
Browse files Browse the repository at this point in the history
fix issue with redirect when user is not logged in and adjust setTimeout delay
  • Loading branch information
edwardcho1231 authored Dec 7, 2023
1 parent b21fc0b commit c5e8bf7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion blocks/subscriptions-block/components/usePaywall.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const usePaywall = () => {
isIdentityInitialized &&
!isPaywalled
) {
setTimeout(() => runPaywall(), 1000);
setTimeout(() => runPaywall(), 0);
}
}, [
apiOrigin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const PaymentInfo = ({
isInitialized,
successUpdateURL,
isPaymentMethodUpdate = false,
loginURL
}) => {

const { Sales } = useSales();
Expand Down Expand Up @@ -101,7 +102,7 @@ const PaymentInfo = ({

const handlePayPal = async () => {
const isLoggedIn = await Identity.isLoggedIn();

const checkoutURL = window.location.pathname;
if (!isLoggedIn) {
window.location.href = `${loginURL}?redirect=${checkoutURL}`;
}
Expand Down
8 changes: 7 additions & 1 deletion blocks/subscriptions-block/features/checkout/default.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const LABEL_ORDER_NUMBER_PAYPAL = "ArcSubs_OrderNumber"
const BLOCK_CLASS_NAME = "b-checkout";

const Checkout = ({ customFields }) => {
const { offerURL, successURL, stripeIntentsID } = customFields;
const { offerURL, successURL, loginURL, stripeIntentsID } = customFields;

const [loggedIn, setIsLoggedIn] = useState(false);
const [user, setUser] = useState(false);
Expand Down Expand Up @@ -102,15 +102,21 @@ const Checkout = ({ customFields }) => {
offerURL={offerURL}
stripeIntentsID={stripeIntentsID}
isInitialized = {isInitialized}
loginURL = {loginURL}
/>
)}
</section>
);
};
Checkout.propTypes = {
customFields: PropTypes.shape({
loginURL: PropTypes.string.tag({
defaultValue: "/account/login/",
label: "Login URL",
}),
offerURL: PropTypes.string.tag({
defaultValue: "/offer/",
label: "Offer URL",
}),
successURL: PropTypes.string.tag({
defaultValue: "/",
Expand Down

0 comments on commit c5e8bf7

Please sign in to comment.