vuchat 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/.github/workflows/publish.yaml +25 -0
  2. package/.yarnrc.yml +2 -0
  3. package/Readme.md +21 -0
  4. package/custom.d.ts +6 -0
  5. package/dist/cjs/index.js +399 -0
  6. package/dist/cjs/index.js.map +1 -0
  7. package/dist/cjs/types/components/Buttons/VuButton.d.ts +6 -0
  8. package/dist/cjs/types/components/Buttons/VuIconButton.d.ts +12 -0
  9. package/dist/cjs/types/components/Buttons/index.d.ts +2 -0
  10. package/dist/cjs/types/components/Buttons/styled.d.ts +5 -0
  11. package/dist/cjs/types/components/Buttons/types.d.ts +13 -0
  12. package/dist/cjs/types/components/ErrorComponent/index.d.ts +7 -0
  13. package/dist/cjs/types/components/ErrorComponent/styled.d.ts +5 -0
  14. package/dist/cjs/types/components/Header/index.d.ts +6 -0
  15. package/dist/cjs/types/components/Header/styled.d.ts +3 -0
  16. package/dist/cjs/types/components/Icons/VuIcon.d.ts +8 -0
  17. package/dist/cjs/types/components/Icons/index.d.ts +1 -0
  18. package/dist/cjs/types/components/SearchInput/SearchInput.d.ts +5 -0
  19. package/dist/cjs/types/components/SearchInput/index.d.ts +1 -0
  20. package/dist/cjs/types/components/SearchInput/styled.d.ts +7 -0
  21. package/dist/cjs/types/components/TextArea/VuTextArea.d.ts +7 -0
  22. package/dist/cjs/types/components/TextArea/index.d.ts +1 -0
  23. package/dist/cjs/types/components/TextArea/styled.d.ts +8 -0
  24. package/dist/cjs/types/components/api/api.d.ts +9 -0
  25. package/dist/cjs/types/components/api/axiosInstance.d.ts +29 -0
  26. package/dist/cjs/types/components/api/types.d.ts +27 -0
  27. package/dist/cjs/types/components/index.d.ts +5 -0
  28. package/dist/cjs/types/index.d.ts +2 -0
  29. package/dist/cjs/types/pages/VuChat.d.ts +8 -0
  30. package/dist/cjs/types/pages/chatbot/Chatbot.d.ts +6 -0
  31. package/dist/cjs/types/pages/chatbot/components/ChatSection/ChatSection.d.ts +10 -0
  32. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/ActionButtons/ActionButtons.d.ts +6 -0
  33. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/ActionButtons/styled.d.ts +2 -0
  34. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/Charts/Charts.d.ts +9 -0
  35. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/Charts/styled.d.ts +4 -0
  36. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/EmptyState/EmptyState.d.ts +3 -0
  37. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/EmptyState/styled.d.ts +4 -0
  38. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/QuestionCard/QuestionCard.d.ts +6 -0
  39. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/QuestionCard/styled.d.ts +4 -0
  40. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/ResponseCard/ResponseCard.d.ts +11 -0
  41. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/ResponseCard/styled.d.ts +8 -0
  42. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/ResponseLoader/ResponseLoader.d.ts +3 -0
  43. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/ResponseLoader/styled.d.ts +4 -0
  44. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/SuggestedQuestions/SuggestedQuestions.d.ts +3 -0
  45. package/dist/cjs/types/pages/chatbot/components/ChatSection/components/SuggestedQuestions/styled.d.ts +2 -0
  46. package/dist/cjs/types/pages/chatbot/components/ChatSection/styled.d.ts +5 -0
  47. package/dist/cjs/types/pages/chatbot/components/RecentConversations/RecentConversations.d.ts +9 -0
  48. package/dist/cjs/types/pages/chatbot/components/RecentConversations/questions.d.ts +1 -0
  49. package/dist/cjs/types/pages/chatbot/components/RecentConversations/styled.d.ts +11 -0
  50. package/dist/cjs/types/pages/chatbot/index.d.ts +1 -0
  51. package/dist/cjs/types/pages/chatbot/styled.d.ts +14 -0
  52. package/dist/cjs/types/pages/index.d.ts +1 -0
  53. package/dist/cjs/types/pages/styled.d.ts +2 -0
  54. package/dist/cjs/types/utils/icons.d.ts +1 -0
  55. package/dist/cjs/types/utils/iconsList.d.ts +2 -0
  56. package/dist/cjs/types/utils/index.d.ts +2 -0
  57. package/dist/esm/index.js +399 -0
  58. package/dist/esm/index.js.map +1 -0
  59. package/dist/esm/types/components/Buttons/VuButton.d.ts +6 -0
  60. package/dist/esm/types/components/Buttons/VuIconButton.d.ts +12 -0
  61. package/dist/esm/types/components/Buttons/index.d.ts +2 -0
  62. package/dist/esm/types/components/Buttons/styled.d.ts +5 -0
  63. package/dist/esm/types/components/Buttons/types.d.ts +13 -0
  64. package/dist/esm/types/components/ErrorComponent/index.d.ts +7 -0
  65. package/dist/esm/types/components/ErrorComponent/styled.d.ts +5 -0
  66. package/dist/esm/types/components/Header/index.d.ts +6 -0
  67. package/dist/esm/types/components/Header/styled.d.ts +3 -0
  68. package/dist/esm/types/components/Icons/VuIcon.d.ts +8 -0
  69. package/dist/esm/types/components/Icons/index.d.ts +1 -0
  70. package/dist/esm/types/components/SearchInput/SearchInput.d.ts +5 -0
  71. package/dist/esm/types/components/SearchInput/index.d.ts +1 -0
  72. package/dist/esm/types/components/SearchInput/styled.d.ts +7 -0
  73. package/dist/esm/types/components/TextArea/VuTextArea.d.ts +7 -0
  74. package/dist/esm/types/components/TextArea/index.d.ts +1 -0
  75. package/dist/esm/types/components/TextArea/styled.d.ts +8 -0
  76. package/dist/esm/types/components/api/api.d.ts +9 -0
  77. package/dist/esm/types/components/api/axiosInstance.d.ts +29 -0
  78. package/dist/esm/types/components/api/types.d.ts +27 -0
  79. package/dist/esm/types/components/index.d.ts +5 -0
  80. package/dist/esm/types/index.d.ts +2 -0
  81. package/dist/esm/types/pages/VuChat.d.ts +8 -0
  82. package/dist/esm/types/pages/chatbot/Chatbot.d.ts +6 -0
  83. package/dist/esm/types/pages/chatbot/components/ChatSection/ChatSection.d.ts +10 -0
  84. package/dist/esm/types/pages/chatbot/components/ChatSection/components/ActionButtons/ActionButtons.d.ts +6 -0
  85. package/dist/esm/types/pages/chatbot/components/ChatSection/components/ActionButtons/styled.d.ts +2 -0
  86. package/dist/esm/types/pages/chatbot/components/ChatSection/components/Charts/Charts.d.ts +9 -0
  87. package/dist/esm/types/pages/chatbot/components/ChatSection/components/Charts/styled.d.ts +4 -0
  88. package/dist/esm/types/pages/chatbot/components/ChatSection/components/EmptyState/EmptyState.d.ts +3 -0
  89. package/dist/esm/types/pages/chatbot/components/ChatSection/components/EmptyState/styled.d.ts +4 -0
  90. package/dist/esm/types/pages/chatbot/components/ChatSection/components/QuestionCard/QuestionCard.d.ts +6 -0
  91. package/dist/esm/types/pages/chatbot/components/ChatSection/components/QuestionCard/styled.d.ts +4 -0
  92. package/dist/esm/types/pages/chatbot/components/ChatSection/components/ResponseCard/ResponseCard.d.ts +11 -0
  93. package/dist/esm/types/pages/chatbot/components/ChatSection/components/ResponseCard/styled.d.ts +8 -0
  94. package/dist/esm/types/pages/chatbot/components/ChatSection/components/ResponseLoader/ResponseLoader.d.ts +3 -0
  95. package/dist/esm/types/pages/chatbot/components/ChatSection/components/ResponseLoader/styled.d.ts +4 -0
  96. package/dist/esm/types/pages/chatbot/components/ChatSection/components/SuggestedQuestions/SuggestedQuestions.d.ts +3 -0
  97. package/dist/esm/types/pages/chatbot/components/ChatSection/components/SuggestedQuestions/styled.d.ts +2 -0
  98. package/dist/esm/types/pages/chatbot/components/ChatSection/styled.d.ts +5 -0
  99. package/dist/esm/types/pages/chatbot/components/RecentConversations/RecentConversations.d.ts +9 -0
  100. package/dist/esm/types/pages/chatbot/components/RecentConversations/questions.d.ts +1 -0
  101. package/dist/esm/types/pages/chatbot/components/RecentConversations/styled.d.ts +11 -0
  102. package/dist/esm/types/pages/chatbot/index.d.ts +1 -0
  103. package/dist/esm/types/pages/chatbot/styled.d.ts +14 -0
  104. package/dist/esm/types/pages/index.d.ts +1 -0
  105. package/dist/esm/types/pages/styled.d.ts +2 -0
  106. package/dist/esm/types/utils/icons.d.ts +1 -0
  107. package/dist/esm/types/utils/iconsList.d.ts +2 -0
  108. package/dist/esm/types/utils/index.d.ts +2 -0
  109. package/dist/types/components/Buttons/VuButton.d.ts +6 -0
  110. package/dist/types/components/Buttons/VuIconButton.d.ts +12 -0
  111. package/dist/types/components/Buttons/index.d.ts +2 -0
  112. package/dist/types/components/Buttons/styled.d.ts +5 -0
  113. package/dist/types/components/Buttons/types.d.ts +13 -0
  114. package/dist/types/components/ErrorComponent/index.d.ts +7 -0
  115. package/dist/types/components/ErrorComponent/styled.d.ts +5 -0
  116. package/dist/types/components/Header/index.d.ts +6 -0
  117. package/dist/types/components/Header/styled.d.ts +3 -0
  118. package/dist/types/components/Icons/VuIcon.d.ts +8 -0
  119. package/dist/types/components/Icons/index.d.ts +1 -0
  120. package/dist/types/components/SearchInput/SearchInput.d.ts +5 -0
  121. package/dist/types/components/SearchInput/index.d.ts +1 -0
  122. package/dist/types/components/SearchInput/styled.d.ts +7 -0
  123. package/dist/types/components/TextArea/VuTextArea.d.ts +7 -0
  124. package/dist/types/components/TextArea/index.d.ts +1 -0
  125. package/dist/types/components/TextArea/styled.d.ts +8 -0
  126. package/dist/types/components/api/api.d.ts +9 -0
  127. package/dist/types/components/api/axiosInstance.d.ts +29 -0
  128. package/dist/types/components/api/types.d.ts +27 -0
  129. package/dist/types/components/index.d.ts +5 -0
  130. package/dist/types/index.d.ts +2 -0
  131. package/dist/types/pages/VuChat.d.ts +8 -0
  132. package/dist/types/pages/chatbot/Chatbot.d.ts +6 -0
  133. package/dist/types/pages/chatbot/components/ChatSection/ChatSection.d.ts +10 -0
  134. package/dist/types/pages/chatbot/components/ChatSection/components/ActionButtons/ActionButtons.d.ts +6 -0
  135. package/dist/types/pages/chatbot/components/ChatSection/components/ActionButtons/styled.d.ts +2 -0
  136. package/dist/types/pages/chatbot/components/ChatSection/components/Charts/Charts.d.ts +9 -0
  137. package/dist/types/pages/chatbot/components/ChatSection/components/Charts/styled.d.ts +4 -0
  138. package/dist/types/pages/chatbot/components/ChatSection/components/EmptyState/EmptyState.d.ts +3 -0
  139. package/dist/types/pages/chatbot/components/ChatSection/components/EmptyState/styled.d.ts +4 -0
  140. package/dist/types/pages/chatbot/components/ChatSection/components/QuestionCard/QuestionCard.d.ts +6 -0
  141. package/dist/types/pages/chatbot/components/ChatSection/components/QuestionCard/styled.d.ts +4 -0
  142. package/dist/types/pages/chatbot/components/ChatSection/components/ResponseCard/ResponseCard.d.ts +11 -0
  143. package/dist/types/pages/chatbot/components/ChatSection/components/ResponseCard/styled.d.ts +8 -0
  144. package/dist/types/pages/chatbot/components/ChatSection/components/ResponseLoader/ResponseLoader.d.ts +3 -0
  145. package/dist/types/pages/chatbot/components/ChatSection/components/ResponseLoader/styled.d.ts +4 -0
  146. package/dist/types/pages/chatbot/components/ChatSection/components/SuggestedQuestions/SuggestedQuestions.d.ts +3 -0
  147. package/dist/types/pages/chatbot/components/ChatSection/components/SuggestedQuestions/styled.d.ts +2 -0
  148. package/dist/types/pages/chatbot/components/ChatSection/styled.d.ts +5 -0
  149. package/dist/types/pages/chatbot/components/RecentConversations/RecentConversations.d.ts +9 -0
  150. package/dist/types/pages/chatbot/components/RecentConversations/questions.d.ts +1 -0
  151. package/dist/types/pages/chatbot/components/RecentConversations/styled.d.ts +11 -0
  152. package/dist/types/pages/chatbot/index.d.ts +1 -0
  153. package/dist/types/pages/chatbot/styled.d.ts +14 -0
  154. package/dist/types/pages/index.d.ts +1 -0
  155. package/dist/types/pages/styled.d.ts +2 -0
  156. package/dist/types/utils/icons.d.ts +1 -0
  157. package/dist/types/utils/iconsList.d.ts +2 -0
  158. package/dist/types/utils/index.d.ts +2 -0
  159. package/dist/types.d.ts +14 -0
  160. package/package.json +56 -0
  161. package/postcss.config.ts +6 -0
  162. package/rollup.config-1696564443080.cjs +67 -0
  163. package/rollup.config.ts +67 -0
  164. package/src/assets/icons/add.svg +1 -0
  165. package/src/assets/icons/arrow-left.svg +1 -0
  166. package/src/assets/icons/bot.svg +35 -0
  167. package/src/assets/icons/bot1.svg +1 -0
  168. package/src/assets/icons/copy.svg +1 -0
  169. package/src/assets/icons/delete.svg +1 -0
  170. package/src/assets/icons/download.svg +8 -0
  171. package/src/assets/icons/error.svg +12 -0
  172. package/src/assets/icons/load.svg +5 -0
  173. package/src/assets/icons/message.svg +4 -0
  174. package/src/assets/icons/search.svg +1 -0
  175. package/src/assets/icons/send.svg +11 -0
  176. package/src/assets/icons/thumbs-down.svg +1 -0
  177. package/src/assets/icons/thumbs-up.svg +1 -0
  178. package/src/assets/icons/user.svg +12 -0
  179. package/src/components/Buttons/VuButton.tsx +26 -0
  180. package/src/components/Buttons/VuIconButton.tsx +31 -0
  181. package/src/components/Buttons/index.ts +2 -0
  182. package/src/components/Buttons/styled.ts +63 -0
  183. package/src/components/Buttons/types.ts +17 -0
  184. package/src/components/ErrorComponent/index.tsx +23 -0
  185. package/src/components/ErrorComponent/styled.ts +28 -0
  186. package/src/components/Header/index.tsx +35 -0
  187. package/src/components/Header/styled.ts +12 -0
  188. package/src/components/Icons/VuIcon.tsx +30 -0
  189. package/src/components/Icons/index.ts +1 -0
  190. package/src/components/SearchInput/SearchInput.tsx +21 -0
  191. package/src/components/SearchInput/index.ts +1 -0
  192. package/src/components/SearchInput/styled.ts +25 -0
  193. package/src/components/TextArea/VuTextArea.tsx +39 -0
  194. package/src/components/TextArea/index.ts +1 -0
  195. package/src/components/TextArea/styled.ts +39 -0
  196. package/src/components/api/api.ts +51 -0
  197. package/src/components/api/axiosInstance.ts +5 -0
  198. package/src/components/api/types.ts +31 -0
  199. package/src/components/index.ts +5 -0
  200. package/src/index.css +3 -0
  201. package/src/index.ts +2 -0
  202. package/src/pages/VuChat.tsx +36 -0
  203. package/src/pages/chatbot/Chatbot.tsx +171 -0
  204. package/src/pages/chatbot/components/ChatSection/ChatSection.tsx +201 -0
  205. package/src/pages/chatbot/components/ChatSection/components/ActionButtons/ActionButtons.tsx +30 -0
  206. package/src/pages/chatbot/components/ChatSection/components/ActionButtons/styled.ts +10 -0
  207. package/src/pages/chatbot/components/ChatSection/components/Charts/Charts.tsx +81 -0
  208. package/src/pages/chatbot/components/ChatSection/components/Charts/styled.ts +25 -0
  209. package/src/pages/chatbot/components/ChatSection/components/EmptyState/EmptyState.tsx +26 -0
  210. package/src/pages/chatbot/components/ChatSection/components/EmptyState/styled.ts +27 -0
  211. package/src/pages/chatbot/components/ChatSection/components/QuestionCard/QuestionCard.tsx +21 -0
  212. package/src/pages/chatbot/components/ChatSection/components/QuestionCard/styled.ts +20 -0
  213. package/src/pages/chatbot/components/ChatSection/components/ResponseCard/ResponseCard.tsx +181 -0
  214. package/src/pages/chatbot/components/ChatSection/components/ResponseCard/styled.ts +44 -0
  215. package/src/pages/chatbot/components/ChatSection/components/ResponseLoader/ResponseLoader.tsx +23 -0
  216. package/src/pages/chatbot/components/ChatSection/components/ResponseLoader/styled.ts +23 -0
  217. package/src/pages/chatbot/components/ChatSection/components/SuggestedQuestions/SuggestedQuestions.tsx +18 -0
  218. package/src/pages/chatbot/components/ChatSection/components/SuggestedQuestions/styled.ts +12 -0
  219. package/src/pages/chatbot/components/ChatSection/styled.ts +27 -0
  220. package/src/pages/chatbot/components/RecentConversations/RecentConversations.tsx +129 -0
  221. package/src/pages/chatbot/components/RecentConversations/questions.ts +24 -0
  222. package/src/pages/chatbot/components/RecentConversations/styled.ts +49 -0
  223. package/src/pages/chatbot/index.ts +1 -0
  224. package/src/pages/chatbot/styled.ts +77 -0
  225. package/src/pages/index.ts +1 -0
  226. package/src/pages/styled.ts +9 -0
  227. package/src/utils/icons.ts +3 -0
  228. package/src/utils/iconsList.tsx +14 -0
  229. package/src/utils/index.ts +2 -0
  230. package/tailwind.config.ts +18 -0
  231. package/tsconfig.json +20 -0
