diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index d4ff9ca..42618aa 100644 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -344,7 +344,8 @@ function PrivateOutlet(): JSX.Element { } function PrivateSubscriptionOutlet(): JSX.Element { - const isProduction = import.meta.env.MODE === "production"; + // const isProduction = import.meta.env.MODE === "production"; + const isProduction = false; console.log(isProduction); const status = useSelector(selectors.selectStatus); return status === "subscribed" || !isProduction ? ( diff --git a/src/components/BestiesHoroscopeSlider/index.tsx b/src/components/BestiesHoroscopeSlider/index.tsx new file mode 100644 index 0000000..2c1d526 --- /dev/null +++ b/src/components/BestiesHoroscopeSlider/index.tsx @@ -0,0 +1,66 @@ +import { useTranslation } from "react-i18next"; +import styles from "./styles.module.css"; +import { + getCategoryIdByZodiacSign, + getZodiacSignByDate, +} from "@/services/zodiac-sign"; +import { useEffect, useState } from "react"; +import { useApi } from "@/api"; +import { getRandomArbitrary } from "@/services/random-value"; + +interface BestiesHoroscopeSliderProps { + data: Horoscope; +} + +export interface Horoscope { + name: string; + birthDate: string; +} + +function BestiesHoroscopeSlider({ + data, +}: BestiesHoroscopeSliderProps): JSX.Element { + const api = useApi(); + const { i18n, t } = useTranslation(); + const locale = i18n.language; + const zodiacSign = getZodiacSignByDate(data.birthDate); + const [backgroundUrl, setBackgroundUrl] = useState(""); + + useEffect(() => { + (async () => { + try { + const { asset_categories } = await api.getAssetCategories({ locale }); + const categoryId = getCategoryIdByZodiacSign( + zodiacSign, + asset_categories + ); + const assets = ( + await api.getAssets({ category: String(categoryId || "1") }) + ).assets; + const randomAsset = assets[getRandomArbitrary(0, assets.length - 1)]; + setBackgroundUrl(randomAsset.url); + } catch (error) { + console.error("Error: ", error); + } + })(); + }, []); + + return ( +
{ + console.log("start"); + }} + > +

+ {t("au.besties.result")} + {data.name} +

+
+ ); +} + +export default BestiesHoroscopeSlider; diff --git a/src/components/BestiesHoroscopeSlider/styles.module.css b/src/components/BestiesHoroscopeSlider/styles.module.css new file mode 100644 index 0000000..4e86c46 --- /dev/null +++ b/src/components/BestiesHoroscopeSlider/styles.module.css @@ -0,0 +1,28 @@ +.container { + width: max-content; + max-width: 280px; + height: 160px; + border-radius: 17px; + display: flex; + align-items: flex-end; + justify-content: center; + padding: 8px 12px; + background-repeat: no-repeat !important; + background-size: cover !important; + background-position: center !important; + background-color: #000 !important; +} + +.text { + color: #b1b0b0; + font-weight: 400; + font-size: 17px; + line-height: 20px; + text-align: left; +} + +.text > b { + color: #fff; + font-weight: 700; + font-size: 18px; +} diff --git a/src/components/Compatibility/index.tsx b/src/components/Compatibility/index.tsx index 9ef9e3e..809751b 100644 --- a/src/components/Compatibility/index.tsx +++ b/src/components/Compatibility/index.tsx @@ -90,8 +90,16 @@ function CompatibilityPage(): JSX.Element { birthDate: selectedDate, }, categoryId: compatCategory, + selfName, }) ); + dispatch( + actions.compatibilities.update({ + name, + birthDate: getDateAsString(selectedDate), + }) + ); + navigate(routes.client.compatibilityResult()); }; diff --git a/src/components/HomePage/index.tsx b/src/components/HomePage/index.tsx index 67b3a45..5890fd5 100644 --- a/src/components/HomePage/index.tsx +++ b/src/components/HomePage/index.tsx @@ -21,6 +21,8 @@ import { EPathsFromHome } from "@/store/siteConfig"; import { buildFilename, saveFile } from "../WallpaperPage/utils"; import Onboarding from "../Onboarding"; import TextWithFinger from "../TextWithFinger"; +import Slider from "../Slider"; +import BestiesHoroscopeSlider from "../BestiesHoroscopeSlider"; const buttonTextFormatter = (text: string): JSX.Element => { const sentences = text.split("."); @@ -44,6 +46,8 @@ function HomePage(): JSX.Element { const isShowNavbar = homeConfig.isShowNavbar; const onboardingConfigHome = useSelector(selectors.selectOnboardingHome); + const bestiesHoroscopes = useSelector(selectors.selectCompatibilities); + const [isShowOnboardingHome, setIsShowOnboardingHome] = useState( !onboardingConfigHome?.isShown ); @@ -163,41 +167,60 @@ function HomePage(): JSX.Element { : "calc(100vh - 500px)", }} > - { -
+ - - setIsShowOnboardingHome(false)} - /> - - - {buttonTextFormatter(t("aura-money_compatibility-button"))} - - - {buttonTextFormatter(t("aura-10_breath-button"))} - -
-

{"Get an answer"}

-
+ setIsShowOnboardingHome(false)} + /> +
+ + {buttonTextFormatter(t("aura-money_compatibility-button"))} + + + {buttonTextFormatter(t("aura-10_breath-button"))} + +
+
+
+

{"Get an answer"}

