PHP 8.2.30
Preview: page.tsx Size: 1.60 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/adminjs/src/frontend/components/routes/page.tsx

import { InfoBox, Text } from '@adminjs/design-system'
import React, { FC, useMemo } from 'react'
import { Trans } from 'react-i18next'
import { useSelector } from 'react-redux'
import { useParams } from 'react-router'

import allowOverride from '../../hoc/allow-override.js'
import withNoSSR from '../../hoc/with-no-ssr.js'
import { useTranslation } from '../../hooks/index.js'
import { ReduxState } from '../../store/store.js'
import ErrorBoundary from '../app/error-boundary.js'

declare const AdminJS: {
  UserComponents: Record<string, FC>;
}

type PageRouteProps = {
  pageName: string;
}

const Page: FC = () => {
  const pages = useSelector((state: ReduxState) => state.pages)
  const params = useParams<PageRouteProps>()
  const { pageName } = params
  const { tm } = useTranslation()

  const currentPage = useMemo(() => pages.find(({ name }) => name === pageName), [pages, pageName])

  if (!currentPage) {
    return (
      <InfoBox title={tm('pageNotFound_title')} illustration="NotFound">
        <Text mb="xxl">
          <Trans i18nKey="messages.pageNotFound_subtitle" values={{ pageName }} components={{ strong: <strong /> }} />
        </Text>
      </InfoBox>
    )
  }

  const Component = AdminJS.UserComponents[currentPage.component]

  if (!Component) {
    return (
      <InfoBox title={tm('componentNotFound_title')} illustration="Beware">
        <Text mb="xxl">
          <Trans i18nKey="messages.componentNotFound_subtitle" />
        </Text>
      </InfoBox>
    )
  }

  return (
    <ErrorBoundary>
      <Component />
    </ErrorBoundary>
  )
}

export default allowOverride(withNoSSR(Page), 'PageRoute')

Directory Contents

Dirs: 1 × Files: 8

Name Size Perms Modified Actions
utils DIR
- drwxr-xr-x 2026-02-28 00:32:50
Edit Download
4.63 KB lrw-r--r-- 2026-02-28 00:32:46
Edit Download
1.37 KB lrw-r--r-- 2026-02-28 00:32:46
Edit Download
363 B lrw-r--r-- 2026-02-28 00:32:28
Edit Download
1.60 KB lrw-r--r-- 2026-02-28 00:32:48
Edit Download
2.12 KB lrw-r--r-- 2026-02-28 00:32:48
Edit Download
5.85 KB lrw-r--r-- 2026-02-28 00:32:48
Edit Download
3.47 KB lrw-r--r-- 2026-02-28 00:32:48
Edit Download
3.26 KB lrw-r--r-- 2026-02-28 00:32:48
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).