'use client' import { useEffect, useState } from 'react' import { usePathname } from 'next/navigation' import { useMarketplacePreferences } from './MarketplaceShell' type FrameId = 'dashboard' | 'admin' | 'public-site' const frameConfig: Record = { dashboard: { label: 'Company Workspace', port: 3001, path: '/sign-in', }, admin: { label: 'Platform Operations', port: 3002, path: '/', }, 'public-site': { label: 'Branded Website', port: 3003, path: '/', }, } function withPort(port: number, path: string) { if (typeof window === 'undefined') return path const url = new URL(window.location.href) url.port = String(port) url.pathname = path url.search = '' url.hash = '' return url.toString() } export default function WorkspaceFrame({ target }: { target: FrameId }) { const pathname = usePathname() const { language } = useMarketplacePreferences() const [src, setSrc] = useState('') const config = frameConfig[target] const fillViewport = pathname === '/company-workspace' const frameHeight = fillViewport ? '100vh' : 'calc(100vh - 56px)' const loadingLabel = { en: 'Loading', fr: 'Chargement de', ar: 'جارٍ تحميل', }[language] useEffect(() => { setSrc(withPort(config.port, config.path)) }, [config.path, config.port]) return (
{src ? (