Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Sidebar.tsx 4.8KB

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