diff --git a/src/components/PalmistryV1/components/PalmsSayAbout/index.tsx b/src/components/PalmistryV1/components/PalmsSayAbout/index.tsx index 0ac0282..09cd582 100644 --- a/src/components/PalmistryV1/components/PalmsSayAbout/index.tsx +++ b/src/components/PalmistryV1/components/PalmsSayAbout/index.tsx @@ -1,12 +1,69 @@ import Title from "@/components/Title"; import styles from "./styles.module.scss"; -import { palmistryV1Prefix } from "@/routes"; import PointRing from "./PointRing"; import { ELocalesPlacement } from "@/locales"; import { useTranslations } from "@/hooks/translations"; +import PhotoReady from "../PhotoReady"; +import { useSelector } from "react-redux"; +import { selectors } from "@/store"; +import { useMemo } from "react"; +import { palmistryV1Prefix } from "@/routes"; +import { IPalmistryLine } from "@/api/resources/Palmistry"; +import { IPalmistryFingerLocal } from "@/store/palmistry"; +import { useMetricABFlags } from "@/services/metric/metricService"; function PalmsSayAbout() { const { translate } = useTranslations(ELocalesPlacement.PalmistryV1); + const lines = useSelector(selectors.selectPalmistryLines); + const fingers = useSelector(selectors.selectPalmistryFingers); + + const { flags } = useMetricABFlags(); + const isReal = flags?.palmOnPayment?.[0] === "real"; + + const filterByName = ( + array: Array, + name: string + ) => { + return array.filter((value: IPalmistryLine | IPalmistryFingerLocal) => value.name === name); + }; + + const love = useMemo(() => { + return { + lines: filterByName(lines, "heart") as IPalmistryLine[], + fingers: filterByName(fingers, "thumb") as IPalmistryFingerLocal[], + }; + }, [fingers, lines]); + + const head = useMemo(() => { + return { + lines: filterByName(lines, "head") as IPalmistryLine[], + fingers: filterByName(fingers, "index_finger") as IPalmistryFingerLocal[], + }; + }, [fingers, lines]); + + const life = useMemo(() => { + return { + lines: filterByName(lines, "life") as IPalmistryLine[], + fingers: filterByName( + fingers, + "middle_finger" + ) as IPalmistryFingerLocal[], + }; + }, [fingers, lines]); + + const fate = useMemo(() => { + return { + lines: filterByName(lines, "fate") as IPalmistryLine[], + fingers: filterByName(fingers, "ring_finger") as IPalmistryFingerLocal[], + }; + }, [fingers, lines]); + + const pinky = useMemo(() => { + return { + lines: [], + fingers: filterByName(fingers, "pinky") as IPalmistryFingerLocal[], + }; + }, [fingers]); return (
@@ -15,10 +72,19 @@ function PalmsSayAbout() {
- Hand with love line + {!!love.lines.length && !!love.fingers.length && isReal && ( + + )} + {(!love.lines.length || !love.fingers.length || !isReal) && ( + Hand with love line + )}
@@ -41,10 +107,19 @@ function PalmsSayAbout() {
- Hand with head line + {!!head.lines.length && !!head.fingers.length && isReal && ( + + )} + {(!head.lines.length || !head.fingers.length || !isReal) && ( + Hand with head line + )}
@@ -67,10 +142,19 @@ function PalmsSayAbout() {
- Hand with life line + {!!life.lines.length && !!life.fingers.length && isReal && ( + + )} + {(!life.lines.length || !life.fingers.length || !isReal) && ( + Hand with life line + )}
@@ -93,10 +177,19 @@ function PalmsSayAbout() {
- Hand with fate line + {!!fate.lines.length && !!fate.fingers.length && isReal && ( + + )} + {(!fate.lines.length || !fate.fingers.length || !isReal) && ( + Hand with fate line + )}
@@ -119,10 +212,19 @@ function PalmsSayAbout() {
- Hand with little finger + {!!pinky.fingers.length && isReal && ( + + )} + {(!pinky.fingers.length || !isReal) && ( + Hand with little finger + )}
diff --git a/src/components/PalmistryV1/components/PalmsSayAbout/styles.module.scss b/src/components/PalmistryV1/components/PalmsSayAbout/styles.module.scss index 17e2ffa..27e1599 100644 --- a/src/components/PalmistryV1/components/PalmsSayAbout/styles.module.scss +++ b/src/components/PalmistryV1/components/PalmsSayAbout/styles.module.scss @@ -52,3 +52,7 @@ } } } + +.photo-ready { + max-width: 90px; +} diff --git a/src/components/PalmistryV1/components/PhotoReady/index.tsx b/src/components/PalmistryV1/components/PhotoReady/index.tsx new file mode 100644 index 0000000..d82ce00 --- /dev/null +++ b/src/components/PalmistryV1/components/PhotoReady/index.tsx @@ -0,0 +1,105 @@ +import { useCallback, useEffect, useRef, useState } from "react"; +import styles from "./styles.module.scss"; +import { useSelector } from "react-redux"; +import { selectors } from "@/store"; +import { IPalmistryLine, IPalmistryPoint } from "@/api/resources/Palmistry"; +import { IPalmistryFingerLocal } from "@/store/palmistry"; + +interface IPhotoReadyProps { + className?: string; + lines: IPalmistryLine[]; + fingers: IPalmistryFingerLocal[]; +} + +function PhotoReady({ className = "", lines, fingers }: IPhotoReadyProps) { + const photo = useSelector(selectors.selectPalmistryPhoto); + + const imageRef = useRef(null); + const [isImageLoaded, setIsImageLoaded] = useState(false); + const [imageWidth, setImageWidth] = useState(0); + const [imageHeight, setImageHeight] = useState(0); + const linesRef = useRef([]); + + useEffect(() => { + if (isImageLoaded && imageRef.current) { + setImageWidth(imageRef.current.width || 0); + setImageHeight(imageRef.current.height || 0); + } + }, [isImageLoaded]); + + const getCoordinatesString = useCallback( + (points: IPalmistryPoint[]) => { + const coordinatesString = `M ${points[0]?.x * imageWidth} ${ + points[0]?.y * imageHeight + }`; + return points.reduce( + (acc, point) => + `${acc} L ${point?.x * imageWidth} ${point?.y * imageHeight}`, + coordinatesString + ); + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [lines, isImageLoaded, imageWidth, imageHeight] + ); + + return ( +
+ PalmIcon setIsImageLoaded(true)} + /> + {!!imageHeight && !!imageWidth && ( + + {!!fingers.length && + fingers?.map((finger, index) => { + return ( + + {/* */} + + + ); + })} + + <> + {lines.map((line, index) => ( + (linesRef.current[index] = el as SVGPathElement)} + /> + ))} + + + )} +
+ ); +} + +export default PhotoReady; diff --git a/src/components/PalmistryV1/components/PhotoReady/styles.module.scss b/src/components/PalmistryV1/components/PhotoReady/styles.module.scss new file mode 100644 index 0000000..9f5ba6b --- /dev/null +++ b/src/components/PalmistryV1/components/PhotoReady/styles.module.scss @@ -0,0 +1,43 @@ +.container { + position: relative; +} + +.svg-objects { + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; +} + +.line { + stroke-linecap: round; + stroke-linejoin: round; + stroke-width: 2px; + fill-rule: evenodd; + clip-rule: evenodd; + stroke-miterlimit: 1.5; + stroke-dasharray: 500; + stroke: #fff; + fill: none; + stroke-dashoffset: 0; +} + +.line-heart { + stroke: #f8d90f; + /* animation-delay: 4.5s; */ +} + +.line-life { + stroke: #e51c39; +} + +.line-head { + stroke: #00d114; + /* animation-delay: 1.5s; */ +} + +.line-fate { + stroke: #05ced8; + /* animation-delay: 3s; */ +} diff --git a/src/components/PalmistryV1/pages/TrialChoice/index.tsx b/src/components/PalmistryV1/pages/TrialChoice/index.tsx index d3770a8..cd1527c 100644 --- a/src/components/PalmistryV1/pages/TrialChoice/index.tsx +++ b/src/components/PalmistryV1/pages/TrialChoice/index.tsx @@ -2,7 +2,7 @@ import { useDispatch, useSelector } from "react-redux"; import EmailSubstrate from "../../components/EmailSubstrate"; import styles from "./styles.module.scss"; import { actions, selectors } from "@/store"; -import Title from "@/components/Title"; +// import Title from "@/components/Title"; import PriceList from "@/components/pages/ABDesign/v1/components/PriceList"; import { usePaywall } from "@/hooks/paywall/usePaywall"; import { EPlacementKeys } from "@/api/resources/Paywall"; @@ -17,7 +17,7 @@ import routes from "@/routes"; import { useNavigate } from "react-router-dom"; import Loader from "@/components/Loader"; import { useTranslations } from "@/hooks/translations"; -import { useMetricABFlags } from "@/services/metric/metricService"; +// import { useMetricABFlags } from "@/services/metric/metricService"; import { getLongText } from "./abText"; function TrialChoice() { @@ -31,8 +31,8 @@ function TrialChoice() { const locale = getDefaultLocaleByLanguage(language); - const { flags } = useMetricABFlags(); - const isLongText = flags?.text?.[0] === "on"; + // const { flags } = useMetricABFlags(); + // const isLongText = flags?.text?.[0] === "on"; const [isDisabled, setIsDisabled] = useState(true); @@ -61,12 +61,12 @@ function TrialChoice() { {!isLoading && ( <> - {!isLongText && ( + {/* {!isLongText && ( {getText("text.0")} - )} - {isLongText &&

{getLongText(locale)}

} + )} */} +

{getLongText(locale)}

{