@omniumretail/component-library 1.2.71 → 1.2.73

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 (191) hide show
  1. package/package.json +6 -3
  2. package/NPMPUBLISH.md +0 -29
  3. package/bitbucket-pipelines.yml +0 -95
  4. package/dist/components/AnalyticsBar/AnalyticsBar.stories.d.ts +0 -5
  5. package/dist/components/BellNotifications/BellNotifications.stories.d.ts +0 -5
  6. package/dist/components/Button/Button.stories.d.ts +0 -6
  7. package/dist/components/Category/Category.stories.d.ts +0 -3
  8. package/dist/components/CategoryReadOnly/CategoryReadOnly.stories.d.ts +0 -3
  9. package/dist/components/CategoryResponse/CategoryResponse.stories.d.ts +0 -3
  10. package/dist/components/DatePicker/DatePicker.stories.d.ts +0 -5
  11. package/dist/components/DatePickerTag/DatePickerTag.stories.d.ts +0 -5
  12. package/dist/components/DropdownButton/DropdownButton.stories.d.ts +0 -5
  13. package/dist/components/ExportTableData/ExportTableData.stories.d.ts +0 -3
  14. package/dist/components/Footer/Footer.stories.d.ts +0 -5
  15. package/dist/components/Footer2/Footer.stories.d.ts +0 -6
  16. package/dist/components/Header/Header.stories.d.ts +0 -5
  17. package/dist/components/Input/Input.stories.d.ts +0 -5
  18. package/dist/components/InputCountryCode/inputCountryCode.stories.d.ts +0 -5
  19. package/dist/components/Label/Label.stories.d.ts +0 -6
  20. package/dist/components/Link/Link.stories.d.ts +0 -7
  21. package/dist/components/Menu/Menu.stories.d.ts +0 -5
  22. package/dist/components/MobileTable/MobileTable.stories.d.ts +0 -5
  23. package/dist/components/ModalConfirmation/ModalConfirmation.stories.d.ts +0 -5
  24. package/dist/components/ModalWithTable/ModalWithTable.stories.d.ts +0 -5
  25. package/dist/components/Navigation/Navigation.stories.d.ts +0 -5
  26. package/dist/components/Notification/Notification.stories.d.ts +0 -5
  27. package/dist/components/Questions/Questions.stories.d.ts +0 -3
  28. package/dist/components/Radio/Radio.stories.d.ts +0 -5
  29. package/dist/components/ResponseType/ResponseType.stories.d.ts +0 -3
  30. package/dist/components/ResponsiveTable/ResponsiveTable.stories.d.ts +0 -9
  31. package/dist/components/Select/Select.stories.d.ts +0 -6
  32. package/dist/components/Separator/Separator.stories.d.ts +0 -6
  33. package/dist/components/Sidebar/Sidebar.stories.d.ts +0 -6
  34. package/dist/components/Switch/Switch.stories.d.ts +0 -5
  35. package/dist/components/Table/Table.stories.d.ts +0 -9
  36. package/dist/components/Tag/Tag.stories.d.ts +0 -5
  37. package/dist/components/Upload/Upload.stories.d.ts +0 -3
  38. package/dist/components/UserInfo/UserInfo.stories.d.ts +0 -3
  39. package/dist/components/WebCam/WebCam.stories.d.ts +0 -3
  40. package/dist/types/index.d.ts +0 -2
  41. package/public/index.ts +0 -0
  42. package/src/assets/code-brackets.svg +0 -1
  43. package/src/assets/colors.svg +0 -1
  44. package/src/assets/comments.svg +0 -1
  45. package/src/assets/direction.svg +0 -1
  46. package/src/assets/flow.svg +0 -1
  47. package/src/assets/fonts/Silka-Bold.woff2 +0 -0
  48. package/src/assets/fonts/Silka-Regular.woff2 +0 -0
  49. package/src/assets/images/A2AI-logo.png +0 -0
  50. package/src/assets/images/omnium-retail-logo-white.png +0 -0
  51. package/src/assets/images/omnium-retail-logo.png +0 -0
  52. package/src/assets/images/omnium-retail_icon.png +0 -0
  53. package/src/assets/plugin.svg +0 -1
  54. package/src/assets/repo.svg +0 -1
  55. package/src/assets/scss/_combinations.scss +0 -0
  56. package/src/assets/scss/_global.scss +0 -89
  57. package/src/assets/scss/index.scss +0 -2
  58. package/src/assets/stackalt.svg +0 -1
  59. package/src/components/AnalyticsBar/AnalyticsBar.stories.tsx +0 -236
  60. package/src/components/AnalyticsBar/helpers/codeMutation.tsx +0 -19
  61. package/src/components/AnalyticsBar/index.tsx +0 -76
  62. package/src/components/AnalyticsBar/interfaces/analyticsBar.tsx +0 -13
  63. package/src/components/AnalyticsBar/styles.module.scss +0 -137
  64. package/src/components/BellNotifications/BellNotifications.stories.tsx +0 -200
  65. package/src/components/BellNotifications/index.tsx +0 -154
  66. package/src/components/BellNotifications/styles.module.scss +0 -239
  67. package/src/components/Button/Button.stories.tsx +0 -26
  68. package/src/components/Button/index.tsx +0 -24
  69. package/src/components/Button/styles.module.scss +0 -70
  70. package/src/components/Category/Category.stories.tsx +0 -371
  71. package/src/components/Category/CategoryContent/index.tsx +0 -255
  72. package/src/components/Category/CategoryContent/styles.module.scss +0 -69
  73. package/src/components/Category/CategorySidebar/index.tsx +0 -344
  74. package/src/components/Category/CategorySidebar/styles.module.scss +0 -28
  75. package/src/components/Category/index.tsx +0 -58
  76. package/src/components/Category/styles.module.scss +0 -13
  77. package/src/components/CategoryReadOnly/CategoryReadOnly.stories.tsx +0 -274
  78. package/src/components/CategoryReadOnly/evaluationOptions.tsx +0 -81
  79. package/src/components/CategoryReadOnly/index.tsx +0 -328
  80. package/src/components/CategoryReadOnly/styles.module.scss +0 -214
  81. package/src/components/CategoryResponse/CategoryResponse.stories.tsx +0 -311
  82. package/src/components/CategoryResponse/evaluationOptions.tsx +0 -81
  83. package/src/components/CategoryResponse/index.tsx +0 -502
  84. package/src/components/CategoryResponse/styles.module.scss +0 -365
  85. package/src/components/DatePicker/DatePicker.stories.tsx +0 -16
  86. package/src/components/DatePicker/index.tsx +0 -38
  87. package/src/components/DatePicker/styles.module.scss +0 -3
  88. package/src/components/DatePickerTag/DatePickerTag.stories.tsx +0 -19
  89. package/src/components/DatePickerTag/index.tsx +0 -91
  90. package/src/components/DatePickerTag/styles.module.scss +0 -32
  91. package/src/components/DropdownButton/DropdownButton.stories.tsx +0 -24
  92. package/src/components/DropdownButton/index.tsx +0 -36
  93. package/src/components/DropdownButton/styles.module.scss +0 -9
  94. package/src/components/ExportTableData/ExportTableData.stories.tsx +0 -43
  95. package/src/components/ExportTableData/index.tsx +0 -37
  96. package/src/components/ExportTableData/styles.module.scss +0 -4
  97. package/src/components/Footer/Footer.stories.tsx +0 -15
  98. package/src/components/Footer/index.tsx +0 -45
  99. package/src/components/Footer/styles.module.scss +0 -38
  100. package/src/components/Footer2/Footer.stories.tsx +0 -184
  101. package/src/components/Footer2/index.tsx +0 -322
  102. package/src/components/Footer2/styles.module.scss +0 -292
  103. package/src/components/Header/Header.data.ts +0 -26
  104. package/src/components/Header/Header.stories.tsx +0 -236
  105. package/src/components/Header/Header.types.ts +0 -32
  106. package/src/components/Header/README.md +0 -38
  107. package/src/components/Header/index.tsx +0 -200
  108. package/src/components/Header/styles.module.scss +0 -216
  109. package/src/components/Input/Input.stories.tsx +0 -13
  110. package/src/components/Input/index.tsx +0 -31
  111. package/src/components/Input/styles.module.scss +0 -8
  112. package/src/components/InputCountryCode/index.tsx +0 -79
  113. package/src/components/InputCountryCode/inputCountryCode.stories.tsx +0 -55
  114. package/src/components/InputCountryCode/styles.module.scss +0 -3
  115. package/src/components/Label/Label.stories.tsx +0 -21
  116. package/src/components/Label/index.tsx +0 -19
  117. package/src/components/Label/styles.module.scss +0 -17
  118. package/src/components/Link/Link.stories.tsx +0 -30
  119. package/src/components/Link/index.tsx +0 -21
  120. package/src/components/Link/styles.module.scss +0 -24
  121. package/src/components/Menu/Menu.stories.tsx +0 -178
  122. package/src/components/Menu/helpers/codeMutation.tsx +0 -19
  123. package/src/components/Menu/index.tsx +0 -24
  124. package/src/components/Menu/styles.module.scss +0 -0
  125. package/src/components/MobileTable/MobileTable.stories.tsx +0 -27
  126. package/src/components/MobileTable/index.tsx +0 -102
  127. package/src/components/MobileTable/styles.module.scss +0 -75
  128. package/src/components/ModalConfirmation/ModalConfirmation.stories.tsx +0 -40
  129. package/src/components/ModalConfirmation/ModalStatusList.tsx +0 -5
  130. package/src/components/ModalConfirmation/index.tsx +0 -71
  131. package/src/components/ModalConfirmation/styles.module.scss +0 -62
  132. package/src/components/ModalWithTable/ModalWithTable.stories.tsx +0 -99
  133. package/src/components/ModalWithTable/index.tsx +0 -238
  134. package/src/components/ModalWithTable/styles.module.scss +0 -77
  135. package/src/components/Navigation/Navigation.stories.tsx +0 -21
  136. package/src/components/Navigation/index.tsx +0 -91
  137. package/src/components/Navigation/styles.module.scss +0 -91
  138. package/src/components/Notification/Notification.stories.tsx +0 -32
  139. package/src/components/Notification/index.tsx +0 -28
  140. package/src/components/Questions/Questions.stories.tsx +0 -37
  141. package/src/components/Questions/SingleQuestion/index.tsx +0 -337
  142. package/src/components/Questions/SingleQuestion/styles.module.scss +0 -142
  143. package/src/components/Questions/index.tsx +0 -124
  144. package/src/components/Questions/styles.modules.scss +0 -0
  145. package/src/components/Radio/Radio.stories.tsx +0 -43
  146. package/src/components/Radio/index.tsx +0 -26
  147. package/src/components/Radio/styles.module.scss +0 -24
  148. package/src/components/ResponseType/ResponseType.stories.tsx +0 -393
  149. package/src/components/ResponseType/index.tsx +0 -100
  150. package/src/components/ResponseType/styles.module.scss +0 -31
  151. package/src/components/ResponsiveTable/ResponsiveTable.stories.tsx +0 -386
  152. package/src/components/ResponsiveTable/index.tsx +0 -389
  153. package/src/components/ResponsiveTable/styles.module.scss +0 -153
  154. package/src/components/Select/Select.stories.tsx +0 -39
  155. package/src/components/Select/index.tsx +0 -27
  156. package/src/components/Select/styles.module.scss +0 -19
  157. package/src/components/Separator/Separator.stories.tsx +0 -22
  158. package/src/components/Separator/index.tsx +0 -27
  159. package/src/components/Separator/styles.module.scss +0 -25
  160. package/src/components/Sidebar/Sidebar.stories.tsx +0 -85
  161. package/src/components/Sidebar/index.tsx +0 -127
  162. package/src/components/Sidebar/styles.module.scss +0 -141
  163. package/src/components/Switch/Switch.stories.tsx +0 -14
  164. package/src/components/Switch/index.tsx +0 -18
  165. package/src/components/Switch/styles.module.scss +0 -7
  166. package/src/components/Table/Table.stories.tsx +0 -337
  167. package/src/components/Table/index.tsx +0 -313
  168. package/src/components/Table/styles.module.scss +0 -97
  169. package/src/components/Tag/Tag.stories.tsx +0 -32
  170. package/src/components/Tag/index.tsx +0 -295
  171. package/src/components/Tag/styles.module.scss +0 -104
  172. package/src/components/Upload/Upload.stories.tsx +0 -45
  173. package/src/components/Upload/index.tsx +0 -112
  174. package/src/components/Upload/styles.module.scss +0 -29
  175. package/src/components/UserInfo/UserInfo.stories.tsx +0 -38
  176. package/src/components/UserInfo/index.tsx +0 -77
  177. package/src/components/UserInfo/styles.module.scss +0 -35
  178. package/src/components/WebCam/WebCam.stories.tsx +0 -24
  179. package/src/components/WebCam/index.tsx +0 -73
  180. package/src/components/WebCam/styles.module.scss +0 -37
  181. package/src/components/index.tsx +0 -34
  182. package/src/constants/i18n.ts +0 -25
  183. package/src/constants/logoCompanyHelper.ts +0 -52
  184. package/src/constants/translationHelper.ts +0 -7
  185. package/src/index.ts +0 -3
  186. package/src/locales/en.json +0 -142
  187. package/src/locales/es.json +0 -142
  188. package/src/locales/pt.json +0 -142
  189. package/src/types/Global.d.ts +0 -4
  190. package/tsconfig.json +0 -24
  191. package/vite.config.js +0 -51
