diff --git a/src/components/BreathPage/index.tsx b/src/components/BreathPage/index.tsx index 776d756..afd9cda 100644 --- a/src/components/BreathPage/index.tsx +++ b/src/components/BreathPage/index.tsx @@ -40,7 +40,7 @@ function BreathPage({ leoApng }: BreathPageProps): JSX.Element { const navigateTimeOut = setTimeout(() => { navigate(routes.client.breathResult()); - }, 60_000); + }, 50_000); return () => { clearTimeout(navigateTimeOut); @@ -106,26 +106,7 @@ function BreathPage({ leoApng }: BreathPageProps): JSX.Element { useApiCall(createCallback); const handleCross = () => { - if (homeConfig.pathFromHome === EPathsFromHome.compatibility) { - dispatch( - actions.siteConfig.update({ - home: { - pathFromHome: EPathsFromHome.compatibility, - isShowNavbar: true, - }, - }) - ); - return navigate(routes.client.home()); - } - if (homeConfig.pathFromHome === EPathsFromHome.breath) { - dispatch( - actions.siteConfig.update({ - home: { pathFromHome: EPathsFromHome.breath, isShowNavbar: false }, - }) - ); - return navigate(routes.client.compatibility()); - } - return navigate(routes.client.home()); + navigate(routes.client.breathResult()); }; return ( diff --git a/src/components/Compatibility/index.tsx b/src/components/Compatibility/index.tsx index 1fb90fa..702ef60 100644 --- a/src/components/Compatibility/index.tsx +++ b/src/components/Compatibility/index.tsx @@ -26,24 +26,29 @@ function CompatibilityPage(): JSX.Element { const { t, i18n } = useTranslation(); const navigate = useNavigate(); const dispatch = useDispatch(); - const [isDisabled, setIsDisabled] = useState(true); - const [isDisabledName, setIsDisabledName] = useState(true); - const [isDisabledDate, setIsDisabledDate] = useState(true); - const [isChangeDate, setIsChangeDate] = useState(false); - const [currentOnboarding, setCurrentOnboarding] = useState(0); - const [name, setName] = useState(""); - const [selectedDate, setSelectedDate] = useState(""); - const [compatCategory, setCompatCategory] = useState(1); const homeConfig = useSelector(selectors.selectHome); const showNavbarFooter = homeConfig.isShowNavbar; const birthdate = useSelector(selectors.selectBirthdate); const onboardingCompatibility = useSelector( selectors.selectOnboardingCompatibility ); + + const [isDisabled, setIsDisabled] = useState(true); + const [isDisabledName, setIsDisabledName] = useState(true); + const [isDisabledSelfName, setIsDisabledSelfName] = useState(true); + isDisabledSelfName; + const [isDisabledDate, setIsDisabledDate] = useState(true); + const [isChangeDate, setIsChangeDate] = useState(false); + const [currentOnboarding, setCurrentOnboarding] = useState(0); + const [name, setName] = useState(""); + const [selfName, setSelfName] = useState(""); + const [selectedDate, setSelectedDate] = useState(""); + const [compatCategory, setCompatCategory] = useState(1); const zodiacSign = getZodiacSignByDate(birthdate); const [asset, setAsset] = useState(); const api = useApi(); - const inputRef = useRef(null); + const inputSelfNameRef = useRef(null); + const inputNameRef = useRef(null); const dateRef = useRef(null); const categoriesRef = useRef(null); const mainButtonRef = useRef(null); @@ -123,6 +128,14 @@ function CompatibilityPage(): JSX.Element { }, [api, locale]); const { data } = useApiCall(loadData); + const handleValidSelfName = (name: string) => { + console.log(name); + + setIsDisabledSelfName(!name.length); + setSelfName(name); + checkAllDisabled(); + }; + const handleValidName = (name: string) => { setIsDisabledName(!name.length); setName(name); @@ -137,6 +150,7 @@ function CompatibilityPage(): JSX.Element { }; const checkAllDisabled = () => { + // isDisabledSelfName setIsDisabled(isDisabledName || isDisabledDate); }; @@ -144,10 +158,9 @@ function CompatibilityPage(): JSX.Element { setCompatCategory(parseInt(event.target.value)); }; - const handleNameOnboarding = () => { - if (!name.length) return; - setCurrentOnboarding(1); - dateRef.current?.scrollIntoView({ behavior: "smooth" }); + const scrollToElementOnboarding = (nextOnboarding: number, ref: HTMLElement | null) => { + setCurrentOnboarding(nextOnboarding); + ref?.scrollIntoView({ behavior: "smooth" }); }; return ( @@ -166,33 +179,81 @@ function CompatibilityPage(): JSX.Element { {t("compatibility")} */}
- - {t("iAm")} - + {onboardingCompatibility && ( + + {t("iAm")} + + )} + {!onboardingCompatibility && ( +
+ { + if (!selfName.length) return; + if (e.key === "Enter") { + (e.target as HTMLInputElement).blur(); + } + }} + onValid={handleValidSelfName} + onInvalid={() => setIsDisabledSelfName(true)} + onBlur={() => { + if (!selfName.length) return; + setCurrentOnboarding(1); + inputNameRef.current?.scrollIntoView({ behavior: "smooth" }); + }} + /> +
+ )} +
- {!onboardingCompatibility?.isShown && ( + {!onboardingCompatibility && ( <> {currentOnboarding === 0 && ( + { + if (!selfName.length) return; + scrollToElementOnboarding(1, inputNameRef.current); + }} + /> + + )} + {currentOnboarding === 1 && ( + { + if (!name.length) return; + scrollToElementOnboarding(2, dateRef.current); + }} /> )} - {currentOnboarding === 1 && ( + {currentOnboarding === 2 && ( @@ -200,7 +261,7 @@ function CompatibilityPage(): JSX.Element { @@ -212,10 +273,10 @@ function CompatibilityPage(): JSX.Element { )} - {currentOnboarding === 3 && ( + {currentOnboarding === 4 && ( @@ -230,13 +291,13 @@ function CompatibilityPage(): JSX.Element { )}
{ if (!name.length) return; if (e.key === "Enter") { @@ -247,23 +308,23 @@ function CompatibilityPage(): JSX.Element { onInvalid={() => setIsDisabledName(true)} onBlur={() => { if (!name.length) return; - setCurrentOnboarding(1); + setCurrentOnboarding(2); dateRef.current?.scrollIntoView({ behavior: "smooth" }); }} />
- {currentOnboarding === 2 && !onboardingCompatibility?.isShown && ( + {currentOnboarding === 3 && !onboardingCompatibility && ( @@ -271,21 +332,21 @@ function CompatibilityPage(): JSX.Element { text={t("au.web_onbording.category")} direction={EDirectionOnboarding.TOP} showCross={true} - crossClickHandler={() => setCurrentOnboarding(3)} + crossClickHandler={() => setCurrentOnboarding(4)} /> )} {data && data.length && (
{data.map((item, index) => (
setCurrentOnboarding(3)} + onClick={() => setCurrentOnboarding(4)} > diff --git a/src/components/CreateProfilePage/ProcessFlow.tsx b/src/components/CreateProfilePage/ProcessFlow.tsx index fcb5070..41f0e4a 100644 --- a/src/components/CreateProfilePage/ProcessFlow.tsx +++ b/src/components/CreateProfilePage/ProcessFlow.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import ProcessItem from "./ProcessItem" import styles from './styles.module.css' @@ -32,15 +32,28 @@ const getMultiplier = (currentIdx: number, length: number): number => { return Math.max(length - (currentIdx + 1) - 1, 0) } -const calculateTop = (currentIdx: number, length: number): number => { - const itemHeight = 63 - return getMultiplier(currentIdx, length) * itemHeight +const calculateTop = (currentIdx: number, length: number, items: HTMLDivElement[]): number => { + + return items.slice(currentIdx + 2).reduce((accumulator, item) => { + if (!item) return accumulator; + return accumulator + item.clientHeight + }, 1) + 8 * getMultiplier(currentIdx, length) + + // const itemHeight = 63 + // return getMultiplier(currentIdx, length) * itemHeight1?.clientHeight } function ProcessFlow({ items, onDone }: ProcessFlowProps): JSX.Element { const [status, setStatus] = useState(ProcessStatus.Idle) const [doneTaskIdx, setDoneTaskIdx] = useState(-1) + const itemsRef = useRef([] as HTMLDivElement[]); const tasks = items.map(({ task }) => task) + const [rerender, setRerender] = useState(false); + rerender + + useEffect(() => { + setRerender((prev) => !prev); + }, [itemsRef]) useEffect(() => { if (status !== ProcessStatus.Idle) return @@ -54,8 +67,9 @@ function ProcessFlow({ items, onDone }: ProcessFlowProps): JSX.Element { return (itemsRef.current[idx] = el as HTMLDivElement)} /> } return ( diff --git a/src/components/CreateProfilePage/ProcessItem.tsx b/src/components/CreateProfilePage/ProcessItem.tsx index 24d0b0f..2297e08 100644 --- a/src/components/CreateProfilePage/ProcessItem.tsx +++ b/src/components/CreateProfilePage/ProcessItem.tsx @@ -1,3 +1,4 @@ +import { LegacyRef } from "react" import Loader, { LoaderColor } from "../Loader" import styles from "./styles.module.css" @@ -5,12 +6,13 @@ type ProcessItemProps = { top: number label: string isDone: boolean + refItem: LegacyRef } -function ProcessItem({ top, label, isDone }: ProcessItemProps): JSX.Element { +function ProcessItem({ top, label, isDone, refItem }: ProcessItemProps): JSX.Element { return ( -
+
{ isDone diff --git a/src/components/CreateProfilePage/styles.module.css b/src/components/CreateProfilePage/styles.module.css index ace19e9..8a8cb63 100644 --- a/src/components/CreateProfilePage/styles.module.css +++ b/src/components/CreateProfilePage/styles.module.css @@ -43,9 +43,9 @@ .process-item { display: flex; - font-size: 24px; + font-size: 20px; font-weight: 400; - margin-bottom: 24px; + margin-bottom: 8px; line-height: 32px; position: relative; transition: top 0.4s ease-in-out; diff --git a/src/components/HomePage/index.tsx b/src/components/HomePage/index.tsx index 63ee031..6faf788 100644 --- a/src/components/HomePage/index.tsx +++ b/src/components/HomePage/index.tsx @@ -202,7 +202,8 @@ function HomePage(): JSX.Element { variant="h3" className={styles["content__daily-forecast-title"]} > - {forecast.category} + {/* {forecast.category} */} + {t("aura.personal_aura.button")}

{forecast.body} diff --git a/src/store/compatibility.ts b/src/store/compatibility.ts index 7774ea9..10fa6ad 100644 --- a/src/store/compatibility.ts +++ b/src/store/compatibility.ts @@ -5,6 +5,7 @@ import type { PayloadAction } from "@reduxjs/toolkit"; interface ICompatibility { rightUser: IUser; categoryId: number; + selfName: string; } interface IUser { @@ -18,6 +19,7 @@ const initialState: ICompatibility = { birthDate: "", }, categoryId: 1, + selfName: "I am", }; const compatibilitySlice = createSlice({ @@ -25,7 +27,7 @@ const compatibilitySlice = createSlice({ initialState, reducers: { update(state, action: PayloadAction>) { - return { ...state, ...action.payload }; + return { ...initialState, ...state, ...action.payload }; }, }, extraReducers: (builder) => builder.addCase("reset", () => initialState), @@ -40,4 +42,8 @@ export const selectCategoryId = createSelector( (state: { compatibility: ICompatibility }) => state.compatibility.categoryId, (compatibility) => compatibility ); +export const selectSelfName = createSelector( + (state: { compatibility: ICompatibility }) => state.compatibility.selfName, + (compatibility) => compatibility +); export default compatibilitySlice.reducer; diff --git a/src/store/index.ts b/src/store/index.ts index 84c890a..b7df392 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -32,7 +32,7 @@ import subscriptionPlans, { } from "./subscriptionPlan"; import status, { actions as userStatusActions, selectStatus } from "./status"; import compatibility, { - actions as compatibilityActions, + actions as compatibilityActions, selectSelfName, } from "./compatibility"; import userCallbacks, { actions as userCallbacksActions, @@ -68,6 +68,7 @@ export const selectors = { selectPlanById, selectAuraCoordinates, selectRightUser, + selectSelfName, selectCategoryId, selectSelectedPrice, selectUserCallbacksDescription,