index.tsx 4.5 KB

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