index.tsx 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. 'use client'
  2. import { useTranslation } from 'react-i18next'
  3. import { useState } from 'react'
  4. import { AtSymbolIcon, CubeTransparentIcon, GlobeAltIcon, UserIcon, UsersIcon, XMarkIcon } from '@heroicons/react/24/outline'
  5. import { GlobeAltIcon as GlobalAltIconSolid, UserIcon as UserIconSolid, UsersIcon as UsersIconSolid } from '@heroicons/react/24/solid'
  6. import AccountPage from './account-page'
  7. import MembersPage from './members-page'
  8. import IntegrationsPage from './Integrations-page'
  9. import LanguagePage from './language-page'
  10. import ProviderPage from './provider-page'
  11. import DataSourcePage from './data-source-page'
  12. import s from './index.module.css'
  13. import Modal from '@/app/components/base/modal'
  14. import { Database03 } from '@/app/components/base/icons/src/vender/line/development'
  15. import { Database03 as Database03Solid } from '@/app/components/base/icons/src/vender/solid/development'
  16. const iconClassName = `
  17. w-4 h-4 ml-3 mr-2
  18. `
  19. type IAccountSettingProps = {
  20. onCancel: () => void
  21. activeTab?: string
  22. }
  23. export default function AccountSetting({
  24. onCancel,
  25. activeTab = 'account',
  26. }: IAccountSettingProps) {
  27. const [activeMenu, setActiveMenu] = useState(activeTab)
  28. const { t } = useTranslation()
  29. const menuItems = [
  30. {
  31. key: 'account-group',
  32. name: t('common.settings.accountGroup'),
  33. items: [
  34. {
  35. key: 'account',
  36. name: t('common.settings.account'),
  37. icon: <UserIcon className={iconClassName} />,
  38. activeIcon: <UserIconSolid className={iconClassName} />,
  39. },
  40. {
  41. key: 'integrations',
  42. name: t('common.settings.integrations'),
  43. icon: <AtSymbolIcon className={iconClassName} />,
  44. activeIcon: <AtSymbolIcon className={iconClassName} />,
  45. },
  46. {
  47. key: 'language',
  48. name: t('common.settings.language'),
  49. icon: <GlobeAltIcon className={iconClassName} />,
  50. activeIcon: <GlobalAltIconSolid className={iconClassName} />,
  51. },
  52. ],
  53. },
  54. {
  55. key: 'workspace-group',
  56. name: t('common.settings.workplaceGroup'),
  57. items: [
  58. {
  59. key: 'members',
  60. name: t('common.settings.members'),
  61. icon: <UsersIcon className={iconClassName} />,
  62. activeIcon: <UsersIconSolid className={iconClassName} />,
  63. },
  64. {
  65. key: 'provider',
  66. name: t('common.settings.provider'),
  67. icon: <CubeTransparentIcon className={iconClassName} />,
  68. activeIcon: <CubeTransparentIcon className={iconClassName} />,
  69. },
  70. {
  71. key: 'data-source',
  72. name: t('common.settings.dataSource'),
  73. icon: <Database03 className={iconClassName} />,
  74. activeIcon: <Database03Solid className={iconClassName} />,
  75. },
  76. ],
  77. },
  78. ]
  79. return (
  80. <Modal
  81. isShow
  82. onClose={() => { }}
  83. className={s.modal}
  84. wrapperClassName='pt-[60px]'
  85. >
  86. <div className='flex'>
  87. <div className='w-[200px] p-4 border border-gray-100'>
  88. <div className='mb-8 ml-2 text-base font-medium leading-6 text-gray-900'>{t('common.userProfile.settings')}</div>
  89. <div>
  90. {
  91. menuItems.map(menuItem => (
  92. <div key={menuItem.key} className='mb-4'>
  93. <div className='px-2 mb-[6px] text-xs font-medium text-gray-500'>{menuItem.name}</div>
  94. <div>
  95. {
  96. menuItem.items.map(item => (
  97. <div
  98. key={item.key}
  99. className={`
  100. flex items-center h-[37px] mb-[2px] text-sm cursor-pointer rounded-lg
  101. ${activeMenu === item.key ? 'font-semibold text-primary-600 bg-primary-50' : 'font-light text-gray-700'}
  102. `}
  103. onClick={() => setActiveMenu(item.key)}
  104. >
  105. {activeMenu === item.key ? item.activeIcon : item.icon}{item.name}
  106. </div>
  107. ))
  108. }
  109. </div>
  110. </div>
  111. ))
  112. }
  113. </div>
  114. </div>
  115. <div className='w-[520px] h-[580px] px-6 py-4 overflow-y-auto'>
  116. <div className='flex items-center justify-between h-6 mb-8 text-base font-medium text-gray-900 '>
  117. {[...menuItems[0].items, ...menuItems[1].items].find(item => item.key === activeMenu)?.name}
  118. <XMarkIcon className='w-4 h-4 cursor-pointer' onClick={onCancel} />
  119. </div>
  120. {
  121. activeMenu === 'account' && <AccountPage />
  122. }
  123. {
  124. activeMenu === 'members' && <MembersPage />
  125. }
  126. {
  127. activeMenu === 'integrations' && <IntegrationsPage />
  128. }
  129. {
  130. activeMenu === 'language' && <LanguagePage />
  131. }
  132. {
  133. activeMenu === 'provider' && <ProviderPage />
  134. }
  135. {
  136. activeMenu === 'data-source' && <DataSourcePage />
  137. }
  138. </div>
  139. </div>
  140. </Modal>
  141. )
  142. }