@@ -0,0 +1,181 @@
1
+ import { useRef, useState } from "react";
2
+ import { VuIcon } from "../../../../../../components/Icons/VuIcon";
3
+ import {
4
+ ChartContainer,
5
+ Container,
6
+ ErrorContainer,
7
+ ResponseContainer,
8
+ SideButtonsContainer,
9
+ TextContainer,
10
+ TimeContainer,
11
+ } from "./styled";
12
+
13
+ import { VuIconButton } from "../../../../../../components/Buttons";
14
+ import React from "react";
15
+ import BotIcon from "../../../../../../assets/icons/bot.svg";
16
+ import CopyIcon from "../../../../../../assets/icons/copy.svg";
17
+ import ThumbsUpIcon from "../../../../../../assets/icons/thumbs-up.svg";
18
+ import ThumbsDownIcon from "../../../../../../assets/icons/thumbs-down.svg";
19
+ import { Charts } from "../Charts/Charts";
20
+ import { Tooltip } from "react-tooltip";
21
+ import { useMutation } from "react-query";
22
+ import { likeDislikeChat } from "../../../../../../components/api/api";
23
+
24
+ // Keeping this data for future reference.
25
+
26
+ /* const pieData = {
27
+ labels: ["Red", "Blue", "Yellow"],
28
+ datasets: [
29
+ {
30
+ label: "My First Dataset",
31
+ data: [300, 50, 100],
32
+ backgroundColor: [
33
+ "rgb(255, 99, 132)",
34
+ "rgb(54, 162, 235)",
35
+ "rgb(255, 205, 86)",
36
+ ],
37
+ hoverOffset: 4,
38
+ },
39
+ ],
40
+ }; */
41
+
42
+ // const lineData = {
43
+ // labels: ["January", "February", "March", "April", "May", "June", "July"],
44
+ // datasets: [
45
+ // {
46
+ // label: "My First Dataset",
47
+ // data: [65, 59, 80, 81, 56, 55, 40],
48
+ // backgroundColor: [
49
+ // "rgba(255, 99, 132, 0.2)",
50
+ // "rgba(255, 159, 64, 0.2)",
51
+ // "rgba(255, 205, 86, 0.2)",
52
+ // "rgba(75, 192, 192, 0.2)",
53
+ // "rgba(54, 162, 235, 0.2)",
54
+ // "rgba(153, 102, 255, 0.2)",
55
+ // "rgba(201, 203, 207, 0.2)",
56
+ // ],
57
+ // borderColor: [
58
+ // "rgb(255, 99, 132)",
59
+ // "rgb(255, 159, 64)",
60
+ // "rgb(255, 205, 86)",
61
+ // "rgb(75, 192, 192)",
62
+ // "rgb(54, 162, 235)",
63
+ // "rgb(153, 102, 255)",
64
+ // "rgb(201, 203, 207)",
65
+ // ],
66
+ // borderWidth: 1,
67
+ // },
68
+ // ],
69
+ // };
70
+
71
+ interface ResponseCardProps {
72
+ answer: string;
73
+ chartData?: any;
74
+ onError?: boolean;
75
+ chatID?: number;
76
+ like?: number;
77
+ dislike?: number;
78
+ }
79
+
80
+ export const ResponseCard: React.FC<ResponseCardProps> = ({
81
+ answer,
82
+ chartData,
83
+ onError = false,
84
+ chatID,
85
+ like,
86
+ dislike,
87
+ }) => {
88
+ const divRef = useRef<HTMLDivElement>(null);
89
+ const [likeDislike, setLikeDislike] = useState<{
90
+ like: boolean;
91
+ dislike: boolean;
92
+ }>({
93
+ like: !!like,
94
+ dislike: !!dislike,
95
+ });
96
+
97
+ const createLikeDislikeMutation = useMutation({
98
+ mutationFn: likeDislikeChat,
99
+ onSuccess: (data) => {
100
+ setLikeDislike({
101
+ like: data.like,
102
+ dislike: data.dislike,
103
+ });
104
+ },
105
+ });
106
+
107
+ const handleCopyClick = async () => {
108
+ if (divRef.current) {
109
+ const textToCopy = divRef.current.textContent || "";
110
+ try {
111
+ await navigator.clipboard.writeText(textToCopy);
112
+ } catch (err) {
113
+ console.error("Failed to copy text: ", err);
114
+ }
115
+ }
116
+ };
117
+
118
+ const handleLikeDislike = (like: number, dislike: number) => {
119
+ chatID &&
120
+ createLikeDislikeMutation.mutate({
121
+ chatID: chatID,
122
+ like,
123
+ dislike,
124
+ });
125
+ };
126
+
127
+ const mapChartData = () => {
128
+ const labels = chartData.chart_labels;
129
+ const data = chartData.chart_values;
130
+ return {
131
+ labels,
132
+ datasets: [
133
+ {
134
+ label: chartData.chart_title,
135
+ data,
136
+ },
137
+ ],
138
+ };
139
+ };
140
+
141
+ return (
142
+ <Container>
143
+ <ResponseContainer>
144
+ <div>
145
+ <VuIcon svg={BotIcon} size={32} />
146
+ </div>
147
+ <TextContainer ref={divRef}>
148
+ {!onError ? answer : <ErrorContainer>{answer}</ErrorContainer>}
149
+ </TextContainer>
150
+ {!onError && (
151
+ <SideButtonsContainer>
152
+ <VuIconButton onClick={handleCopyClick} icon={CopyIcon} />
153
+ <VuIconButton
154
+ icon={ThumbsUpIcon}
155
+ data-tooltip-id="tooltip-btns"
156
+ data-tooltip-content="Like"
157
+ iconColor={likeDislike.like ? "fill-rose-500" : undefined}
158
+ onClick={() => handleLikeDislike(1, 0)}
159
+ />
160
+ <VuIconButton
161
+ icon={ThumbsDownIcon}
162
+ data-tooltip-id="tooltip-btns"
163
+ data-tooltip-content="Dislike"
164
+ iconColor={likeDislike.dislike ? "fill-rose-500" : undefined}
165
+ onClick={() => handleLikeDislike(0, 1)}
166
+ />
167
+ </SideButtonsContainer>
168
+ )}
169
+ </ResponseContainer>
170
+ {chartData && chartData.chart_possible && (
171
+ <ChartContainer>
172
+ {!chartData.error && (
173
+ <Charts type={chartData.chart_type} data={mapChartData()} />
174
+ )}
175
+ </ChartContainer>
176
+ )}
177
+ {/* <TimeContainer>2 Oct 2:22 PM</TimeContainer> */}
178
+ <Tooltip id="tooltip-btns" place="right" />
179
+ </Container>
180
+ );
181
+ };
@@ -0,0 +1,44 @@
1
+ import tw from "tailwind-styled-components";
2
+
3
+ export const Container = tw.div`
4
+ bg-white
5
+ px-10
6
+ py-5
7
+ w-full
8
+ `;
9
+
10
+ export const ResponseContainer = tw.div`
11
+ flex
12
+ gap-x-3
13
+ `;
14
+
15
+ export const ChartContainer = tw.div`
16
+ flex
17
+ justify-center
18
+ mt-4
19
+ w-full
20
+ `;
21
+
22
+ export const TimeContainer = tw.div`
23
+ flex
24
+ justify-end
25
+ text-xs
26
+ `;
27
+
28
+ export const TextContainer = tw.div`
29
+ text-sm
30
+ text-left
31
+ p-1
32
+ w-full
33
+ `;
34
+
35
+ export const SideButtonsContainer = tw.div`
36
+ flex
37
+ flex-col
38
+ pl-7
39
+ gap-2
40
+ `
41
+
42
+ export const ErrorContainer = tw.div`
43
+ text-red-500
44
+ `
@@ -0,0 +1,23 @@
1
+ import { Container, ReponseLoaderWrapper, ContentContainer } from "./styled";
2
+ import React from "react";
3
+ import SyncLoader from "react-spinners/SyncLoader";
4
+ //@ts-ignore
5
+ import Skeleton from "react-loading-skeleton";
6
+ import "react-loading-skeleton/dist/skeleton.css";
7
+
8
+ export const ResponseLoader: React.FC = () => {
9
+ return (
10
+ <Container>
11
+ <ReponseLoaderWrapper>
12
+ <SyncLoader color={"#000"} size={4} aria-label="Loading Spinner" />
13
+ <ContentContainer>
14
+ <p>Generating Response</p>
15
+ <Skeleton width={"60%"} />
16
+ <Skeleton width={"55%"} />
17
+ <Skeleton width={"50%"} />
18
+ <Skeleton width={"45%"} />
19
+ </ContentContainer>
20
+ </ReponseLoaderWrapper>
21
+ </Container>
22
+ );
23
+ };
@@ -0,0 +1,23 @@
1
+ import tw from "tailwind-styled-components";
2
+
3
+ export const Container = tw.div`
4
+ bg-white
5
+ px-10
6
+ py-4
7
+ my-5
8
+ w-full
9
+ `;
10
+
11
+ export const ReponseLoaderWrapper = tw.div`
12
+ flex
13
+ gap-x-3
14
+ `;
15
+
16
+ export const ContentContainer = tw.div`
17
+ flex
18
+ flex-col
19
+ text-sm
20
+ text-left
21
+ w-full
22
+ gap-2
23
+ `;
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import { Container } from "./styled";
3
+ import { VuButton } from "../../../../../../components";
4
+ import { Questions } from "../../../RecentConversations/questions";
5
+
6
+ const SuggestedQuestions: React.FC = () => {
7
+ return (
8
+ <Container>
9
+ {Questions.slice(0, 6).map((question) => (
10
+ <VuButton $fill="text">
11
+ <span className="text-sm">{question}</span>
12
+ </VuButton>
13
+ ))}
14
+ </Container>
15
+ );
16
+ };
17
+
18
+ export default SuggestedQuestions;
@@ -0,0 +1,12 @@
1
+ import tw from "tailwind-styled-components";
2
+
3
+ export const Container = tw.div`
4
+ bg-transparent
5
+ px-20
6
+ py-4
7
+ my-5
8
+ grid
9
+ grid-cols-3
10
+ gap-x-8
11
+ gap-y-5
12
+ `;
@@ -0,0 +1,27 @@
1
+ import tw from "tailwind-styled-components";
2
+
3
+ export const Container = tw.div`
4
+ flex
5
+ flex-col
6
+ items-center
7
+ justify-center
8
+ px-[7.5rem]
9
+ py-5
10
+ `;
11
+
12
+ export const ChartWrapper = tw.div`
13
+ grow
14
+ overflow-y-auto
15
+ `;
16
+
17
+ export const InputContainer = tw.div`
18
+ bg-alice_blue
19
+ p-2
20
+ w-full
21
+ pl-[7.5rem]
22
+ pr-[8rem]`;
23
+
24
+
25
+ export const ConversationContainer = tw.div`
26
+ w-full
27
+ `
@@ -0,0 +1,129 @@
1
+ import React, { useState, FC, useEffect } from "react";
2
+ import {
3
+ Container,
4
+ IconAndTextContainer,
5
+ IconAndTextSubContainer,
6
+ IconContainer,
7
+ ListContainer,
8
+ QuestionContainer,
9
+ } from "./styled";
10
+
11
+ import { Tooltip } from "react-tooltip";
12
+ import { VuIconButton } from "../../../../components/Buttons";
13
+ import { VuIcon } from "../../../../components/Icons/VuIcon";
14
+ import MessageIcon from "../../../../assets/icons/message.svg";
15
+ import DeleteIcon from "../../../../assets/icons/delete.svg";
16
+ import {
17
+ deleteConversation,
18
+ getConversations,
19
+ } from "../../../../components/api/api";
20
+ import { useQuery, useMutation, useQueryClient } from "react-query";
21
+ import ClipLoader from "react-spinners/ClipLoader";
22
+ import { Conversations } from "../../../../components/api/types";
23
+ import { LoaderContainer } from "../../styled";
24
+ import { ChatInfo } from "../../Chatbot";
25
+
26
+ interface Props {
27
+ handleSetConversationInfo: (chatInfoOld?: ChatInfo) => void;
28
+ searchQuery: string;
29
+ currentConversationInfo?: ChatInfo;
30
+ }
31
+
32
+ function filterData(data: Conversations, query: string) {
33
+ return data.filter((item) =>
34
+ item.chat_info[0].question.toLowerCase().includes(query.toLowerCase())
35
+ );
36
+ }
37
+
38
+ export const RecentConversations: FC<Props> = ({
39
+ handleSetConversationInfo,
40
+ searchQuery,
41
+ currentConversationInfo,
42
+ }) => {
43
+ const [filteredData, setFilteredData] = useState<Conversations>([]);
44
+
45
+ const queryClient = useQueryClient();
46
+
47
+ const { isLoading, status, data, refetch } = useQuery({
48
+ queryKey: "conversations",
49
+ queryFn: () => getConversations(),
50
+ enabled: false,
51
+ });
52
+
53
+ useEffect(() => {
54
+ const filtered = filterData(data ?? [], searchQuery);
55
+ setFilteredData(filtered);
56
+ }, [data, searchQuery]);
57
+
58
+ useEffect(() => {
59
+ refetch();
60
+ }, [currentConversationInfo]);
61
+
62
+ const deleteChatMutation = useMutation({
63
+ mutationFn: deleteConversation,
64
+ onSuccess: (_, conversationID) => {
65
+ queryClient.invalidateQueries(["conversations", conversationID]);
66
+ handleSetConversationInfo();
67
+ queryClient.invalidateQueries("conversations");
68
+ },
69
+ });
70
+
71
+ if (status === "loading")
72
+ return (
73
+ <LoaderContainer>
74
+ <ClipLoader
75
+ color={"#000"}
76
+ loading={isLoading}
77
+ size={25}
78
+ aria-label="Loading Spinner"
79
+ data-testid="loader"
80
+ />
81
+ </LoaderContainer>
82
+ );
83
+ if (status === "error") return <h1>Error in Loading Recent Conversations</h1>;
84
+
85
+ return (
86
+ <Container>
87
+ <div>Recent Conversations</div>
88
+ <ListContainer>
89
+ {filteredData?.map((question, index) => (
90
+ <IconAndTextContainer
91
+ key={index}
92
+ isSelected={currentConversationInfo?.conversationID === question.id}
93
+ onClick={() =>
94
+ handleSetConversationInfo({
95
+ conversationID: question.id,
96
+ isNew: false,
97
+ })
98
+ }
99
+ data-tooltip-id="question-tooltip"
100
+ data-tooltip-content={question.chat_info[0].question}
101
+ >
102
+ <IconAndTextSubContainer>
103
+ <IconContainer>
104
+ <VuIcon svg={MessageIcon} />
105
+ </IconContainer>
106
+ <QuestionContainer>
107
+ {question.chat_info[0].question}
108
+ </QuestionContainer>
109
+ </IconAndTextSubContainer>
110
+ {currentConversationInfo?.conversationID === question.id && (
111
+ <IconContainer>
112
+ <VuIconButton
113
+ name="delete"
114
+ icon={DeleteIcon}
115
+ disabled={deleteChatMutation.isLoading}
116
+ onClick={(e) => {
117
+ e.stopPropagation();
118
+ deleteChatMutation.mutate(question.id);
119
+ }}
120
+ />
121
+ </IconContainer>
122
+ )}
123
+ </IconAndTextContainer>
124
+ ))}
125
+ </ListContainer>
126
+ <Tooltip id="question-tooltip" />
127
+ </Container>
128
+ );
129
+ };
@@ -0,0 +1,24 @@
1
+ export const Questions: string[] = [
2
+ "What is the difference between software design and software architecture?",
3
+ "Explain the concept of Object-Oriented Programming (OOP).",
4
+ "What is the SOLID principle in software development, and why is it important?",
5
+ "Describe the difference between functional and imperative programming.",
6
+ "What is version control, and why is it essential in software development?",
7
+ "What is a software development life cycle (SDLC), and name some common SDLC models.",
8
+ "Explain the concept of a code review and its benefits.",
9
+ "What is the purpose of unit testing in software development?",
10
+ "Describe the differences between static and dynamic typing in programming languages.",
11
+ "What is a software bug, and how can it be prevented or mitigated?",
12
+ "Explain the concept of refactoring in software development.",
13
+ "What is the DRY (Don't Repeat Yourself) principle, and how does it relate to code quality?",
14
+ "Describe the role of a software architect in a development project.",
15
+ "What is the difference between a thread and a process in the context of multitasking?",
16
+ "Explain the importance of documentation in software development.",
17
+ "What is the difference between a library and a framework in programming?",
18
+ "Describe the concept of Continuous Integration (CI) and Continuous Delivery (CD).",
19
+ "What is the Agile software development methodology, and what are its key principles?",
20
+ "Explain the concept of a design pattern in software development, and give an example.",
21
+ "What is a RESTful API, and how does it differ from SOAP?",
22
+ "Describe the principles of Test-Driven Development (TDD).",
23
+ // Add more questions here...
24
+ ];
@@ -0,0 +1,49 @@
1
+ import tw from "tailwind-styled-components";
2
+
3
+ interface IconAndTextContainerProps {
4
+ isSelected: boolean;
5
+ }
6
+
7
+ export const Container = tw.div`
8
+ flex
9
+ flex-col
10
+ text-left
11
+ grow
12
+ `;
13
+
14
+ export const ListContainer = tw.div`
15
+ my-2
16
+ grow
17
+ overflow-y-auto
18
+ h-32
19
+ `;
20
+
21
+ export const IconAndTextContainer = tw.div<IconAndTextContainerProps>`
22
+ flex
23
+ justify-between
24
+ items-center
25
+ p-1.5
26
+ ${(p) =>
27
+ p.isSelected
28
+ ? `
29
+ bg-gainsboro
30
+ `
31
+ : `bg-white`}
32
+ `;
33
+
34
+ export const IconAndTextSubContainer = tw.div`
35
+ flex
36
+ items-center
37
+ overflow-x-hidden
38
+ `;
39
+
40
+ export const IconContainer = tw.span`
41
+ mr-2
42
+ `;
43
+
44
+ export const QuestionContainer = tw.div`
45
+ truncate
46
+ text-sm
47
+ text-center
48
+ cursor-pointer
49
+ `;
@@ -0,0 +1 @@
1
+ export * from "./Chatbot";
@@ -0,0 +1,77 @@
1
+ import tw from "tailwind-styled-components";
2
+
3
+ export const FlexContainerRow = tw.div`
4
+ flex
5
+ `;
6
+
7
+ export const FlexContainerCol = tw.div`
8
+ flex
9
+ flex-col
10
+ gap-4
11
+ grow
12
+ `;
13
+
14
+ export const Header = tw.div`
15
+ flex
16
+ justify-between
17
+ mb-10
18
+ `;
19
+
20
+ export const HeaderIconAndText = tw.div`
21
+ flex
22
+ items-center
23
+ `;
24
+
25
+ export const Container = tw.div`
26
+ flex
27
+ h-full
28
+ `;
29
+
30
+ export const LeftSectionContainer = tw.div`
31
+ flex
32
+ flex-col
33
+ `;
34
+
35
+ export const RecentConversationsContainer = tw.div`
36
+ grow
37
+ w-80
38
+ pr-6
39
+ min-w-[20rem]
40
+ `;
41
+
42
+ export const RecentConversationsSubContainer = tw.div`
43
+ h-full
44
+ flex
45
+ flex-col
46
+ `;
47
+
48
+ export const ChatContainer = tw.div`
49
+ flex
50
+ flex-col
51
+ bg-alice_blue
52
+ relative
53
+ py-10
54
+ w-full
55
+ `;
56
+
57
+ export const LoaderContainer = tw.div`
58
+ flex
59
+ justify-center
60
+ items-center
61
+ h-full
62
+ `;
63
+
64
+ export const SelectWithLabelContainer = tw.div`
65
+ flex
66
+ items-center
67
+ mb-2
68
+ pr-6
69
+ `;
70
+
71
+ export const SelectContainer = tw.div`
72
+ grow
73
+ `;
74
+
75
+ export const SelectLabelContainer = tw.div`
76
+ mr-2
77
+ `;
@@ -0,0 +1 @@
1
+ export * from "./VuChat";
@@ -0,0 +1,9 @@
1
+ import tw from "tailwind-styled-components";
2
+
3
+ export const MainContainer = tw.div`
4
+ p-6
5
+ h-full
6
+ bg-white
7
+ flex
8
+ flex-col
9
+ `;
@@ -0,0 +1,3 @@
1
+ const iconRoot = "/src/assets/icons/";
2
+
3
+ export const getSvgPath = (name: string) => `${iconRoot}${name}.svg`;
@@ -0,0 +1,14 @@
1
+ export const vuIconList = [
2
+ "add",
3
+ "arrow-left",
4
+ "bot",
5
+ "copy",
6
+ "delete",
7
+ "message",
8
+ "search",
9
+ "send",
10
+ "thumbs-up",
11
+ "thumbs-down",
12
+ ] as const;
13
+
14
+ export type VuIconName = (typeof vuIconList)[number];
@@ -0,0 +1,2 @@
1
+ export * from "./icons";
2
+ export * from "./iconsList";
@@ -0,0 +1,18 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: ["./src/**/*.{js,jsx,ts,tsx}"],
4
+ theme: {
5
+ extend: {
6
+ colors: {
7
+ primary: "#11339A",
8
+ white: "#FFF",
9
+ black: "#000",
10
+ light_pink: "#FFB2B8",
11
+ gainsboro: "#D8DEE4",
12
+ lavender_blush: "#FEF2F3",
13
+ alice_blue: "#F3F6FC",
14
+ },
15
+ },
16
+ },
17
+ plugins: [],
18
+ };