index.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import { useRouter } from 'next/navigation'
  6. import Log from '@/app/components/app/log'
  7. import Annotation from '@/app/components/app/annotation'
  8. import { PageType } from '@/app/components/app/configuration/toolbox/annotation/type'
  9. import TabSlider from '@/app/components/base/tab-slider-plain'
  10. type Props = {
  11. pageType: PageType
  12. appId: string
  13. }
  14. const LogAnnotation: FC<Props> = ({
  15. pageType,
  16. appId,
  17. }) => {
  18. const { t } = useTranslation()
  19. const router = useRouter()
  20. const options = [
  21. { value: PageType.log, text: t('appLog.title') },
  22. { value: PageType.annotation, text: t('appAnnotation.title') },
  23. ]
  24. return (
  25. <div className='pt-4 px-6 h-full flex flex-col'>
  26. <TabSlider
  27. className='shrink-0'
  28. value={pageType}
  29. onChange={(value) => {
  30. router.push(`/app/${appId}/${value === PageType.log ? 'logs' : 'annotations'}`)
  31. }}
  32. options={options}
  33. />
  34. <div className='mt-3 grow'>
  35. {pageType === PageType.log && (<Log appId={appId} />)}
  36. {pageType === PageType.annotation && (<Annotation appId={appId} />)}
  37. </div>
  38. </div>
  39. )
  40. }
  41. export default React.memo(LogAnnotation)