Merge branch 'AW-102-trial-choice-palmistry' into 'develop'
AW-102-trial-choice-palmistry See merge request witapp/aura-webapp!166
This commit is contained in:
commit
98e1b9a534
@ -20,15 +20,33 @@ export default function StepSubscriptionPlan() {
|
|||||||
const steps = useSteps();
|
const steps = useSteps();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const activeProductFromStore = useSelector(selectors.selectActiveProduct);
|
const activeProductFromStore = useSelector(selectors.selectActiveProduct);
|
||||||
const { products } = usePaywall({
|
const { products, properties } = usePaywall({
|
||||||
placementKey: EPlacementKeys["aura.placement.palmistry.main"],
|
placementKey: EPlacementKeys["aura.placement.palmistry.main"],
|
||||||
});
|
});
|
||||||
|
const defaultProduct = properties.find(
|
||||||
|
(property) => property.key === "default.product"
|
||||||
|
)?._id;
|
||||||
|
|
||||||
const storedEmail = steps.getStoredValue(Step.Email);
|
const storedEmail = steps.getStoredValue(Step.Email);
|
||||||
|
|
||||||
const [product, setProduct] = React.useState("");
|
const [product, setProduct] = React.useState("");
|
||||||
|
|
||||||
const [email, setEmail] = React.useState(steps.getStoredValue(Step.Email));
|
const [email, setEmail] = React.useState(steps.getStoredValue(Step.Email));
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (!defaultProduct) return;
|
||||||
|
const targetDefaultProduct = products.find((p) => p._id === defaultProduct);
|
||||||
|
if (!targetDefaultProduct) return;
|
||||||
|
|
||||||
|
setProduct(defaultProduct);
|
||||||
|
steps.saveCurrent(defaultProduct);
|
||||||
|
dispatch(
|
||||||
|
actions.payment.update({
|
||||||
|
activeProduct: targetDefaultProduct,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}, [defaultProduct, dispatch, products, steps]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (activeProductFromStore) {
|
if (activeProductFromStore) {
|
||||||
setProduct(activeProductFromStore._id);
|
setProduct(activeProductFromStore._id);
|
||||||
@ -40,6 +58,7 @@ export default function StepSubscriptionPlan() {
|
|||||||
}, [storedEmail]);
|
}, [storedEmail]);
|
||||||
|
|
||||||
const onNext = () => {
|
const onNext = () => {
|
||||||
|
if (!product) return;
|
||||||
const targetProduct = products.find((_product) => _product._id === product);
|
const targetProduct = products.find((_product) => _product._id === product);
|
||||||
|
|
||||||
if (targetProduct) {
|
if (targetProduct) {
|
||||||
@ -134,6 +153,7 @@ export default function StepSubscriptionPlan() {
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={onNext}
|
onClick={onNext}
|
||||||
active
|
active
|
||||||
|
disabled={!product}
|
||||||
>
|
>
|
||||||
Continue
|
Continue
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user