diff --git a/apps/user/app/(main)/(user)/layout.tsx b/apps/user/app/(main)/(user)/layout.tsx index 3878efa..f908775 100644 --- a/apps/user/app/(main)/(user)/layout.tsx +++ b/apps/user/app/(main)/(user)/layout.tsx @@ -6,10 +6,7 @@ export default async function DashboardLayout({ children }: { children: React.Re return ( - - {/*
*/} - {children} - + {children} ); diff --git a/apps/user/app/layout.tsx b/apps/user/app/layout.tsx index 4e8fab5..d4a8a38 100644 --- a/apps/user/app/layout.tsx +++ b/apps/user/app/layout.tsx @@ -64,6 +64,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo try { config = await getGlobalConfig({ skipErrorHandler: true }).then((res) => res.data.data); + console.log(config); } catch (error) { /* empty */ } diff --git a/apps/user/components/header.tsx b/apps/user/components/header.tsx index 46d54c1..47ea04b 100644 --- a/apps/user/components/header.tsx +++ b/apps/user/components/header.tsx @@ -2,11 +2,10 @@ import useGlobalStore from '@/config/use-global'; import { buttonVariants } from '@shadcn/ui/button'; +import { useTranslations } from 'next-intl'; import Image from 'next/legacy/image'; import Link from 'next/link'; import LanguageSwitch from './language-switch'; -// import { MobileSidebar } from './mobile-sidebar'; -import { useTranslations } from 'next-intl'; import ThemeSwitch from './theme-switch'; import { UserNav } from './user-nav'; diff --git a/apps/user/config/use-global.tsx b/apps/user/config/use-global.tsx index b9480b7..fcd6f9d 100644 --- a/apps/user/config/use-global.tsx +++ b/apps/user/config/use-global.tsx @@ -78,7 +78,7 @@ export const useGlobalStore = create((set, get) => ({ const { pan_domain, subscribe_domain, subscribe_path } = get().common.subscribe || {}; const domains = subscribe_domain ? subscribe_domain.split('\n') - : [extractDomain(NEXT_PUBLIC_API_URL || NEXT_PUBLIC_SITE_URL || '')]; + : [extractDomain(NEXT_PUBLIC_API_URL || NEXT_PUBLIC_SITE_URL || '', pan_domain)]; return domains.map((domain) => { const enc_type = type ? Base64.stringify(UTF8.parse(type)) : ''; diff --git a/packages/ui/src/utils/index.ts b/packages/ui/src/utils/index.ts index b2a92a1..2b28e9a 100644 --- a/packages/ui/src/utils/index.ts +++ b/packages/ui/src/utils/index.ts @@ -7,7 +7,7 @@ export * from './unit-conversions'; export const isBrowser = () => typeof window !== 'undefined'; export function getNextResetDate(startDate: Date | number) { - let time = new Date(startDate); + const time = new Date(startDate); const resetDay = time.getDate(); const currentDate = new Date(); if (isNaN(time.getTime())) { @@ -27,21 +27,23 @@ export function getNextResetDate(startDate: Date | number) { } } -export function extractDomain(url: string): string | null { +/** + * Extracts the full domain or root domain from a URL. + * + * @param url - The URL to extract the domain from. + * @param extractRoot - If true, extracts the root domain (e.g., example.com). If false, extracts the full domain (e.g., sub.example.com). + * @returns The extracted domain or root domain, or null if the URL is invalid. + */ +export function extractDomain(url: string, extractRoot = true): string | null { try { - const hostname = new URL(url).hostname; - - if (hostname.match(/^\d{1,3}(\.\d{1,3}){3}$/)) { + const { hostname } = new URL(url); + if (/^\d{1,3}(\.\d{1,3}){3}$/.test(hostname)) { return hostname; } - const domainParts = hostname.split('.').filter(Boolean); - - if (domainParts.length >= 2) { - const topLevelDomain = domainParts.slice(-2).join('.'); - return topLevelDomain; + if (extractRoot && domainParts.length > 2) { + return domainParts.slice(-2).join('.'); } - return hostname; } catch (error) { console.error('Invalid URL:', error);