Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Sidebar.tsx 4.8KB

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