import * as routes from "@/constants/routes/myPages" import { env } from "@/env/server" import { getIntl } from "@/i18n" import { safeTry } from "@/utils/safeTry" import type { ReactNode } from "react" import type { Lang } from "../../constants/languages" export type MyPagesLink = { text: ReactNode href: string } type Args = { lang: Lang } export async function getPrimaryLinks({ lang }: Args): Promise { const intl = await getIntl() const scandicSasPromise = safeTry(isScandicXSASActive()) const teamMemberPromise = safeTry(showTeamMemberCard()) const [showSASLink] = await scandicSasPromise const [showTeamMemberLink] = await teamMemberPromise const menuItems: MyPagesLink[] = [ { text: intl.formatMessage({ id: "Overview" }), href: routes.overview[lang], }, { text: intl.formatMessage({ id: "My Points" }), href: routes.points[lang], }, { text: intl.formatMessage({ id: "My Stays" }), href: routes.stays[lang], }, { text: intl.formatMessage({ id: "My Benefits" }), href: routes.benefits[lang], }, ] if (showSASLink) { menuItems.push({ text: intl.formatMessage({ id: "Scandic ♥ SAS" }), href: routes.scandicXSAS[lang], }) } if (showTeamMemberLink) { menuItems.push({ text: intl.formatMessage({ id: "Team Member Card" }), href: "#", }) } return menuItems } export async function getSecondaryLinks({ lang, }: Args): Promise { const intl = await getIntl() const menuItems: MyPagesLink[] = [ { text: intl.formatMessage({ id: "About Scandic Friends" }), href: routes.scandicFriends[lang], }, { text: intl.formatMessage({ id: "My Profile" }), href: routes.profile[lang], }, ] return menuItems } async function isScandicXSASActive() { async function checkIfLinked() { // TODO: Implement this check return true } const isLinked = await checkIfLinked() return env.SAS_ENABLED && isLinked } async function showTeamMemberCard() { async function getIsTeamMember() { // TODO: Implement this check return false } const isTeamMember = await getIsTeamMember() return isTeamMember }