@@ -1,502 +0,0 @@
1
- import styles from './styles.module.scss';
2
- import { useEffect, useImperativeHandle, useState } from 'react';
3
- import { Form, UploadFile, Upload, DatePicker, InputNumber, Tag, Modal } from 'antd';
4
- import { useForm } from 'antd/es/form/Form';
5
- import classNames from 'classnames';
6
- import TextArea from 'antd/es/input/TextArea';
7
- import { Select } from '../Select';
8
- import { evaluationOptions } from './evaluationOptions';
9
- import React from 'react';
10
- import { t } from 'i18next';
11
- import { Button } from '../Button';
12
- import dayjs from 'dayjs';
13
- import { CommentOutlined, FileDoneOutlined, PictureOutlined } from '@ant-design/icons';
14
-
15
- interface CategoryResponse {
16
- data: any;
17
- serverReadyData: any;
18
- onNextCategoryAvailabilityChange: (hasNext: boolean) => void;
19
- onPreviousCategoryAvailabilityChange: (hasPrevious: boolean) => void;
20
- selectYesNoOption?: any;
21
- addAction?: (questionId: string, questionAnswerId: string) => void;
22
- openAction?: (actionId: string) => void;
23
- addButtons?: boolean;
24
- fileList?: React.Dispatch<React.SetStateAction<Record<string, UploadFile<any>[]>>>;
25
- initialFileList?: any;
26
- };
27
-
28
- type Category = {
29
- Title: string;
30
- Key: string;
31
- Data: any;
32
- Children?: Category[];
33
- };
34
-
35
- const updateCategoryAnswers = (CategoryAnswers: any[], categoryToUpdate: any, updatedQuestions: any) => {
36
- CategoryAnswers.forEach((category: any) => {
37
- if (category.Data.CategoryId === categoryToUpdate.CategoryId) {
38
- category.Data.Questions = category.Data.Questions.map((question: any, index: any) => {
39
- return {
40
- ...question,
41
- Answer: updatedQuestions[index].Answer,
42
- Note: updatedQuestions[index].Note,
43
- ImagesList: updatedQuestions[index].ImagesList
44
- };
45
- });
46
- }
47
- else if (category.Children && category.Children.length > 0) {
48
- updateCategoryAnswers(category.Children, categoryToUpdate, updatedQuestions);
49
- }
50
- });
51
- return CategoryAnswers;
52
- };
53
-
54
- const findCategoryWithQuestions = (currentKey: string, categories: Category[], direction: 'next' | 'prev'): Category | null => {
55
- let foundCurrent = false;
56
-
57
- const searchCategories = (categoryList: Category[], direction: 'next' | 'prev'): Category | null => {
58
- const iterable = direction === 'next' ? categoryList : [...categoryList].reverse();
59
-
60
- for (const category of iterable) {
61
- if (foundCurrent) {
62
- if (category.Data.Questions.length > 0) {
63
- return category;
64
- }
65
- } else if (category.Key === currentKey) {
66
- foundCurrent = true;
67
- }
68
-
69
- if (category.Children) {
70
- const result = searchCategories(category.Children, direction);
71
- if (result) {
72
- return result;
73
- }
74
- }
75
- }
76
- return null;
77
- };
78
-
79
- return searchCategories(categories, direction);
80
- };
81
-
82
- const getCategoryObject = (currentKey: string, categories: Category[], direction: 'next' | 'prev'): any => {
83
- const category = findCategoryWithQuestions(currentKey, categories, direction);
84
- return category ? category.Data : null;
85
- };
86
-
87
- const hasCategory = (currentKey: string, categories: Category[], direction: 'next' | 'prev'): boolean => {
88
- const category = findCategoryWithQuestions(currentKey, categories, direction);
89
- return !!category;
90
- };
91
-
92
- export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref) => {
93
- const { data } = props;
94
- const [currentKey, setCurrentKey] = useState(data.CategoryAnswers[0].Key);
95
- const [localData, setLocalData] = useState<any>(data);
96
- // Setting first set of questions as default open
97
- const [selectedCategory, setSelectedCategory] = useState<any>(data.CategoryAnswers[0]);
98
- const [initialValues, setInitialValues] = useState<any>(data.CategoryAnswers[0].Data);
99
- const [fileLists, setFileLists] = useState<Record<string, UploadFile[]>>(props.initialFileList || []);
100
- const [dataValue, setDataValue] = useState<any>();
101
- const [isNoteVisible, setIsNoteVisible] = useState<{ categoryIndex: number; questionIndex: number } | null>(null);
102
- const [form] = useForm();
103
- const [isMobile, setIsMobile] = useState(window.innerWidth < 767);
104
- const [previewVisible, setPreviewVisible] = useState(false);
105
- const [previewImage, setPreviewImage] = useState<string>("");
106
-
107
- const handleResize = () => {
108
- setIsMobile(window.innerWidth < 767);
109
- };
110
-
111
- useEffect(() => {
112
- handleResize();
113
-
114
- const resizeListener = () => {
115
- handleResize();
116
- };
117
-
118
- window.addEventListener('resize', resizeListener);
119
-
120
- return () => {
121
- window.removeEventListener('resize', resizeListener);
122
- };
123
- }, []);
124
-
125
- useEffect(() => {
126
- if (props.initialFileList) {
127
- setFileLists(props.initialFileList);
128
- }
129
- }, [props.initialFileList]);
130
-
131
- const updateInitialValues = (data: any) => {
132
- const {
133
- Questions,
134
- OpenAnswer,
135
- IsYesOrNo
136
- } = data;
137
-
138
- const initial = {
139
- Questions: Questions.map((question: any) => ({
140
- Subject: question.Subject,
141
- Description: question.Description,
142
- Answer: props.addButtons
143
- ? !question.Disabled
144
- ? (question.IsDate
145
- ? (question?.Answer?.length > 0
146
- ? dayjs.unix(Number(question?.Answer))
147
- : null)
148
- : question.Answer)
149
- : question.Answer
150
- : question.Answer,
151
- Note: question.Note || "",
152
- IsMultipleChoise: question.IsMultipleChoise || false,
153
- IsNumerical: question.IsNumerical || false,
154
- IsDate: question.IsDate || false,
155
- IsOpenAnswer: question.IsOpenAnswer || false,
156
- IsMandatory: question.IsMandatory || false
157
- })),
158
- OpenAnswer: OpenAnswer,
159
- IsYesOrNo: IsYesOrNo
160
- };
161
-
162
- setInitialValues(initial);
163
- form.setFieldsValue(initial);
164
- };
165
-
166
- const getTitleWithQuestionCount = (category: any): string => {
167
- const questionCount = category?.Data?.Questions?.length;
168
- const answeredQuestions = category?.Data?.Questions?.filter
169
- ((question: any) => question.Answer !== null && question.Answer !== undefined && question.Answer !== '' && question.Answer.length > 0).length;
170
-
171
- return questionCount
172
- ? `${category.Title} - ${answeredQuestions} / ${questionCount}`
173
- : category.Title;
174
- };
175
-
176
- const handleLabelClick = (category: any, index: number) => {
177
- setSelectedCategory(category);
178
- updateInitialValues(category.Data);
179
- setCurrentKey(index);
180
- };
181
-
182
- const handleFileChange = (fileList: UploadFile[], categoryIndex: number, questionIndex: number) => {
183
- const key = `${categoryIndex}_${questionIndex}`;
184
- setFileLists((prev) => ({
185
- ...prev,
186
- [key]: fileList,
187
- }));
188
- };
189
-
190
- useEffect(() => {
191
- if (props.fileList) {
192
- props.fileList(fileLists);
193
- }
194
- }, [fileLists]);
195
-
196
- const onPreview = async (file: UploadFile) => {
197
- let src = file.url as string;
198
- if (!src) {
199
- src = await new Promise((resolve) => {
200
- const reader = new FileReader();
201
- reader.readAsDataURL(file.originFileObj!);
202
- reader.onload = () => resolve(reader.result as string);
203
- });
204
- }
205
-
206
- setPreviewImage(src);
207
- setPreviewVisible(true);
208
- };
209
-
210
- const handleAddAction = (questionId: string, questionAnswerId: string) => {
211
- if (props.addAction) {
212
- props.addAction(questionId, questionAnswerId);
213
- }
214
- };
215
-
216
- const onFinish = (values: any) => {
217
- const updatedQuestions = initialValues.Questions.map((question: any, index: number) => {
218
-
219
- return {
220
- ...question,
221
- Answer: !props.addButtons
222
- ? values.Questions[index].Answer
223
- : Array.isArray(values.Questions[index].Answer)
224
- ? values.Questions[index].Answer
225
- : values.Questions[index].Answer
226
- ? [values.Questions[index].Answer]
227
- : [],
228
- Note: values.Questions[index].Note,
229
- IsMultipleChoise: values.Questions[index].IsMultipleChoise,
230
- Files: fileLists[`${selectedCategory.Data.CategoryId}_${index}`] || [], // Include files in the form data
231
- };
232
- });
233
-
234
- const updatedCategory = updateCategoryAnswers(localData.CategoryAnswers, selectedCategory.Data, updatedQuestions);
235
-
236
- const updatedLocalData = { ...localData, CategoryAnswers: updatedCategory };
237
-
238
- setLocalData(updatedLocalData);
239
- };
240
-
241
- const renderCategories = (categories: any) => {
242
- return categories.map((category: any, index: number) => {
243
- const labelClasses = classNames({
244
- [styles.cursorPointer]: category.Data.Questions.length > 0
245
- }, [styles.label]);
246
-
247
- const indexCheck = category.Data.Questions.length > 0 && category.Key;
248
-
249
- return (
250
- <div
251
- className={`${styles.labelWrapper} ${category.Data.CategoryId === selectedCategory.Data.CategoryId ? styles.active : ""}`}
252
- key={index}
253
- >
254
- <div
255
- className={labelClasses}
256
- data-index={indexCheck}
257
- onClick={() => category.Data.Questions.length > 0 && handleLabelClick(category, indexCheck)}
258
- >
259
- {getTitleWithQuestionCount(category)}
260
- </div>
261
- {category.Children && (
262
- <div className={styles.subCategory}>
263
- {renderCategories(category.Children)}
264
- </div>
265
- )}
266
- </div>
267
- )
268
- });
269
- };
270
-
271
- const handleNextClick = () => {
272
- const nextCategory = findCategoryWithQuestions(currentKey, localData.CategoryAnswers, 'next');
273
- if (nextCategory) {
274
- setCurrentKey(nextCategory.Key);
275
- setSelectedCategory(nextCategory);
276
- }
277
-
278
- const nextCategoryData = getCategoryObject(currentKey, localData.CategoryAnswers, 'next');
279
- setSelectedCategory(nextCategoryData ? { ...nextCategory, data: nextCategoryData } : null);
280
- updateInitialValues(nextCategoryData);
281
- };
282
-
283
- const handlePreviousClick = () => {
284
- const prevCategory = findCategoryWithQuestions(currentKey, localData.CategoryAnswers, 'prev');
285
- if (prevCategory) {
286
- setCurrentKey(prevCategory.Key);
287
- setSelectedCategory(prevCategory);
288
- }
289
-
290
- const prevCategoryData = getCategoryObject(currentKey, localData.CategoryAnswers, 'prev');
291
- setSelectedCategory(prevCategoryData ? { ...prevCategory, data: prevCategoryData } : null);
292
- updateInitialValues(prevCategoryData);
293
- };
294
-
295
- useImperativeHandle(ref, () => ({
296
- handleNextClick,
297
- handlePreviousClick,
298
- }));
299
-
300
- useEffect(() => {
301
- props.serverReadyData(localData);
302
- }, [localData]);
303
-
304
- useEffect(() => {
305
- const hasNext = hasCategory(currentKey, localData.CategoryAnswers, 'next');
306
- props.onNextCategoryAvailabilityChange(hasNext);
307
-
308
- const hasPrevious = hasCategory(currentKey, localData.CategoryAnswers, 'prev');
309
- props.onPreviousCategoryAvailabilityChange(hasPrevious);
310
- }, [currentKey, localData.CategoryAnswers, props]);
311
-
312
- // This gets the scale we use for each select from the database using a key based variable,if
313
- // any new generalEvaluationLevel is added to the backend we need to update our own without
314
- // deleting any of the previous so we dont mess up the project history.
315
- const selectedEvaluationOption = `scale_${selectedCategory?.Data?.GeneralEvaluationLevel}` as keyof typeof evaluationOptions;
316
- const dateFormatList = ['DD/MM/YYYY', 'YYYY/MM/DD'];
317
-
318
- return (
319
- <div className={styles.categoryResponse}>
320
- <div className={styles.sidebarWrapper}>
321
- {renderCategories(localData.CategoryAnswers)}
322
- </div>
323
- <div className={styles.contentWrapper}>
324
- <Form
325
- initialValues={initialValues}
326
- name="dynamic_form_nest_item"
327
- onFinish={onFinish}
328
- autoComplete="off"
329
- form={form}
330
- onValuesChange={(_, allValues) => onFinish(allValues)}
331
- >
332
- <div className={styles.details}>
333
- <div className={styles.categoryDescription}>
334
- {selectedCategory?.Data?.Description}
335
- </div>
336
- </div>
337
- {selectedCategory?.Data?.Questions.map((question: any, index: number) => {
338
- const isOpenAnswer = selectedCategory.Data.OpenAnswer || question.IsOpenAnswer;
339
- const showNote = (isNoteVisible?.categoryIndex === currentKey && isNoteVisible?.questionIndex === index);
340
-
341
- const questionWrapper = classNames({
342
- [styles.questionWrapperOpenAnswer]: isOpenAnswer || props.addButtons,
343
- }, [styles.questionWrapper]);
344
-
345
- return (
346
- <div className={questionWrapper} key={index}>
347
- <div className={styles.question}>
348
- <div className={styles.subject}>
349
- {`${question.Subject} ${question.IsMandatory ? "*" : ''}`}
350
- </div>
351
-
352
- <div className={styles.description}>
353
- {question.Description}
354
- </div>
355
-
356
- {props.addButtons &&
357
- <>
358
- {(form.getFieldValue(`Questions`)?.[index].Note || (isNoteVisible && showNote)) &&
359
- <div className={styles.noteContainer}>
360
- <span className={styles.note}>{t('components.categoryResponse.note')}: </span>
361
-
362
- <Form.Item name={["Questions", index, "Note"]} className={styles.form}>
363
- <TextArea
364
- disabled={(!isNoteVisible || !showNote)}
365
- variant={showNote ? "outlined" : "borderless"}
366
- onBlur={() => setIsNoteVisible(null)}
367
- className={styles.textArea}
368
- />
369
- </Form.Item>
370
- </div>
371
- }
372
-
373
- {question?.Actions?.length > 0 &&
374
- <div className={styles.actionContainer}>
375
- <span className={styles.note}>{t('components.categoryResponse.actions')}: </span>
376
-
377
- <div className={styles.action}>
378
- {question?.Actions?.map((action: any, index: number) => (
379
- <a onClick={() => props.openAction!(action.Id)} key={action.Id}>
380
- {action.Name}
381
- </a>
382
- ))}
383
- </div>
384
- </div>
385
- }
386
-
387
- <div className={styles.actionsButtonsContainer}>
388
- <div className={styles.buttonContainer} onClick={() => setIsNoteVisible({ categoryIndex: currentKey, questionIndex: index })}>
389
- <CommentOutlined className={styles.iconStyle} />
390
-
391
- <span className={styles.buttonLabel}>{t('components.categoryResponse.note')}</span>
392
- </div>
393
-
394
- <div className={styles.uploadContainer}>
395
- <Upload
396
- listType={"picture"}
397
- fileList={fileLists[`${selectedCategory.Data.CategoryId}_${question.Id}`] || []}
398
- beforeUpload={() => false} // Prevent automatic upload
399
- onChange={({ fileList }) => handleFileChange(fileList, selectedCategory.Data.CategoryId, question.Id)}
400
- onPreview={onPreview}
401
- className={styles.uploadFiles}
402
- >
403
- <div className={styles.uploadIconContainer}>
404
- <PictureOutlined className={styles.iconStyle} />
405
-
406
- <span className={styles.buttonLabel}>{t('components.categoryResponse.loadFile')}</span>
407
- </div>
408
- </Upload>
409
-
410
- <Modal
411
- open={previewVisible}
412
- footer={null}
413
- onCancel={() => setPreviewVisible(false)}
414
- closeIcon={false}
415
- >
416
- <img alt="Preview" style={{ width: "100%" }} src={previewImage} />
417
- </Modal>
418
- </div>
419
-
420
- <div className={styles.buttonContainer} onClick={() => handleAddAction(question.QuestionId, question.Id)}>
421
- <FileDoneOutlined className={styles.iconStyle} />
422
-
423
- <span className={styles.buttonLabel}>{t('components.categoryResponse.createAction')}</span>
424
- </div>
425
- </div>
426
- </>
427
- }
428
- </div>
429
- <div className={styles.answer}>
430
- {isOpenAnswer
431
- ? <Form.Item
432
- name={["Questions", index, "Answer"]}
433
- >
434
- <TextArea disabled={question.Disabled} />
435
- </Form.Item>
436
-
437
- : question.IsDate
438
- ? <Form.Item
439
- name={["Questions", index, "Answer"]}
440
- >
441
- <DatePicker
442
- className={styles.datePickerStyle}
443
- placeholder={''}
444
- format={dateFormatList}
445
- value={dataValue}
446
- defaultValue={form.getFieldValue(`Questions`)?.[index].Answer}
447
- onChange={(value) => setDataValue(value)}
448
- disabled={question.Disabled}
449
- />
450
- </Form.Item>
451
-
452
- : question.IsNumerical
453
-
454
- ? <Form.Item
455
- name={["Questions", index, "Answer"]}
456
- >
457
- <InputNumber className={styles.inputNumberStyle} />
458
- </Form.Item>
459
-
460
- : <Form.Item
461
- name={["Questions", index, "Answer"]}
462
- >
463
- <Select
464
- options={selectedCategory.Data.IsYesOrNo
465
-
466
- ? props.selectYesNoOption
467
-
468
- : question?.Options?.length > 0
469
-
470
- ? question?.Options?.map((option: any) => ({
471
- label: form.getFieldValue(`Questions`)?.[index]?.IsMultipleChoise
472
- ?
473
- <Tag style={{
474
- backgroundColor: "rgba(0, 0, 0, 0.06)",
475
- color: "black"
476
- }}>{option?.Value}
477
- </Tag>
478
-
479
- : option.Value,
480
-
481
- value: option.Value,
482
- }))
483
-
484
- : evaluationOptions[selectedEvaluationOption]
485
- }
486
- mode={form.getFieldValue(`Questions`)?.[index]?.IsMultipleChoise ? "multiple" : undefined}
487
- customClass={styles.selectAnswerStyle}
488
- placeholder={form.getFieldValue(`Questions`)?.[index]?.IsMultipleChoise
489
- ? t('components.categoryResponse.placeholderForMultiple')
490
- : t('components.categoryResponse.placeholderForSingular')}
491
- />
492
- </Form.Item>
493
- }
494
- </div>
495
- </div>
496
- );
497
- })}
498
- </Form>
499
- </div >
500
- </div >
501
- );
502
- });