index.tsx 2.1 KB

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