@omniumretail/component-library 1.2.70 → 1.2.72
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.
- package/dist/component-library.umd.js +1154 -0
- package/dist/{types/components → components}/AnalyticsBar/helpers/codeMutation.d.ts +2 -2
- package/dist/{types/components → components}/AnalyticsBar/index.d.ts +2 -1
- package/dist/{types/components → components}/Button/index.d.ts +2 -1
- package/dist/{types/components → components}/Category/index.d.ts +2 -1
- package/dist/{types/components → components}/CategoryReadOnly/index.d.ts +2 -1
- package/dist/{types/components → components}/CategoryResponse/index.d.ts +3 -2
- package/dist/{types/components → components}/DatePicker/index.d.ts +2 -1
- package/dist/{types/components → components}/DatePickerTag/index.d.ts +2 -1
- package/dist/{types/components → components}/DropdownButton/index.d.ts +3 -2
- package/dist/{types/components → components}/Footer2/index.d.ts +2 -1
- package/dist/{types/components → components}/Header/Header.data.d.ts +2 -1
- package/dist/{types/components → components}/Header/Header.types.d.ts +2 -1
- package/dist/{types/components → components}/Header/index.d.ts +2 -1
- package/dist/{types/components → components}/Input/index.d.ts +2 -1
- package/dist/{types/components → components}/InputCountryCode/index.d.ts +2 -1
- package/dist/{types/components → components}/Link/index.d.ts +2 -1
- package/dist/{types/components → components}/Menu/helpers/codeMutation.d.ts +2 -2
- package/dist/{types/components → components}/Menu/index.d.ts +2 -1
- package/dist/{types/components → components}/MobileTable/index.d.ts +2 -1
- package/dist/{types/components → components}/ModalWithTable/index.d.ts +2 -1
- package/dist/{types/components → components}/Notification/index.d.ts +2 -1
- package/dist/{types/components → components}/Radio/index.d.ts +3 -2
- package/dist/{types/components → components}/ResponsiveTable/index.d.ts +2 -1
- package/dist/{types/components → components}/Select/index.d.ts +2 -1
- package/dist/{types/components → components}/Switch/index.d.ts +2 -1
- package/dist/{types/components → components}/Table/index.d.ts +2 -1
- package/dist/{types/components → components}/Tag/index.d.ts +3 -2
- package/dist/{types/components → components}/Upload/index.d.ts +3 -2
- package/dist/{types/components → components}/WebCam/index.d.ts +2 -1
- package/{src/locales/en.json → dist/locales/en.json.d.ts} +4 -2
- package/{src/locales/es.json → dist/locales/es.json.d.ts} +4 -2
- package/{src/locales/pt.json → dist/locales/pt.json.d.ts} +4 -1
- package/package.json +98 -183
- package/NPMPUBLISH.md +0 -29
- package/bitbucket-pipelines.yml +0 -95
- package/dist/780.bundle.js +0 -1
- package/dist/838.bundle.js +0 -2
- package/dist/838.bundle.js.LICENSE.txt +0 -1
- package/dist/bundle.js +0 -2
- package/dist/bundle.js.LICENSE.txt +0 -451
- package/dist/main.css +0 -36
- package/dist/types/components/AnalyticsBar/AnalyticsBar.stories.d.ts +0 -4
- package/dist/types/components/BellNotifications/BellNotifications.stories.d.ts +0 -4
- package/dist/types/components/Button/Button.stories.d.ts +0 -5
- package/dist/types/components/Category/Category.stories.d.ts +0 -3
- package/dist/types/components/CategoryReadOnly/CategoryReadOnly.stories.d.ts +0 -3
- package/dist/types/components/CategoryResponse/CategoryResponse.stories.d.ts +0 -3
- package/dist/types/components/DatePicker/DatePicker.stories.d.ts +0 -4
- package/dist/types/components/DatePickerTag/DatePickerTag.stories.d.ts +0 -4
- package/dist/types/components/DropdownButton/DropdownButton.stories.d.ts +0 -4
- package/dist/types/components/ExportTableData/ExportTableData.stories.d.ts +0 -3
- package/dist/types/components/Footer/Footer.stories.d.ts +0 -4
- package/dist/types/components/Footer2/Footer.stories.d.ts +0 -5
- package/dist/types/components/Header/Header.stories.d.ts +0 -4
- package/dist/types/components/Input/Input.stories.d.ts +0 -4
- package/dist/types/components/InputCountryCode/inputCountryCode.stories.d.ts +0 -4
- package/dist/types/components/Label/Label.stories.d.ts +0 -5
- package/dist/types/components/Link/Link.stories.d.ts +0 -6
- package/dist/types/components/Menu/Menu.stories.d.ts +0 -4
- package/dist/types/components/MobileTable/MobileTable.stories.d.ts +0 -4
- package/dist/types/components/ModalConfirmation/ModalConfirmation.stories.d.ts +0 -4
- package/dist/types/components/ModalWithTable/ModalWithTable.stories.d.ts +0 -4
- package/dist/types/components/Navigation/Navigation.stories.d.ts +0 -4
- package/dist/types/components/Notification/Notification.stories.d.ts +0 -4
- package/dist/types/components/Questions/Questions.stories.d.ts +0 -3
- package/dist/types/components/Radio/Radio.stories.d.ts +0 -4
- package/dist/types/components/ResponseType/ResponseType.stories.d.ts +0 -3
- package/dist/types/components/ResponsiveTable/ResponsiveTable.stories.d.ts +0 -8
- package/dist/types/components/Select/Select.stories.d.ts +0 -5
- package/dist/types/components/Separator/Separator.stories.d.ts +0 -5
- package/dist/types/components/Sidebar/Sidebar.stories.d.ts +0 -5
- package/dist/types/components/Switch/Switch.stories.d.ts +0 -4
- package/dist/types/components/Table/Table.stories.d.ts +0 -8
- package/dist/types/components/Tag/Tag.stories.d.ts +0 -4
- package/dist/types/components/Upload/Upload.stories.d.ts +0 -3
- package/dist/types/components/UserInfo/UserInfo.stories.d.ts +0 -3
- package/dist/types/components/WebCam/WebCam.stories.d.ts +0 -3
- package/src/assets/code-brackets.svg +0 -1
- package/src/assets/colors.svg +0 -1
- package/src/assets/comments.svg +0 -1
- package/src/assets/direction.svg +0 -1
- package/src/assets/flow.svg +0 -1
- package/src/assets/fonts/Silka-Bold.woff2 +0 -0
- package/src/assets/fonts/Silka-Regular.woff2 +0 -0
- package/src/assets/images/A2AI-logo.png +0 -0
- package/src/assets/images/omnium-retail-logo-white.png +0 -0
- package/src/assets/images/omnium-retail-logo.png +0 -0
- package/src/assets/images/omnium-retail_icon.png +0 -0
- package/src/assets/plugin.svg +0 -1
- package/src/assets/repo.svg +0 -1
- package/src/assets/scss/_combinations.scss +0 -0
- package/src/assets/scss/_global.scss +0 -89
- package/src/assets/scss/index.scss +0 -2
- package/src/assets/stackalt.svg +0 -1
- package/src/components/AnalyticsBar/AnalyticsBar.stories.tsx +0 -236
- package/src/components/AnalyticsBar/helpers/codeMutation.tsx +0 -19
- package/src/components/AnalyticsBar/index.tsx +0 -76
- package/src/components/AnalyticsBar/interfaces/analyticsBar.tsx +0 -13
- package/src/components/AnalyticsBar/styles.module.scss +0 -137
- package/src/components/BellNotifications/BellNotifications.stories.tsx +0 -200
- package/src/components/BellNotifications/index.tsx +0 -154
- package/src/components/BellNotifications/styles.module.scss +0 -239
- package/src/components/Button/Button.stories.tsx +0 -26
- package/src/components/Button/index.tsx +0 -24
- package/src/components/Button/styles.module.scss +0 -70
- package/src/components/Category/Category.stories.tsx +0 -371
- package/src/components/Category/CategoryContent/index.tsx +0 -255
- package/src/components/Category/CategoryContent/styles.module.scss +0 -69
- package/src/components/Category/CategorySidebar/index.tsx +0 -344
- package/src/components/Category/CategorySidebar/styles.module.scss +0 -28
- package/src/components/Category/index.tsx +0 -58
- package/src/components/Category/styles.module.scss +0 -13
- package/src/components/CategoryReadOnly/CategoryReadOnly.stories.tsx +0 -274
- package/src/components/CategoryReadOnly/evaluationOptions.tsx +0 -81
- package/src/components/CategoryReadOnly/index.tsx +0 -328
- package/src/components/CategoryReadOnly/styles.module.scss +0 -214
- package/src/components/CategoryResponse/CategoryResponse.stories.tsx +0 -312
- package/src/components/CategoryResponse/evaluationOptions.tsx +0 -81
- package/src/components/CategoryResponse/index.tsx +0 -502
- package/src/components/CategoryResponse/styles.module.scss +0 -365
- package/src/components/DatePicker/DatePicker.stories.tsx +0 -16
- package/src/components/DatePicker/index.tsx +0 -38
- package/src/components/DatePicker/styles.module.scss +0 -3
- package/src/components/DatePickerTag/DatePickerTag.stories.tsx +0 -19
- package/src/components/DatePickerTag/index.tsx +0 -91
- package/src/components/DatePickerTag/styles.module.scss +0 -32
- package/src/components/DropdownButton/DropdownButton.stories.tsx +0 -24
- package/src/components/DropdownButton/index.tsx +0 -36
- package/src/components/DropdownButton/styles.module.scss +0 -9
- package/src/components/ExportTableData/ExportTableData.stories.tsx +0 -43
- package/src/components/ExportTableData/index.tsx +0 -37
- package/src/components/ExportTableData/styles.module.scss +0 -4
- package/src/components/Footer/Footer.stories.tsx +0 -15
- package/src/components/Footer/index.tsx +0 -45
- package/src/components/Footer/styles.module.scss +0 -38
- package/src/components/Footer2/Footer.stories.tsx +0 -184
- package/src/components/Footer2/index.tsx +0 -322
- package/src/components/Footer2/styles.module.scss +0 -292
- package/src/components/Header/Header.data.ts +0 -26
- package/src/components/Header/Header.stories.tsx +0 -236
- package/src/components/Header/Header.types.ts +0 -32
- package/src/components/Header/README.md +0 -38
- package/src/components/Header/index.tsx +0 -200
- package/src/components/Header/styles.module.scss +0 -216
- package/src/components/Input/Input.stories.tsx +0 -13
- package/src/components/Input/index.tsx +0 -31
- package/src/components/Input/styles.module.scss +0 -8
- package/src/components/InputCountryCode/index.tsx +0 -79
- package/src/components/InputCountryCode/inputCountryCode.stories.tsx +0 -55
- package/src/components/InputCountryCode/styles.module.scss +0 -3
- package/src/components/Label/Label.stories.tsx +0 -21
- package/src/components/Label/index.tsx +0 -19
- package/src/components/Label/styles.module.scss +0 -17
- package/src/components/Link/Link.stories.tsx +0 -30
- package/src/components/Link/index.tsx +0 -21
- package/src/components/Link/styles.module.scss +0 -24
- package/src/components/Menu/Menu.stories.tsx +0 -178
- package/src/components/Menu/helpers/codeMutation.tsx +0 -19
- package/src/components/Menu/index.tsx +0 -24
- package/src/components/Menu/styles.module.scss +0 -0
- package/src/components/MobileTable/MobileTable.stories.tsx +0 -27
- package/src/components/MobileTable/index.tsx +0 -102
- package/src/components/MobileTable/styles.module.scss +0 -75
- package/src/components/ModalConfirmation/ModalConfirmation.stories.tsx +0 -40
- package/src/components/ModalConfirmation/ModalStatusList.tsx +0 -5
- package/src/components/ModalConfirmation/index.tsx +0 -71
- package/src/components/ModalConfirmation/styles.module.scss +0 -62
- package/src/components/ModalWithTable/ModalWithTable.stories.tsx +0 -99
- package/src/components/ModalWithTable/index.tsx +0 -238
- package/src/components/ModalWithTable/styles.module.scss +0 -77
- package/src/components/Navigation/Navigation.stories.tsx +0 -21
- package/src/components/Navigation/index.tsx +0 -91
- package/src/components/Navigation/styles.module.scss +0 -91
- package/src/components/Notification/Notification.stories.tsx +0 -32
- package/src/components/Notification/index.tsx +0 -28
- package/src/components/Questions/Questions.stories.tsx +0 -37
- package/src/components/Questions/SingleQuestion/index.tsx +0 -337
- package/src/components/Questions/SingleQuestion/styles.module.scss +0 -142
- package/src/components/Questions/index.tsx +0 -124
- package/src/components/Questions/styles.modules.scss +0 -0
- package/src/components/Radio/Radio.stories.tsx +0 -43
- package/src/components/Radio/index.tsx +0 -26
- package/src/components/Radio/styles.module.scss +0 -24
- package/src/components/ResponseType/ResponseType.stories.tsx +0 -393
- package/src/components/ResponseType/index.tsx +0 -100
- package/src/components/ResponseType/styles.module.scss +0 -31
- package/src/components/ResponsiveTable/ResponsiveTable.stories.tsx +0 -386
- package/src/components/ResponsiveTable/index.tsx +0 -389
- package/src/components/ResponsiveTable/styles.module.scss +0 -153
- package/src/components/Select/Select.stories.tsx +0 -39
- package/src/components/Select/index.tsx +0 -27
- package/src/components/Select/styles.module.scss +0 -19
- package/src/components/Separator/Separator.stories.tsx +0 -22
- package/src/components/Separator/index.tsx +0 -27
- package/src/components/Separator/styles.module.scss +0 -25
- package/src/components/Sidebar/Sidebar.stories.tsx +0 -85
- package/src/components/Sidebar/index.tsx +0 -127
- package/src/components/Sidebar/styles.module.scss +0 -141
- package/src/components/Switch/Switch.stories.tsx +0 -14
- package/src/components/Switch/index.tsx +0 -18
- package/src/components/Switch/styles.module.scss +0 -7
- package/src/components/Table/Table.stories.tsx +0 -337
- package/src/components/Table/index.tsx +0 -313
- package/src/components/Table/styles.module.scss +0 -97
- package/src/components/Tag/Tag.stories.tsx +0 -32
- package/src/components/Tag/index.tsx +0 -295
- package/src/components/Tag/styles.module.scss +0 -104
- package/src/components/Upload/Upload.stories.tsx +0 -45
- package/src/components/Upload/index.tsx +0 -112
- package/src/components/Upload/styles.module.scss +0 -29
- package/src/components/UserInfo/UserInfo.stories.tsx +0 -38
- package/src/components/UserInfo/index.tsx +0 -77
- package/src/components/UserInfo/styles.module.scss +0 -35
- package/src/components/WebCam/WebCam.stories.tsx +0 -24
- package/src/components/WebCam/index.tsx +0 -73
- package/src/components/WebCam/styles.module.scss +0 -37
- package/src/components/index.tsx +0 -34
- package/src/constants/i18n.ts +0 -25
- package/src/constants/logoCompanyHelper.ts +0 -52
- package/src/constants/translationHelper.ts +0 -7
- package/src/index.ts +0 -3
- package/src/types/Global.d.ts +0 -4
- package/tsconfig.json +0 -29
- package/webpack.config.js +0 -51
- /package/dist/{types/components → components}/AnalyticsBar/interfaces/analyticsBar.d.ts +0 -0
- /package/dist/{types/components → components}/BellNotifications/index.d.ts +0 -0
- /package/dist/{types/components → components}/Category/CategoryContent/index.d.ts +0 -0
- /package/dist/{types/components → components}/Category/CategorySidebar/index.d.ts +0 -0
- /package/dist/{types/components → components}/CategoryReadOnly/evaluationOptions.d.ts +0 -0
- /package/dist/{types/components → components}/CategoryResponse/evaluationOptions.d.ts +0 -0
- /package/dist/{types/components → components}/ExportTableData/index.d.ts +0 -0
- /package/dist/{types/components → components}/Footer/index.d.ts +0 -0
- /package/dist/{types/components → components}/Label/index.d.ts +0 -0
- /package/dist/{types/components → components}/ModalConfirmation/ModalStatusList.d.ts +0 -0
- /package/dist/{types/components → components}/ModalConfirmation/index.d.ts +0 -0
- /package/dist/{types/components → components}/Navigation/index.d.ts +0 -0
- /package/dist/{types/components → components}/Questions/SingleQuestion/index.d.ts +0 -0
- /package/dist/{types/components → components}/Questions/index.d.ts +0 -0
- /package/dist/{types/components → components}/ResponseType/index.d.ts +0 -0
- /package/dist/{types/components → components}/Separator/index.d.ts +0 -0
- /package/dist/{types/components → components}/Sidebar/index.d.ts +0 -0
- /package/dist/{types/components → components}/UserInfo/index.d.ts +0 -0
- /package/dist/{types/components → components}/index.d.ts +0 -0
- /package/dist/{types/constants → constants}/i18n.d.ts +0 -0
- /package/dist/{types/constants → constants}/logoCompanyHelper.d.ts +0 -0
- /package/dist/{types/constants → constants}/translationHelper.d.ts +0 -0
- /package/dist/{types/index.d.ts → index.d.ts} +0 -0
- /package/{public → dist}/index.ts +0 -0
|
@@ -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
|
-
});
|