Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

1.5 KB
Raw Blame
import React from 'react'
import { useParams } from 'react-router'
import PageShell from '../components/Layout/PageShell'
import HelpAnchor from '../components/Help/HelpAnchor'
import PluginFrame from '../components/Plugins/PluginFrame'
import { usePluginStore } from '../store/pluginStore'
import { useTranslation } from '../i18n'

/**
 * Full-page host for a `page` plugin (#plugins, M3). Thin by design (no state /
 * effects — the page-pattern rule): it resolves the plugin from the store and
 * renders its sandboxed iframe; PluginFrame owns the bridge.
 */
export default function PluginPage(): React.ReactElement {
  const { pluginId = '' } = useParams()
  const { t } = useTranslation()
  const plugin = usePluginStore((s) => s.getById(pluginId))
  const loaded = usePluginStore((s) => s.loaded)

  if (loaded && (!plugin || plugin.type !== 'page')) {
    return (
      <PageShell background="var(--bg-secondary)">
        <div className="w-full px-6 py-16 text-center text-sm text-content-faint">{t('plugins.notFound')}</div>
      </PageShell>
    )
  }

  return (
    <PageShell background="var(--bg-secondary)" navOffset="var(--nav-h, 56px)">
      <HelpAnchor id="settings-plugins" />
      {/* The phone shell sets --plugin-page-h and its own insets (mobile.css). */}
      <div data-plugin-page style={{ height: 'var(--plugin-page-h, calc(100vh - var(--nav-h, 56px)))' }}>
        <PluginFrame pluginId={pluginId} title={plugin?.name} fill surface="plugin-page" className="w-full h-full" />
      </div>
    </PageShell>
  )
}