You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Sidebar.tsx 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. 'use client'
  2. import { Drawer, Menu, Divider, Avatar, Typography } from 'antd'
  3. import {
  4. HomeOutlined,
  5. MessageOutlined,
  6. UserOutlined,
  7. BookOutlined,
  8. ApiOutlined,
  9. WalletOutlined,
  10. SettingOutlined,
  11. QuestionCircleOutlined,
  12. LogoutOutlined,
  13. LeftOutlined
  14. } from '@ant-design/icons'
  15. import { useRouter } from 'next/navigation'
  16. import type { SidebarProps } from '@/types/sidebar'
  17. const { Text } = Typography
  18. const Sidebar = ({ open = false, setOpen = () => { } }: SidebarProps) => {
  19. const router = useRouter()
  20. const handleClick = (e: { key: string }) => {
  21. router.push(e.key)
  22. setOpen(false)
  23. }
  24. return (
  25. <Drawer
  26. placement="left"
  27. closable={false}
  28. onClose={() => setOpen(false)}
  29. open={open}
  30. width={250}
  31. mask={false}
  32. styles={{
  33. body: {
  34. padding: "0 10px",
  35. },
  36. }}
  37. >
  38. {/* Custom Close Button */}
  39. <button
  40. className="p-2 bg-white hover:bg-gray-100 rounded shadow text-xs cursor-pointer"
  41. onClick={() => {
  42. setOpen(false)
  43. }}
  44. style={{
  45. position: 'absolute',
  46. top: 30,
  47. right: -20,
  48. }}
  49. >
  50. <LeftOutlined />
  51. </button>
  52. {/* Top: Avatar/Profile */}
  53. <div className="flex items-center gap-3 px-4 py-4 border-b border-gray-200">
  54. <Avatar size="large" icon={<UserOutlined />} />
  55. <div>
  56. <div className="text-xs text-gray-500">PRODUCT MANAGER</div>
  57. <Text strong>Amirul Baharuddin</Text>
  58. </div>
  59. </div>
  60. {/* Main Menu */}
  61. <div className='border-b border-gray-200'>
  62. <p className='px-7 pt-3 text-gray-500 text-xs text-bold'>MAIN</p>
  63. <Menu
  64. mode="inline"
  65. onClick={handleClick}
  66. items={[
  67. {
  68. key: '/dashboard',
  69. icon: <HomeOutlined />,
  70. label: 'Dashboard',
  71. },
  72. {
  73. key: '/chat',
  74. icon: <MessageOutlined />,
  75. label: 'Ruccan Chat',
  76. },
  77. {
  78. key: '/persona',
  79. icon: <UserOutlined />,
  80. label: 'Persona',
  81. },
  82. {
  83. key: '/knowledge',
  84. icon: <BookOutlined />,
  85. label: 'Knowledge',
  86. },
  87. {
  88. key: '/integration',
  89. icon: <ApiOutlined />,
  90. label: 'Integration',
  91. },
  92. {
  93. key: '/wallet',
  94. icon: <WalletOutlined />,
  95. label: 'Wallet',
  96. },
  97. ]}
  98. />
  99. </div>
  100. {/* Settings & Others */}
  101. <div>
  102. <p className='px-7 pt-3 text-gray-500 text-xs text-bold'>SETTINGS</p>
  103. <Menu
  104. mode="inline"
  105. onClick={handleClick}
  106. items={[
  107. {
  108. key: 'settings-parent',
  109. icon: <SettingOutlined />,
  110. label: 'Settings',
  111. children: [
  112. {
  113. key: '/settings/general',
  114. icon: <SettingOutlined />, // General settings still makes sense
  115. label: 'General',
  116. },
  117. {
  118. key: '/settings/profile',
  119. icon: <UserOutlined />, // Profile = user-related
  120. label: 'Profile',
  121. },
  122. {
  123. key: '/settings/chat-preference',
  124. icon: <MessageOutlined />, // Chat preference = chat/message
  125. label: 'Chat Preference',
  126. }
  127. ]
  128. }
  129. ]}
  130. />
  131. </div>
  132. <div>
  133. <Menu
  134. mode="inline"
  135. onClick={handleClick}
  136. style={{ position: "absolute", bottom: 0, left: 0 }}
  137. items={[
  138. {
  139. key: '/help',
  140. icon: <QuestionCircleOutlined />,
  141. label: 'Help',
  142. },
  143. {
  144. key: '/logout',
  145. icon: <LogoutOutlined style={{ color: "red" }} />,
  146. label: <p className='text-red-400 font-bold'>Logout</p>,
  147. },
  148. ]}
  149. />
  150. </div>
  151. </Drawer>
  152. )
  153. }
  154. export default Sidebar