From 306204f126f9a93c013827d9ac4c1f0361ea701b Mon Sep 17 00:00:00 2001 From: Daniil Chemerkin Date: Thu, 6 Jun 2024 23:15:42 +0000 Subject: [PATCH] Develop --- .../step-subscription-plan.tsx | 23 ++++++++++++++++++- .../palmistry/step-upload/step-upload.tsx | 5 ++-- 2 files changed, 25 insertions(+), 3 deletions(-) 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 3620bc7..35cd301 100644 --- a/src/components/palmistry/step-subscription-plan/step-subscription-plan.tsx +++ b/src/components/palmistry/step-subscription-plan/step-subscription-plan.tsx @@ -20,15 +20,34 @@ export default function StepSubscriptionPlan() { const steps = useSteps(); const dispatch = useDispatch(); const activeProductFromStore = useSelector(selectors.selectActiveProduct); - const { products } = usePaywall({ + const { products, properties } = usePaywall({ placementKey: EPlacementKeys["aura.placement.palmistry.main"], }); + const defaultProduct = properties.find( + (property) => property.key === "default.product" + )?.value; const storedEmail = steps.getStoredValue(Step.Email); const [product, setProduct] = React.useState(""); + const [email, setEmail] = React.useState(steps.getStoredValue(Step.Email)); + React.useEffect(() => { + if (!defaultProduct || activeProductFromStore) return; + const targetDefaultProduct = products.find((p) => p.key === defaultProduct); + if (!targetDefaultProduct) return; + + setProduct(targetDefaultProduct._id); + steps.saveCurrent(targetDefaultProduct._id); + dispatch( + actions.payment.update({ + activeProduct: targetDefaultProduct, + }) + ); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [defaultProduct]); + React.useEffect(() => { if (activeProductFromStore) { setProduct(activeProductFromStore._id); @@ -40,6 +59,7 @@ export default function StepSubscriptionPlan() { }, [storedEmail]); const onNext = () => { + if (!product) return; const targetProduct = products.find((_product) => _product._id === product); if (targetProduct) { @@ -134,6 +154,7 @@ export default function StepSubscriptionPlan() { type="button" onClick={onNext} active + disabled={!product} > Continue diff --git a/src/components/palmistry/step-upload/step-upload.tsx b/src/components/palmistry/step-upload/step-upload.tsx index 9331c53..ef35aad 100644 --- a/src/components/palmistry/step-upload/step-upload.tsx +++ b/src/components/palmistry/step-upload/step-upload.tsx @@ -78,11 +78,12 @@ export default function StepUpload(props: Props) { }; const onTakePhoto = async (photo: string) => { + setUploadMenuModalIsOpen(false); + setPalmCameraModalIsOpen(false); + setIsUpladProcessing(true); const file = DataURIToBlob(photo); await getLines(file); setPalmPhoto(photo as string); - setUploadMenuModalIsOpen(false); - setPalmCameraModalIsOpen(false); }; useEffect(() => {