diff --git a/src/components/palmistry/step-subscription-plan/step-subscription-plan.tsx b/src/components/palmistry/step-subscription-plan/step-subscription-plan.tsx index e8b0e38..35cd301 100644 --- a/src/components/palmistry/step-subscription-plan/step-subscription-plan.tsx +++ b/src/components/palmistry/step-subscription-plan/step-subscription-plan.tsx @@ -25,7 +25,7 @@ export default function StepSubscriptionPlan() { }); const defaultProduct = properties.find( (property) => property.key === "default.product" - )?._id; + )?.value; const storedEmail = steps.getStoredValue(Step.Email); @@ -34,18 +34,19 @@ export default function StepSubscriptionPlan() { const [email, setEmail] = React.useState(steps.getStoredValue(Step.Email)); React.useEffect(() => { - if (!defaultProduct) return; - const targetDefaultProduct = products.find((p) => p._id === defaultProduct); + if (!defaultProduct || activeProductFromStore) return; + const targetDefaultProduct = products.find((p) => p.key === defaultProduct); if (!targetDefaultProduct) return; - setProduct(defaultProduct); - steps.saveCurrent(defaultProduct); + setProduct(targetDefaultProduct._id); + steps.saveCurrent(targetDefaultProduct._id); dispatch( actions.payment.update({ activeProduct: targetDefaultProduct, }) ); - }, [defaultProduct, dispatch, products, steps]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [defaultProduct]); React.useEffect(() => { if (activeProductFromStore) {