w-aura/src/routes.ts
gofnnp 65fe6c21d5 AW-131-pdf
add pdf viewer to home page
2024-07-04 03:51:06 +04:00

520 lines
21 KiB
TypeScript
Executable File

import { EPlacementKeys } from "./api/resources/Paywall";
import type { UserStatus } from "./types";
const environments = import.meta.env
const host = "";
export const apiHost = environments.AURA_API_HOST;
const dApiHost = environments.AURA_DAPI_HOST
const dApiPrefix = environments.AURA_DAPI_PREFIX
const siteHost = environments.AURA_SITE_HOST
const prefix = environments.AURA_PREFIX;
const openAIHost = environments.AURA_OPEN_AI_HOST;
const openAiPrefix = environments.AURA_OPEN_AI_PREFIX;
const routes = {
client: {
root: () => [host, ""].join("/"),
palmistry: () => [host, "palmistry"].join("/"),
palmistryWelcome: () => [host, "palmistry", "welcome"].join("/"),
palmistryGender: () => [host, "palmistry", "gender"].join("/"),
palmistryBirthdate: () => [host, "palmistry", "birthdate"].join("/"),
palmistryPalmsHold: () => [host, "palmistry", "palms-hold"].join("/"),
palmistryWish: () => [host, "palmistry", "wish"].join("/"),
palmistryRelationship: () =>
[host, "palmistry", "relationship-status"].join("/"),
palmistryResonatedElement: () =>
[host, "palmistry", "resonated-element"].join("/"),
palmistryColorYouLike: () =>
[host, "palmistry", "color-you-like"].join("/"),
palmistryDecisions: () => [host, "palmistry", "decisions"].join("/"),
palmistryGuidancePlan: () => [host, "palmistry", "guidance-plan"].join("/"),
palmistryPersonalStatement: () =>
[host, "palmistry", "personal-statement"].join("/"),
palmistryScanInfo: () => [host, "palmistry", "scan-info"].join("/"),
palmistryUpload: () => [host, "palmistry", "upload"].join("/"),
palmistryScanPhoto: () => [host, "palmistry", "scan-photo"].join("/"),
palmistryEmail: () => [host, "palmistry", "email"].join("/"),
palmistrySubscriptionPlan: () =>
[host, "palmistry", "subscription-plan"].join("/"),
palmistryPaywall: () => [host, "palmistry", "paywall"].join("/"),
palmistryPayment: () => [host, "palmistry", "payment"].join("/"),
palmistryDiscount: () => [host, "palmistry", "discount"].join("/"),
palmistryPremiumBundle: () =>
[host, "palmistry", "premium-bundle"].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("/"),
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("/"),
gender: () => [host, "gender"].join("/"),
questionnaire: () => [host, "questionnaire"].join("/"),
goalSetup: () => [host, "goal-setup"].join("/"),
hyperPersonalizedAstrology: () =>
[host, "hyper-personalized-astrology"].join("/"),
noTime: () => [host, "no-time"].join("/"),
loadingInRelationship: () => [host, "loading-in-relationship"].join("/"),
worksRouter: () => [host, "works-router"].join("/"),
worksForUs: () => [host, "works-for-us"].join("/"),
worksTraits: () => [host, "works-traits"].join("/"),
relationshipAlmostThere: () =>
[host, "relationship-almost-there"].join("/"),
singleZodiacInfo: () => [host, "single-zodiac-info"].join("/"),
problems: () => [host, "problems"].join("/"),
notAlone: () => [host, "not-alone"].join("/"),
allRight: () => [host, "all-right"].join("/"),
almostThere: () => [host, "almost-there"].join("/"),
partnerRightPlace: () => [host, "partner-right-place"].join("/"),
partnerThing: () => [host, "partner-thing"].join("/"),
partnerTotallyNormal: () => [host, "partner-totally-normal"].join("/"),
withHeart: () => [host, "with-heart"].join("/"),
withHead: () => [host, "with-head"].join("/"),
both: () => [host, "both"].join("/"),
relationshipZodiacInfo: () => [host, "relationship-zodiac-info"].join("/"),
satisfiedResult: () => [host, "satisfied-result"].join("/"),
aboutUs: () => [host, "about-us"].join("/"),
loadingProfile: () => [host, "loading-profile"].join("/"),
emailConfirm: () => [host, "email-confirm"].join("/"),
onboarding: () => [host, "onboarding"].join("/"),
trialChoice: () => [host, "trial-choice"].join("/"),
trialPayment: () => [host, "trial-payment"].join("/"),
additionalDiscount: () => [host, "additional-discount"].join("/"),
trialPaymentWithDiscount: () =>
[host, "trial-payment-with-discount"].join("/"),
tryApp: () => [host, "try-app"].join("/"),
// Email letters
email: (path: string) => [host, "email", path].join("/"),
// Additional Purchases
addReport: () => [host, "add-report"].join("/"),
unlimitedReadings: () => [host, "unlimited-readings"].join("/"),
addConsultation: () => [host, "add-consultation"].join("/"),
// Advisors
advisors: () => [host, "advisors"].join("/"),
advisorChat: (id: string) => [host, "advisors", id].join("/"),
// Email - Pay - Email
epeGender: () => [host, "epe", "gender"].join("/"),
epeBirthdate: () => [host, "epe", "birthdate"].join("/"),
epeEmail: () => [host, "epe", "email"].join("/"),
epePayment: () => [host, "epe", "payment"].join("/"),
epeSuccessPayment: () => [host, "epe", "success-payment"].join("/"),
epeFailPayment: () => [host, "epe", "fail-payment"].join("/"),
// Advisor short path
advisorChatGender: () => [host, "advisor-chat", "gender"].join("/"),
advisorChatBirthdate: () => [host, "advisor-chat", "birthdate"].join("/"),
advisorChatBirthtime: () => [host, "advisor-chat", "birthtime"].join("/"),
advisorChatBirthPlace: () =>
[host, "advisor-chat", "birth-place"].join("/"),
advisorChatEmail: () => [host, "advisor-chat", "email"].join("/"),
advisorChatPayment: () => [host, "advisor-chat", "payment"].join("/"),
advisorChatSuccessPayment: () =>
[host, "advisor-chat", "success-payment"].join("/"),
advisorChatFailPayment: () =>
[host, "advisor-chat", "fail-payment"].join("/"),
advisorChatPrivate: (id?: string) =>
[host, "advisor-chat-private", id].join("/"),
singlePaymentShortPath: (productId?: string) =>
[host, "single-payment", productId].join("/"),
getInformationPartner: () => [host, "get-information-partner"].join("/"),
// ABDesignV1
genderV1: () => [host, "v1", "gender"].join("/"),
questionnaireV1: () => [host, "v1", "questionnaire"].join("/"),
goalSetupV1: () => [host, "v1", "goal-setup"].join("/"),
aboutUsV1: () => [host, "v1", "about-us"].join("/"),
hyperPersonalizedAstrologyV1: () =>
[host, "v1", "hyper-personalized-astrology"].join("/"),
singleZodiacInfoV1: () => [host, "v1", "single-zodiac-info"].join("/"),
relationshipZodiacInfoV1: () => [host, "v1", "relationship-zodiac-info"].join("/"),
noTimeV1: () => [host, "v1", "no-time"].join("/"),
relationshipAlmostThereV1: () =>
[host, "v1", "relationship-almost-there"].join("/"),
loadingInRelationshipV1: () => [host, "v1", "loading-in-relationship"].join("/"),
problemsV1: () => [host, "v1", "problems"].join("/"),
worksRouterV1: () => [host, "v1", "works-router"].join("/"),
worksForUsV1: () => [host, "v1", "works-for-us"].join("/"),
worksTraitsV1: () => [host, "v1", "works-traits"].join("/"),
notAloneV1: () => [host, "v1", "not-alone"].join("/"),
allRightV1: () => [host, "v1", "all-right"].join("/"),
almostThereV1: () => [host, "v1", "almost-there"].join("/"),
partnerRightPlaceV1: () => [host, "v1", "partner-right-place"].join("/"),
partnerThingV1: () => [host, "v1", "partner-thing"].join("/"),
partnerTotallyNormalV1: () => [host, "v1", "partner-totally-normal"].join("/"),
withHeartV1: () => [host, "v1", "with-heart"].join("/"),
withHeadV1: () => [host, "v1", "with-head"].join("/"),
bothV1: () => [host, "v1", "both"].join("/"),
satisfiedResultV1: () => [host, "v1", "satisfied-result"].join("/"),
loadingProfileV1: () => [host, "v1", "loading-profile"].join("/"),
emailEnterV1: () => [host, "v1", "email"].join("/"),
emailConfirmV1: () => [host, "v1", "email-confirm"].join("/"),
onboardingV1: () => [host, "v1", "onboarding"].join("/"),
trialChoiceV1: () => [host, "v1", "trial-choice"].join("/"),
trialPaymentV1: () => [host, "v1", "trial-payment"].join("/"),
trialPaymentWithDiscountV1: () =>
[host, "v1", "trial-payment-with-discount"].join("/"),
additionalDiscountV1: () => [host, "v1", "additional-discount"].join("/"),
loadingPage: () => [host, "loading-page"].join("/"),
notFound: () => [host, "404"].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(
"/"
),
subscriptionStatusNew: () =>
[dApiHost, "users", "subscription", "status"].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("/"),
dApiTestPaymentProducts: () =>
[dApiHost, "payment", "test", "products"].join("/"),
dApiPaymentCheckout: () => [dApiHost, "payment", "checkout"].join("/"),
dApiCheckProductPurchased: (productKey: string, email: string) =>
[dApiHost, "payment", "products", `${productKey}?email=${email}`].join(
"/"
),
dApiAuth: () => [dApiHost, "users", "auth"].join("/"),
dApiGetRealToken: () => [dApiHost, "users", "auth", "token"].join("/"),
assistants: () => [apiHost, prefix, "ai", "assistants.json"].join("/"),
setExternalChatIdAssistants: (chatId: string) =>
[apiHost, prefix, "ai", "assistants", chatId, "chats.json"].join("/"),
// Palmistry
getPalmistryLines: () =>
[dApiHost, dApiPrefix, "palmistry", "lines"].join("/"),
// Paywall
getPaywallByPlacementKey: (placementKey: EPlacementKeys) =>
[dApiHost, dApiPrefix, "placement", placementKey, "paywall"].join("/"),
// Payment
makePayment: () =>
[dApiHost, dApiPrefix, "payment", "checkout"].join("/"),
// User videos
getUserVideos: () =>
[dApiHost, "users", "videos", "combined"].join("/"),
// User videos
getUserPDFCompatibility: () =>
[dApiHost, "users", "pdf", "compatibility"].join("/"),
},
openAi: {
createThread: () => [openAIHost, openAiPrefix, "threads"].join("/"),
createMessage: (threadId: string) =>
[openAIHost, openAiPrefix, "threads", threadId, "messages"].join("/"),
getListMessages: (threadId: string) =>
[openAIHost, openAiPrefix, "threads", threadId, "messages"].join("/"),
runThread: (threadId: string) =>
[openAIHost, openAiPrefix, "threads", threadId, "runs"].join("/"),
getStatusRunThread: (threadId: string, runId: string) =>
[openAIHost, openAiPrefix, "threads", threadId, "runs", runId].join("/"),
getListRuns: (threadId: string) =>
[openAIHost, openAiPrefix, "threads", threadId, "runs"].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(),
routes.client.trialChoice(),
routes.client.palmistry(),
routes.client.advisors(),
routes.client.advisorChatGender(),
routes.client.advisorChatSuccessPayment(),
routes.client.advisorChatFailPayment(),
];
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(),
];
/**
* Checks if a given path has a cross button.
* @param {string} path - The path to check.
* @returns {boolean} - True if the path has a cross button, false otherwise.
*/
export const hasCrossButton = (path: string): boolean => {
// Check if the path is included in the array of routes with cross buttons
return 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.magicBall(),
routes.client.horoscopeBestiesResult(),
routes.client.predictionMoonResult(),
routes.client.myHoroscopeResult(),
routes.client.thermalResult(),
routes.client.moonPhaseTracker(),
routes.client.energyVampirismResult(),
routes.client.nameHoroscopeResult(),
routes.client.goalSetup(),
routes.client.hyperPersonalizedAstrology(),
routes.client.noTime(),
routes.client.loadingInRelationship(),
routes.client.worksForUs(),
routes.client.relationshipAlmostThere(),
routes.client.singleZodiacInfo(),
routes.client.worksTraits(),
routes.client.notAlone(),
routes.client.allRight(),
routes.client.almostThere(),
routes.client.partnerRightPlace(),
routes.client.partnerThing(),
routes.client.partnerTotallyNormal(),
routes.client.withHeart(),
routes.client.withHead(),
routes.client.both(),
routes.client.relationshipZodiacInfo(),
routes.client.satisfiedResult(),
routes.client.aboutUs(),
routes.client.emailConfirm(),
routes.client.onboarding(),
routes.client.trialChoice(),
routes.client.trialPayment(),
routes.client.additionalDiscount(),
routes.client.trialPaymentWithDiscount(),
routes.client.palmistryPaywall(),
routes.client.palmistryPayment(),
routes.client.palmistryDiscount(),
routes.client.email("marketing-landing"),
routes.client.email("marketing-trial-payment"),
routes.client.tryApp(),
routes.client.addReport(),
routes.client.unlimitedReadings(),
routes.client.addConsultation(),
routes.client.advisors(),
routes.client.epeSuccessPayment(),
routes.client.getInformationPartner(),
routes.client.advisorChatBirthPlace(),
];
export const withoutFooterPartOfRoutes = [
routes.client.questionnaire(),
routes.client.advisors(),
routes.client.advisorChatPrivate(),
];
export const hasNoFooter = (path: string) => {
const targetRoute = withoutFooterPartOfRoutes.findIndex((route) =>
path.includes(route)
);
return !withoutFooterRoutes.includes(path) && targetRoute === -1;
};
export const withNavbarFooterRoutes = [
routes.client.home(),
routes.client.compatibility(),
routes.client.compatibilityResult(),
routes.client.breath(),
routes.client.breathResult(),
routes.client.wallpaper(),
routes.client.advisors(),
];
export const hasNavbarFooter = (path: string) =>
withNavbarFooterRoutes.includes(path);
export const withoutHeaderRoutes = [
routes.client.palmistryPayment(),
routes.client.palmistryDiscount(),
routes.client.palmistryPremiumBundle(),
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(),
routes.client.goalSetup(),
routes.client.hyperPersonalizedAstrology(),
routes.client.noTime(),
routes.client.loadingInRelationship(),
routes.client.worksForUs(),
routes.client.relationshipAlmostThere(),
routes.client.singleZodiacInfo(),
routes.client.worksTraits(),
routes.client.notAlone(),
routes.client.allRight(),
routes.client.almostThere(),
routes.client.partnerRightPlace(),
routes.client.partnerThing(),
routes.client.partnerTotallyNormal(),
routes.client.withHeart(),
routes.client.withHead(),
routes.client.both(),
routes.client.relationshipZodiacInfo(),
routes.client.satisfiedResult(),
routes.client.onboarding(),
routes.client.trialPayment(),
routes.client.additionalDiscount(),
routes.client.trialPaymentWithDiscount(),
routes.client.email("marketing-landing"),
routes.client.email("marketing-trial-payment"),
routes.client.tryApp(),
routes.client.advisors(),
routes.client.epeSuccessPayment(),
routes.client.getInformationPartner(),
routes.client.advisorChatPrivate(),
];
export const hasNoHeader = (path: string) => {
let result = true;
withoutHeaderRoutes.forEach((route) => {
if (
(!path.includes("palmistry") && path.includes(route)) ||
(path.includes("palmistry") && path === route)
) {
result = false;
}
});
return result;
};
export const withFullDataModalRoutes = [routes.client.home()];
export const hasFullDataModal = (path: string) => {
return withFullDataModalRoutes.includes(`/${path.split("/")[1]}`);
};
export const getRouteBy = (status: UserStatus): string => {
switch (status) {
case "lead":
return routes.client.gender();
case "registred":
case "unsubscribed":
return routes.client.trialPayment();
case "subscribed":
return routes.client.home();
default:
throw new Error(`Unknown user status, received status is "${status}"`);
}
};
export default routes;