- } +
+ + {/* SLIDERS */} +
+
+ + {"Your Besties' Horoscope"} + + + {bestiesHoroscopes.map((item, index) => ( + + ))} + +
+
+ {/* END SLIDERS */} +
{dailyForecast && dailyForecast.forecasts.map((forecast, index) => ( diff --git a/src/components/HomePage/styles.module.css b/src/components/HomePage/styles.module.css index 0de2ed4..6d391f4 100644 --- a/src/components/HomePage/styles.module.css +++ b/src/components/HomePage/styles.module.css @@ -149,6 +149,7 @@ background-repeat: no-repeat; background-position: center center; animation: pulse 1s alternate infinite; + cursor: pointer; } .content__aura-text { @@ -157,6 +158,24 @@ color: #fff; font-size: 16px; margin: auto; + user-select: none; +} + +.sliders { + width: 100vw; + max-width: 560px; + display: flex; + flex-direction: column; + gap: 42px; +} + +.sliders__title { + font-weight: 700; + font-size: 23px; + color: #FD433F; + text-align: left; + padding: 0 12px; + margin-bottom: 12px; } @keyframes pulse { diff --git a/src/components/Slider/index.tsx b/src/components/Slider/index.tsx new file mode 100644 index 0000000..eb6fd17 --- /dev/null +++ b/src/components/Slider/index.tsx @@ -0,0 +1,16 @@ +import styles from "./styles.module.css"; + +interface ISliderProps { + children: JSX.Element[]; + className?: string; +} + +function Slider({ children, className }: ISliderProps): JSX.Element { + return ( +
+
{children}
+
+ ); +} + +export default Slider; diff --git a/src/components/Slider/styles.module.css b/src/components/Slider/styles.module.css new file mode 100644 index 0000000..befaeb7 --- /dev/null +++ b/src/components/Slider/styles.module.css @@ -0,0 +1,17 @@ +.slider { + width: fit-content; + height: fit-content; + display: flex; + flex-direction: row; + gap: 16px; + padding: 0 12px; +} + +.container { + width: 100%; + overflow-x: scroll; +} + +.container::-webkit-scrollbar { + display: none; +} diff --git a/src/components/StripePage/index.tsx b/src/components/StripePage/index.tsx index 86f00db..fec2de3 100644 --- a/src/components/StripePage/index.tsx +++ b/src/components/StripePage/index.tsx @@ -49,6 +49,12 @@ export function StripePage(): JSX.Element { return (
+ Cross navigate(routes.client.home())} + /> {isLoading ? (
diff --git a/src/components/StripePage/styles.module.css b/src/components/StripePage/styles.module.css index dda5732..0862b8d 100644 --- a/src/components/StripePage/styles.module.css +++ b/src/components/StripePage/styles.module.css @@ -1,5 +1,6 @@ .page { - position: relative; + /* position: relative; */ + position: static; /* height: calc(100vh - 50px); max-height: -webkit-fill-available; */ flex: auto; @@ -14,3 +15,13 @@ justify-content: center; align-items: center; } + +.cross { + position: absolute; + top: -36px; + right: 28px; + width: 22px; + height: 22px; + cursor: pointer; + z-index: 9; +} diff --git a/src/components/pages/MagicBall/index.tsx b/src/components/pages/MagicBall/index.tsx index 7cbf168..4d986e0 100644 --- a/src/components/pages/MagicBall/index.tsx +++ b/src/components/pages/MagicBall/index.tsx @@ -63,8 +63,6 @@ function MagicBallPage(): JSX.Element { setIsRunning(false); return; } - const canVibrate = !!window.navigator.vibrate; - if (canVibrate) window.navigator.vibrate(100); setProcessState((prev) => prev + 1); }, isRunning ? 1000 : null diff --git a/src/store/compatibilities.ts b/src/store/compatibilities.ts new file mode 100644 index 0000000..d133cc4 --- /dev/null +++ b/src/store/compatibilities.ts @@ -0,0 +1,23 @@ +import { Horoscope } from "@/components/BestiesHoroscopeSlider"; +import { createSlice, createSelector } from "@reduxjs/toolkit"; +import type { PayloadAction } from "@reduxjs/toolkit"; + +const initialState: Horoscope[] = [] + +const compatibilitiesSlice = createSlice({ + name: "compatibilities", + initialState, + reducers: { + update(state, action: PayloadAction) { + return [ ...initialState, ...state, action.payload ]; + }, + }, + extraReducers: (builder) => builder.addCase("reset", () => initialState), +}); + +export const { actions } = compatibilitiesSlice; +export const selectCompatibilities = createSelector( + (state: { compatibilities: Horoscope[] }) => state.compatibilities, + (compatibilities) => compatibilities +); +export default compatibilitiesSlice.reducer; diff --git a/src/store/index.ts b/src/store/index.ts index 6288770..e8fa87c 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -33,8 +33,13 @@ import subscriptionPlans, { } from "./subscriptionPlan"; import status, { actions as userStatusActions, selectStatus } from "./status"; import compatibility, { - actions as compatibilityActions, selectSelfName, + actions as compatibilityActions, + selectSelfName, } from "./compatibility"; +import compatibilities, { + actions as compatibilitiesActions, + selectCompatibilities, +} from "./compatibilities"; import userCallbacks, { actions as userCallbacksActions, } from "./userCallbacks"; @@ -57,6 +62,7 @@ export const actions = { aura: auraActions, siteConfig: siteConfigActions, compatibility: compatibilityActions, + compatibilities: compatibilitiesActions, payment: paymentActions, userCallbacks: userCallbacksActions, onboardingConfig: onboardingConfigActions, @@ -82,6 +88,7 @@ export const selectors = { selectOnboardingCompatibility, selectOnboardingBreath, selectOnboardingNavbarFooter, + selectCompatibilities, ...formSelectors, }; @@ -94,6 +101,7 @@ export const reducer = combineReducers({ aura, payment, compatibility, + compatibilities, userCallbacks, siteConfig, onboardingConfig,