index.tsx 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. 'use client'
  2. import { useTranslation } from 'react-i18next'
  3. import useSWR from 'swr'
  4. import Link from 'next/link'
  5. import s from './index.module.css'
  6. import classNames from '@/utils/classnames'
  7. import { fetchAccountIntegrates } from '@/service/common'
  8. const titleClassName = `
  9. mb-2 text-sm font-medium text-gray-900
  10. `
  11. export default function IntegrationsPage() {
  12. const { t } = useTranslation()
  13. const integrateMap = {
  14. google: {
  15. name: t('common.integrations.google'),
  16. description: t('common.integrations.googleAccount'),
  17. },
  18. github: {
  19. name: t('common.integrations.github'),
  20. description: t('common.integrations.githubAccount'),
  21. },
  22. }
  23. const { data } = useSWR({ url: '/account/integrates' }, fetchAccountIntegrates)
  24. const integrates = data?.data?.length ? data.data : []
  25. return (
  26. <>
  27. <div className='mb-8'>
  28. <div className={titleClassName}>{t('common.integrations.connected')}</div>
  29. {
  30. integrates.map(integrate => (
  31. <div key={integrate.provider} className='mb-2 flex items-center px-3 py-2 bg-gray-50 border-[0.5px] border-gray-200 rounded-lg'>
  32. <div className={classNames('w-8 h-8 mr-3 bg-white rounded-lg border border-gray-100', s[`${integrate.provider}-icon`])} />
  33. <div className='grow'>
  34. <div className='leading-[21px] text-sm font-medium text-gray-800'>{integrateMap[integrate.provider].name}</div>
  35. <div className='leading-[18px] text-xs font-normal text-gray-500'>{integrateMap[integrate.provider].description}</div>
  36. </div>
  37. {
  38. !integrate.is_bound && (
  39. <Link
  40. className='flex items-center h-8 px-[7px] bg-white rounded-lg border border-gray-200 text-xs font-medium text-gray-700 cursor-pointer'
  41. href={integrate.link}
  42. target='_blank' rel='noopener noreferrer'>
  43. {t('common.integrations.connect')}
  44. </Link>
  45. )
  46. }
  47. </div>
  48. ))
  49. }
  50. </div>
  51. {/* <div className='mb-8'>
  52. <div className={titleClassName}>Add a service </div>
  53. {
  54. services.map(service => (
  55. <div key={service.key} className='mb-2 flex items-center px-3 py-2 bg-gray-50 border-[0.5px] border-gray-200 rounded-lg'>
  56. <div className={classNames('w-8 h-8 mr-3 bg-white rounded-lg border border-gray-100', s[`${service.key}-icon`])} />
  57. <div className='grow'>
  58. <div className='leading-[21px] text-sm font-medium text-gray-800'>{service.name}</div>
  59. <div className='leading-[18px] text-xs font-normal text-gray-500'>{service.description}</div>
  60. </div>
  61. <Button className='text-xs font-medium text-gray-800'>Connect</Button>
  62. </div>
  63. ))
  64. }
  65. </div> */}
  66. </>
  67. )
  68. }