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 ( +
+ {t("au.besties.result")} + {data.name} +
+{"Get an answer"}
-{"Get an answer"}
navigate(routes.client.home())}
+ />
{isLoading ? (