import type { UserStatus } from "./types"; const host = ""; export const apiHost = "https://api-web.aura.wit.life"; const siteHost = "https://aura.wit.life"; const prefix = "api/v1"; const routes = { client: { root: () => [host, ""].join("/"), birthday: () => [host, "birthday"].join("/"), didYouKnow: () => [host, "did-you-know"].join("/"), freePeriodInfo: () => [host, "free-period"].join("/"), birthtime: () => [host, "birthtime"].join("/"), emailEnter: () => [host, "email"].join("/"), authResult: () => [host, "auth", "result"].join("/"), auth: () => [host, "auth"].join("/"), subscription: () => [host, "subscription"].join("/"), createProfile: () => [host, "profile", "create"].join("/"), attention: () => [host, "attention"].join("/"), feedback: () => [host, "feedback"].join("/"), paymentMethod: () => [host, "payment", "method"].join("/"), paymentResult: () => [host, "payment", "result"].join("/"), paymentSuccess: () => [host, "payment", "success"].join("/"), paymentFail: () => [host, "payment", "fail"].join("/"), paymentStripe: () => [host, "payment", "stripe"].join("/"), wallpaper: () => [host, "wallpaper"].join("/"), static: () => [host, "static", ":typeId"].join("/"), legal: (type: string) => [host, "static", type].join("/"), compatibility: () => [host, "compatibility"].join("/"), compatibilityResult: () => [host, "compatibility", "result"].join("/"), breath: () => [host, "breath"].join("/"), priceList: () => [host, "price-list"].join("/"), home: () => [host, "home"].join("/"), breathResult: () => [host, "breath", "result"].join("/"), magicBall: () => [host, "magic-ball"].join("/"), horoscopeBestiesResult: () => [host, "horoscope-besties"].join("/"), predictionMoonResult: () => [host, "prediction-moon"].join("/"), myHoroscopeResult: () => [host, "my-horoscope"].join("/"), thermalResult: () => [host, "thermal"].join("/"), moonPhaseTracker: () => [host, "moon-phase-tracker"].join("/"), energyVampirismResult: () => [host, "energy-vampirism"].join("/"), nameHoroscopeResult: () => [host, "name-horoscope"].join("/"), }, server: { appleAuth: (origin: string) => [apiHost, "auth", "apple", `gate?origin=${origin}`].join("/"), googleAuth: (origin: string) => [apiHost, "auth", "google", `gate?origin=${origin}`].join("/"), user: () => [apiHost, prefix, "user.json"].join("/"), token: () => [apiHost, prefix, "auth", "token.json"].join("/"), elements: () => [apiHost, prefix, "elements.json"].join("/"), zodiacs: (zodiac: string) => [apiHost, prefix, "zodiacs", `${zodiac}.json`].join("/"), element: (type: string) => [apiHost, prefix, "elements", `${type}.json`].join("/"), apps: (bundleId: string) => [apiHost, prefix, "apps", `${bundleId}.json`].join("/"), assets: (category: string) => [apiHost, prefix, "assets", "categories", `${category}.json`].join("/"), assetCategories: () => [apiHost, prefix, "assets", "categories.json"].join("/"), dailyForecasts: () => [apiHost, prefix, "user", "daily_forecast.json"].join("/"), auras: () => [apiHost, prefix, "user", "aura.json"].join("/"), paymentIntents: () => [apiHost, prefix, "user", "payment_intents.json"].join("/"), subscriptionItems: () => [apiHost, prefix, "user", "subscription", "item_prices.json"].join("/"), subscriptionPlans: () => [apiHost, prefix, "sub_plans.json"].join("/"), subscriptionCheckout: () => [apiHost, prefix, "user", "subscription", "checkout", "new.json"].join( "/" ), subscriptionStatus: () => [apiHost, prefix, "user", "subscription_receipts", "status.json"].join( "/" ), subscriptionReceipts: () => [apiHost, prefix, "user", "subscription_receipts.json"].join("/"), subscriptionReceipt: (id: string) => [apiHost, prefix, "user", "subscription_receipts", `${id}.json`].join( "/" ), compatCategories: () => [apiHost, prefix, "ai", "compat_categories.json"].join("/"), compat: () => [apiHost, prefix, "ai", "compats.json"].join("/"), createUserCallbacks: () => [apiHost, prefix, "user", "callbacks.json"].join("/"), getUserCallbacks: (id: string) => [apiHost, prefix, "user", "callbacks", `${id}.json`].join("/"), getTranslations: () => [siteHost, "api/v2", "t.json"].join("/"), aiRequestsV2: (promptKey: string) => [apiHost, "api/v2", "ai", "prompts", promptKey, "requests.json"].join( "/" ), getAiRequestsV2: (id: string) => [apiHost, "api/v2", "ai", "requests", `${id}.json`].join("/"), }, }; export const entrypoints = [ routes.client.root(), routes.client.birthday(), routes.client.subscription(), routes.client.wallpaper(), routes.client.didYouKnow(), routes.client.attention(), routes.client.feedback(), routes.client.breath(), routes.client.compatibilityResult(), routes.client.home(), routes.client.breathResult(), routes.client.magicBall(), ]; export const isEntrypoint = (path: string) => entrypoints.includes(path); export const isNotEntrypoint = (path: string) => !isEntrypoint(path); export const withNavigationRoutes = [ routes.client.wallpaper(), routes.client.home(), ]; export const hasNavigation = (path: string) => withNavigationRoutes.includes(path); export const hasNoNavigation = (path: string) => !hasNavigation(path); export const withCrossButtonRoutes = [ // routes.client.attention(), routes.client.subscription(), routes.client.paymentMethod(), ]; export const hasCrossButton = (path: string) => withCrossButtonRoutes.includes(path); export const withoutFooterRoutes = [ routes.client.didYouKnow(), routes.client.freePeriodInfo(), routes.client.createProfile(), routes.client.attention(), routes.client.feedback(), routes.client.compatibility(), routes.client.breath(), routes.client.priceList(), routes.client.compatibilityResult(), routes.client.home(), routes.client.breathResult(), routes.client.paymentResult(), routes.client.paymentSuccess(), routes.client.paymentFail(), routes.client.paymentStripe(), routes.client.magicBall(), routes.client.horoscopeBestiesResult(), routes.client.predictionMoonResult(), routes.client.myHoroscopeResult(), routes.client.thermalResult(), routes.client.moonPhaseTracker(), routes.client.energyVampirismResult(), routes.client.nameHoroscopeResult(), ]; export const hasNoFooter = (path: string) => !withoutFooterRoutes.includes(path); export const withNavbarFooterRoutes = [ routes.client.home(), routes.client.compatibility(), routes.client.compatibilityResult(), routes.client.breath(), routes.client.breathResult(), routes.client.wallpaper(), ]; export const hasNavbarFooter = (path: string) => withNavbarFooterRoutes.includes(path); export const withoutHeaderRoutes = [ routes.client.compatibility(), routes.client.subscription(), routes.client.paymentMethod(), routes.client.paymentResult(), routes.client.paymentSuccess(), routes.client.paymentFail(), routes.client.magicBall(), routes.client.horoscopeBestiesResult(), routes.client.predictionMoonResult(), routes.client.myHoroscopeResult(), routes.client.myHoroscopeResult(), routes.client.thermalResult(), routes.client.moonPhaseTracker(), routes.client.energyVampirismResult(), routes.client.nameHoroscopeResult(), ]; export const hasNoHeader = (path: string) => !withoutHeaderRoutes.includes(path); export const getRouteBy = (status: UserStatus): string => { switch (status) { case "lead": return routes.client.birthday(); case "registred": case "unsubscribed": return routes.client.subscription(); case "subscribed": return routes.client.home(); default: throw new Error(`Unknown user status, received status is "${status}"`); } }; export default routes;