@omniumretail/component-library 1.1.80 → 1.1.82
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styles from './styles.module.scss';
|
|
2
2
|
import { useEffect, useImperativeHandle, useState } from 'react';
|
|
3
|
-
import { Form, UploadFile, Upload, DatePicker
|
|
3
|
+
import { Form, UploadFile, Upload, DatePicker } from 'antd';
|
|
4
4
|
import { useForm } from 'antd/es/form/Form';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import TextArea from 'antd/es/input/TextArea';
|
|
@@ -9,6 +9,7 @@ import { evaluationOptions } from './evaluationOptions';
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import { t } from 'i18next';
|
|
11
11
|
import { Button } from '../Button';
|
|
12
|
+
import dayjs from 'dayjs';
|
|
12
13
|
|
|
13
14
|
interface CategoryResponse {
|
|
14
15
|
data: any;
|
|
@@ -84,15 +85,6 @@ const hasCategory = (currentKey: string, categories: Category[], direction: 'nex
|
|
|
84
85
|
return !!category;
|
|
85
86
|
};
|
|
86
87
|
|
|
87
|
-
const getDateToUnixInUTC = (date: Date): string | null => {
|
|
88
|
-
if (date === null) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const dateInUtc = new Date(Date.UTC(date?.getFullYear(), date?.getMonth(), date?.getDate(), 0, 0, 0));
|
|
93
|
-
return `${dateInUtc.getTime() / 1000}`;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
88
|
export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref) => {
|
|
97
89
|
const { data } = props;
|
|
98
90
|
|
|
@@ -102,6 +94,7 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
|
|
|
102
94
|
const [selectedCategory, setSelectedCategory] = useState<any>(data.CategoryAnswers[0]);
|
|
103
95
|
const [initialValues, setInitialValues] = useState<any>(data.CategoryAnswers[0].Data);
|
|
104
96
|
const [fileLists, setFileLists] = useState<Record<string, UploadFile[]>>({});
|
|
97
|
+
const [dataValue, setDataValue] = useState<any>();
|
|
105
98
|
const [isNoteVisible, setIsNoteVisible] = useState<{ categoryIndex: number; questionIndex: number } | null>(null);
|
|
106
99
|
const [form] = useForm();
|
|
107
100
|
|
|
@@ -116,9 +109,11 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
|
|
|
116
109
|
Questions: Questions.map((question: any) => ({
|
|
117
110
|
Subject: question.Subject,
|
|
118
111
|
Description: question.Description,
|
|
119
|
-
Answer: question.Answer
|
|
112
|
+
Answer: props.addButtons ? (question.IsDate ? (question?.Answer?.length > 0 ? dayjs.unix(Number(question?.Answer?.[0])) : null) : question.Answer) : question.Answer,
|
|
120
113
|
Note: question.Note || "",
|
|
121
|
-
IsMultipleChoise: question.IsMultipleChoise || false
|
|
114
|
+
IsMultipleChoise: question.IsMultipleChoise || false,
|
|
115
|
+
IsDate: question.IsDate || false,
|
|
116
|
+
IsOpenAnswer: question.IsOpenAnswer || false,
|
|
122
117
|
})),
|
|
123
118
|
OpenAnswer: OpenAnswer,
|
|
124
119
|
IsYesOrNo: IsYesOrNo
|
|
@@ -186,11 +181,11 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
|
|
|
186
181
|
...question,
|
|
187
182
|
Answer: !props.addButtons
|
|
188
183
|
? values.Questions[index].Answer
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
184
|
+
: Array.isArray(values.Questions[index].Answer)
|
|
185
|
+
? values.Questions[index].Answer
|
|
186
|
+
: values.Questions[index].Answer
|
|
187
|
+
? [values.Questions[index].Answer]
|
|
188
|
+
: [],
|
|
194
189
|
Note: values.Questions[index].Note,
|
|
195
190
|
IsMultipleChoise: values.Questions[index].IsMultipleChoise,
|
|
196
191
|
Files: fileLists[`${selectedCategory.Data.CategoryId}_${index}`] || [], // Include files in the form data
|
|
@@ -389,6 +384,9 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
|
|
|
389
384
|
className={styles.select}
|
|
390
385
|
placeholder={''}
|
|
391
386
|
format={dateFormatList}
|
|
387
|
+
value={dataValue}
|
|
388
|
+
defaultValue={form.getFieldValue(`Questions`)?.[index].Answer}
|
|
389
|
+
onChange={(value) => setDataValue(value)}
|
|
392
390
|
/>
|
|
393
391
|
</Form.Item>
|
|
394
392
|
|
|
@@ -28,7 +28,7 @@ export const SingleQuestion = ({
|
|
|
28
28
|
const formContext = useContext(FieldContext);
|
|
29
29
|
|
|
30
30
|
const filteredIds = responseTypeOptions
|
|
31
|
-
|
|
31
|
+
?.filter((item: { IsMultipleChoise: any; }) => item.IsMultipleChoise)
|
|
32
32
|
.map((item: { Id: any; }) => item.Id);
|
|
33
33
|
|
|
34
34
|
const answerTypeOptions = responseTypeOptions?.map((answerType: any) => ({
|
|
@@ -159,7 +159,7 @@ export const SingleQuestion = ({
|
|
|
159
159
|
<span>{t('components.category.emphasisAnswer')}</span>
|
|
160
160
|
</div>
|
|
161
161
|
|
|
162
|
-
{filteredIds
|
|
162
|
+
{filteredIds?.includes(formContext.getFieldsValue().questions?.[name]?.responseType) &&
|
|
163
163
|
< div className={styles.checkboxContainer}>
|
|
164
164
|
<Form.Item
|
|
165
165
|
{...restField}
|