index.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. 'use client'
  2. import { useTranslation } from 'react-i18next'
  3. import useSWR from 'swr'
  4. import s from './secret-key/style.module.css'
  5. import Doc from '@/app/components/develop/doc'
  6. import InputCopy from '@/app/components/develop/secret-key/input-copy'
  7. import SecretKeyButton from '@/app/components/develop/secret-key/secret-key-button'
  8. import { fetchAppDetail } from '@/service/apps'
  9. type IDevelopMainProps = {
  10. appId: string
  11. }
  12. const DevelopMain = ({ appId }: IDevelopMainProps) => {
  13. const commonParams = { url: '/apps', id: appId }
  14. const { data: appDetail } = useSWR(commonParams, fetchAppDetail)
  15. const { t } = useTranslation()
  16. return (
  17. <div className='relative flex flex-col h-full overflow-hidden'>
  18. <div className='flex items-center justify-between flex-shrink-0 px-6 border-b border-solid py-2 border-b-gray-100'>
  19. <div className='text-lg font-medium text-gray-900'></div>
  20. <div className='flex items-center flex-wrap gap-y-1'>
  21. <InputCopy className='flex-shrink-0 mr-1 w-52 sm:w-80' value={appDetail?.api_base_url}>
  22. <div className={`ml-2 border border-gray-200 border-solid flex-shrink-0 px-2 py-0.5 rounded-[6px] text-gray-500 text-[0.625rem] ${s.customApi}`}>
  23. {t('appApi.apiServer')}
  24. </div>
  25. </InputCopy>
  26. <div className={`flex items-center h-9 px-3 rounded-lg
  27. text-[13px] font-normal mr-2 ${appDetail?.enable_api ? 'text-green-500 bg-green-50' : 'text-yellow-500 bg-yellow-50'}`}>
  28. <div className='mr-1'>{t('appApi.status')}</div>
  29. <div className='font-semibold'>{appDetail?.enable_api ? `${t('appApi.ok')}` : `${t('appApi.disabled')}`}</div>
  30. </div>
  31. <SecretKeyButton className='flex-shrink-0' appId={appId} />
  32. </div>
  33. </div>
  34. <div className='px-4 sm:px-10 py-4 overflow-auto grow'>
  35. <Doc appDetail={appDetail} />
  36. </div>
  37. </div>
  38. )
  39. }
  40. export default DevelopMain