diff --git a/package-lock.json b/package-lock.json index bf65984..719dc8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ "@vitejs/plugin-react": "^4.0.0", "eslint": "^8.41.0", "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-react-refresh": "^0.4.1", + "eslint-plugin-react-refresh": "^0.4.3", "typescript": "^5.0.4", "vite": "^4.3.8" } @@ -1756,9 +1756,9 @@ } }, "node_modules/eslint-plugin-react-refresh": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.1.tgz", - "integrity": "sha512-QgrvtRJkmV+m4w953LS146+6RwEe5waouubFVNLBfOjXJf6MLczjymO8fOcKj9jMS8aKkTCMJqiPu2WEeFI99A==", + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.3.tgz", + "integrity": "sha512-Hh0wv8bUNY877+sI0BlCUlsS0TYYQqvzEwJsJJPM2WF4RnTStSnSR3zdJYa2nPOJgg3UghXi54lVyMSmpCalzA==", "dev": true, "peerDependencies": { "eslint": ">=7" @@ -4627,9 +4627,9 @@ "requires": {} }, "eslint-plugin-react-refresh": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.1.tgz", - "integrity": "sha512-QgrvtRJkmV+m4w953LS146+6RwEe5waouubFVNLBfOjXJf6MLczjymO8fOcKj9jMS8aKkTCMJqiPu2WEeFI99A==", + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.3.tgz", + "integrity": "sha512-Hh0wv8bUNY877+sI0BlCUlsS0TYYQqvzEwJsJJPM2WF4RnTStSnSR3zdJYa2nPOJgg3UghXi54lVyMSmpCalzA==", "dev": true, "requires": {} }, diff --git a/package.json b/package.json index a119672..b13ef08 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "@vitejs/plugin-react": "^4.0.0", "eslint": "^8.41.0", "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-react-refresh": "^0.4.1", + "eslint-plugin-react-refresh": "^0.4.3", "typescript": "^5.0.4", "vite": "^4.3.8" } diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index 7fd935f..2391167 100644 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -225,9 +225,7 @@ function Layout({ setIsSpecialOfferOpen }: LayoutProps): JSX.Element { {showNavbar ? ( setIsMenuOpen(false)} /> ) : null} - { - // showNavbarFooter && - hasNavbarFooter(location.pathname) ? ( + {showNavbarFooter && hasNavbarFooter(location.pathname) ? ( ) : null} diff --git a/src/components/Compatibility/index.tsx b/src/components/Compatibility/index.tsx index ea3081e..1fb90fa 100644 --- a/src/components/Compatibility/index.tsx +++ b/src/components/Compatibility/index.tsx @@ -18,8 +18,9 @@ import { } from "@/services/zodiac-sign"; import { Asset } from "@/api/resources/Assets"; import { getRandomArbitrary } from "@/services/random-value"; -import Onboarding, { EDirectionOnboarding } from "../Onboarding"; +import Onboarding from "../Onboarding"; import TextWithFinger from "../TextWithFinger"; +import { EDirectionOnboarding } from "@/types"; function CompatibilityPage(): JSX.Element { const { t, i18n } = useTranslation(); @@ -143,6 +144,12 @@ function CompatibilityPage(): JSX.Element { setCompatCategory(parseInt(event.target.value)); }; + const handleNameOnboarding = () => { + if (!name.length) return; + setCurrentOnboarding(1); + dateRef.current?.scrollIntoView({ behavior: "smooth" }); + }; + return (
- {!onboardingCompatibility.isShown && <> - {currentOnboarding === 0 && ( - - + {currentOnboarding === 0 && ( + setCurrentOnboarding(1)} - /> - - )} - {currentOnboarding === 1 && ( - - <> - + showBackground={true} + > + + )} + {currentOnboarding === 1 && ( + + <> + + + + + )} + {currentOnboarding === 3 && ( + + - - - )} - {currentOnboarding === 3 && ( - - - - )} - } + + )} + + )}
- {currentOnboarding === 2 && !onboardingCompatibility.isShown && ( + {currentOnboarding === 2 && !onboardingCompatibility?.isShown && ( { @@ -166,7 +166,10 @@ function HomePage(): JSX.Element { isShowNavbar ? styles["content__buttons--hidden"] : "" }`} > - + setIsShowOnboardingHome(false)} diff --git a/src/components/Navbar/index.tsx b/src/components/Navbar/index.tsx index 2b1326e..98bf907 100644 --- a/src/components/Navbar/index.tsx +++ b/src/components/Navbar/index.tsx @@ -1,5 +1,5 @@ import { useTranslation } from 'react-i18next' -import { Link } from 'react-router-dom' +import { Link, useNavigate } from 'react-router-dom' import { useAuth } from '@/auth' import { useLegal } from '@/legal' import routes from '@/routes' @@ -15,8 +15,15 @@ const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1) function Navbar({ isOpen, closeMenu }: NavbarProps): JSX.Element { const { logout } = useAuth() const { t } = useTranslation() + const navigate = useNavigate() const legal = useLegal() const combinedClassNames = ['navbar', isOpen && 'navbar--open'].filter(Boolean).join(' ') + + const handleLogout = () => { + navigate(routes.client.birthday()) + logout() + } + return ( diff --git a/src/components/NavbarFooter/index.tsx b/src/components/NavbarFooter/index.tsx index 2040dce..860753d 100644 --- a/src/components/NavbarFooter/index.tsx +++ b/src/components/NavbarFooter/index.tsx @@ -1,7 +1,7 @@ import { Link } from "react-router-dom"; import styles from "./styles.module.css"; import Onboarding from "../Onboarding"; -import { useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import TextWithFinger from "../TextWithFinger"; import { useDispatch, useSelector } from "react-redux"; import { actions, selectors } from "@/store"; @@ -28,11 +28,18 @@ function NavbarFooter({ items }: INavbarHomeProps): JSX.Element { ); const [isShowOnboardingNavbarFooter, setIsShowOnboardingNavbarFooter] = - useState(!onboardingConfigNavbarFooter.isShown); + useState(!onboardingConfigNavbarFooter?.isShown); const [selectedOnboarding, setSelectedOnboarding] = useState(3); + const [rerender, setRerender] = useState(false); + console.log(rerender); const buttonsRef = useRef([] as HTMLDivElement[]); + useEffect(() => { + setRerender((prev) => !prev); + }, [buttonsRef]) + + const setShownOnboarding = () => { setIsShowOnboardingNavbarFooter(false); dispatch( diff --git a/src/components/Onboarding/index.tsx b/src/components/Onboarding/index.tsx index 61be6be..3b242fb 100644 --- a/src/components/Onboarding/index.tsx +++ b/src/components/Onboarding/index.tsx @@ -1,12 +1,6 @@ import { useEffect, useRef, useState } from "react"; import styles from "./styles.module.css"; - -export enum EDirectionOnboarding { - LEFT = "left", - RIGHT = "right", - TOP = "top", - BOTTOM = "bottom", -} +import { EDirectionOnboarding } from "@/types"; interface OnboardingProps { targetRef: HTMLElement; @@ -34,8 +28,7 @@ const getCoordinates = ( targetRef.offsetTop + targetRef.offsetHeight / 2 - onboardingRef.current.offsetHeight / 2, - left: - targetRef.offsetLeft - onboardingRef.current.offsetWidth, + left: targetRef.offsetLeft - onboardingRef.current.offsetWidth, }; case EDirectionOnboarding.RIGHT: return { @@ -84,7 +77,7 @@ function Onboarding({ isShow, direction = EDirectionOnboarding.TOP, showBackground = false, - classNameContainer = '', + classNameContainer = "", children, }: OnboardingProps): JSX.Element { const onboardingRef = useRef(null); @@ -93,21 +86,29 @@ function Onboarding({ left: 0, }); useEffect(() => { + if (!onboardingRef.current || !targetRef) { + return; + } setCoordinates(getCoordinates(targetRef, direction, onboardingRef)); }, [direction, targetRef, children]); - const [top, left] = [coordinates.top, coordinates.left]; if (!isShow) { return <>; } return ( -
+
{children} diff --git a/src/components/TextWithFinger/index.tsx b/src/components/TextWithFinger/index.tsx index 0186c76..42c353d 100644 --- a/src/components/TextWithFinger/index.tsx +++ b/src/components/TextWithFinger/index.tsx @@ -1,4 +1,4 @@ -import { EDirectionOnboarding } from "../Onboarding"; +import { EDirectionOnboarding } from "@/types"; import styles from "./styles.module.css"; interface TextWithFingerProps { diff --git a/src/store/index.ts b/src/store/index.ts index 4ffc371..84c890a 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -47,19 +47,6 @@ import { } from "./userCallbacks"; const preloadedState = loadStore(); -export const reducer = combineReducers({ - token, - user, - form, - status, - subscriptionPlans, - aura, - payment, - compatibility, - userCallbacks, - siteConfig, - onboardingConfig, -}); export const actions = { token: tokenActions, user: userActions, @@ -94,6 +81,21 @@ export const selectors = { selectOnboardingNavbarFooter, ...formSelectors, }; + +export const reducer = combineReducers({ + token, + user, + form, + status, + subscriptionPlans, + aura, + payment, + compatibility, + userCallbacks, + siteConfig, + onboardingConfig, +}); + export type RootState = ReturnType; export const store = configureStore({ reducer, diff --git a/src/store/onboarding.ts b/src/store/onboarding.ts index 0a3524b..a3d3cc7 100644 --- a/src/store/onboarding.ts +++ b/src/store/onboarding.ts @@ -36,7 +36,7 @@ const onboardingConfigSlice = createSlice({ initialState, reducers: { update(state, action: PayloadAction>) { - return { ...state, ...action.payload }; + return { ...initialState, ...state, ...action.payload }; }, }, extraReducers: (builder) => builder.addCase("reset", () => initialState), @@ -44,7 +44,9 @@ const onboardingConfigSlice = createSlice({ export const { actions } = onboardingConfigSlice; export const selectOnboarding = createSelector( - (state: { onboardingConfig: IOnboardingConfig }) => state.onboardingConfig, + (state: { onboardingConfig: IOnboardingConfig }) => { + return state.onboardingConfig + }, (onboardingConfig) => onboardingConfig ); export const selectOnboardingHome = createSelector( diff --git a/src/types.ts b/src/types.ts index 453badf..9ff926b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -6,6 +6,13 @@ declare global { } } +export enum EDirectionOnboarding { + LEFT = "left", + RIGHT = "right", + TOP = "top", + BOTTOM = "bottom", +} + export interface FormField { name: string value: T