@omniumretail/component-library 1.1.75 → 1.1.76
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/bundle.js +1 -1
- package/package.json +1 -1
- package/src/components/Category/Category.stories.tsx +4 -7
- package/src/components/CategoryResponse/CategoryResponse.stories.tsx +10 -6
- package/src/components/CategoryResponse/index.tsx +6 -3
- package/src/components/Questions/SingleQuestion/index.tsx +24 -6
package/package.json
CHANGED
|
@@ -46,6 +46,7 @@ const Template: Story<any> = (args) => {
|
|
|
46
46
|
"IsNumeric": false,
|
|
47
47
|
"HasGrade": false,
|
|
48
48
|
"IsEmphasis": false,
|
|
49
|
+
"IsMultipleChoise": true,
|
|
49
50
|
"State": "Draft",
|
|
50
51
|
"Grade": 0,
|
|
51
52
|
"Options": [
|
|
@@ -75,6 +76,7 @@ const Template: Story<any> = (args) => {
|
|
|
75
76
|
"IsNumeric": false,
|
|
76
77
|
"HasGrade": false,
|
|
77
78
|
"IsEmphasis": false,
|
|
79
|
+
"IsMultipleChoise": true,
|
|
78
80
|
"State": "Draft",
|
|
79
81
|
"Grade": 0,
|
|
80
82
|
"Options": [
|
|
@@ -104,6 +106,7 @@ const Template: Story<any> = (args) => {
|
|
|
104
106
|
"IsNumeric": false,
|
|
105
107
|
"HasGrade": false,
|
|
106
108
|
"IsEmphasis": false,
|
|
109
|
+
"IsMultipleChoise": false,
|
|
107
110
|
"State": "Finished",
|
|
108
111
|
"Grade": 0,
|
|
109
112
|
"Options": [
|
|
@@ -127,13 +130,7 @@ const Template: Story<any> = (args) => {
|
|
|
127
130
|
}
|
|
128
131
|
]
|
|
129
132
|
|
|
130
|
-
|
|
131
|
-
value: answerType?.Id,
|
|
132
|
-
label: answerType?.Name
|
|
133
|
-
}));
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return <Category {...args} chooseResponse serverReadyData={setServerData} responseTypeOptions={answerTypeOptions} hasHeader data={[]}></Category>
|
|
133
|
+
return <Category {...args} chooseResponse serverReadyData={setServerData} responseTypeOptions={getAnswerTypeOptions} hasHeader data={[]}></Category>
|
|
137
134
|
};
|
|
138
135
|
|
|
139
136
|
export const Primary = Template.bind({});
|
|
@@ -38,7 +38,7 @@ const Template: Story<any> = (args) => {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
useEffect(() => {
|
|
41
|
-
|
|
41
|
+
console.log(serverData);
|
|
42
42
|
}, [serverData])
|
|
43
43
|
|
|
44
44
|
return (
|
|
@@ -175,7 +175,8 @@ Primary.args = {
|
|
|
175
175
|
"Subject": "This is a Subject",
|
|
176
176
|
"Description": "This is a description",
|
|
177
177
|
"Grade": "25",
|
|
178
|
-
"Answer": null
|
|
178
|
+
"Answer": null,
|
|
179
|
+
"IsMultipleChoise": false
|
|
179
180
|
},
|
|
180
181
|
{
|
|
181
182
|
"Id": "35562A64-A24B-425A-A345-560238CA2468",
|
|
@@ -183,7 +184,8 @@ Primary.args = {
|
|
|
183
184
|
"Subject": "This is a Subject",
|
|
184
185
|
"Description": "This is a description",
|
|
185
186
|
"Grade": "25",
|
|
186
|
-
"Answer": null
|
|
187
|
+
"Answer": null,
|
|
188
|
+
"IsMultipleChoise": true
|
|
187
189
|
}
|
|
188
190
|
]
|
|
189
191
|
}
|
|
@@ -233,7 +235,7 @@ Primary.args = {
|
|
|
233
235
|
"Id": "97A06838-67F9-4726-BC36-719A0C797484",
|
|
234
236
|
"CategoryId": "CATEGORYID3",
|
|
235
237
|
"CategoryName": "Category 3",
|
|
236
|
-
"OpenAnswer":
|
|
238
|
+
"OpenAnswer": false,
|
|
237
239
|
"GeneralEvaluationLevel": 0,
|
|
238
240
|
"Grade": "0",
|
|
239
241
|
"Description": "This is a description",
|
|
@@ -245,7 +247,8 @@ Primary.args = {
|
|
|
245
247
|
"Subject": "This is a Subject",
|
|
246
248
|
"Description": "This is a description",
|
|
247
249
|
"Grade": "0",
|
|
248
|
-
"Answer": "dwjdiwjdiwjdi"
|
|
250
|
+
"Answer": "dwjdiwjdiwjdi",
|
|
251
|
+
"IsOpenAnswer": true
|
|
249
252
|
},
|
|
250
253
|
{
|
|
251
254
|
"Id": "93862A64-A24B-425A-A345-560238CA2468",
|
|
@@ -253,7 +256,8 @@ Primary.args = {
|
|
|
253
256
|
"Subject": "This is a Subject",
|
|
254
257
|
"Description": "This is a description",
|
|
255
258
|
"Grade": "0",
|
|
256
|
-
"Answer": null
|
|
259
|
+
"Answer": null,
|
|
260
|
+
"IsMultipleChoise": true
|
|
257
261
|
}
|
|
258
262
|
]
|
|
259
263
|
}
|
|
@@ -16,7 +16,7 @@ interface CategoryResponse {
|
|
|
16
16
|
onNextCategoryAvailabilityChange: (hasNext: boolean) => void;
|
|
17
17
|
onPreviousCategoryAvailabilityChange: (hasPrevious: boolean) => void;
|
|
18
18
|
selectYesNoOption?: any;
|
|
19
|
-
addAction?: (questionId: string, questionAnswerId:string) => void;
|
|
19
|
+
addAction?: (questionId: string, questionAnswerId: string) => void;
|
|
20
20
|
addButtons?: boolean;
|
|
21
21
|
fileList?: React.Dispatch<React.SetStateAction<Record<string, UploadFile<any>[]>>>;
|
|
22
22
|
};
|
|
@@ -117,7 +117,8 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
|
|
|
117
117
|
Subject: question.Subject,
|
|
118
118
|
Description: question.Description,
|
|
119
119
|
Answer: question.Answer || "",
|
|
120
|
-
Note: question.Note || ""
|
|
120
|
+
Note: question.Note || "",
|
|
121
|
+
IsMultipleChoise: question.IsMultipleChoise || false
|
|
121
122
|
})),
|
|
122
123
|
OpenAnswer: OpenAnswer,
|
|
123
124
|
IsYesOrNo: IsYesOrNo
|
|
@@ -174,6 +175,7 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
|
|
|
174
175
|
...question,
|
|
175
176
|
Answer: values.Questions[index].Answer,
|
|
176
177
|
Note: values.Questions[index].Note,
|
|
178
|
+
IsMultipleChoise: values.Questions[index].IsMultipleChoise,
|
|
177
179
|
Files: fileLists[`${selectedCategory.Data.CategoryId}_${index}`] || [], // Include files in the form data
|
|
178
180
|
};
|
|
179
181
|
});
|
|
@@ -347,7 +349,7 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
|
|
|
347
349
|
|
|
348
350
|
<Button customClass={styles.actionsButtons} onClick={() => handleAddAction(question.QuestionId, question.Id)}>
|
|
349
351
|
{t('components.categoryResponse.createAction')}
|
|
350
|
-
|
|
352
|
+
</Button>
|
|
351
353
|
</div>
|
|
352
354
|
</>
|
|
353
355
|
}
|
|
@@ -371,6 +373,7 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
|
|
|
371
373
|
: evaluationOptions[selectedEvaluationOption]
|
|
372
374
|
}
|
|
373
375
|
// style={{ minWidth: '100%' }}
|
|
376
|
+
mode={form.getFieldValue(`Questions`)?.[index]?.IsMultipleChoise ? "multiple" : undefined}
|
|
374
377
|
customClass={styles.selectAnswerStyle}
|
|
375
378
|
/>
|
|
376
379
|
</Form.Item>
|
|
@@ -2,9 +2,10 @@ import { DeleteOutlined, HolderOutlined, InfoCircleOutlined } from '@ant-design/
|
|
|
2
2
|
import { Checkbox, ColorPicker, Form, Input, Space } from 'antd';
|
|
3
3
|
import { t } from 'i18next';
|
|
4
4
|
import styles from './styles.module.scss';
|
|
5
|
-
import { useState } from 'react';
|
|
5
|
+
import { useContext, useState } from 'react';
|
|
6
6
|
import { Select } from 'antd';
|
|
7
7
|
import classnames from 'classnames';
|
|
8
|
+
import { FieldContext } from 'rc-field-form';
|
|
8
9
|
|
|
9
10
|
export const SingleQuestion = ({
|
|
10
11
|
key,
|
|
@@ -24,6 +25,19 @@ export const SingleQuestion = ({
|
|
|
24
25
|
const [emphasisCheckbox, setEmphasisCheckbox] = useState<boolean>(false);
|
|
25
26
|
const [multipleChoiseCheckbox, setMultipleChoiseCheckbox] = useState<boolean>(false);
|
|
26
27
|
|
|
28
|
+
const formContext = useContext(FieldContext);
|
|
29
|
+
|
|
30
|
+
const filteredIds = responseTypeOptions
|
|
31
|
+
.filter((item: { IsMultipleChoise: any; }) => item.IsMultipleChoise)
|
|
32
|
+
.map((item: { Id: any; }) => item.Id);
|
|
33
|
+
|
|
34
|
+
const answerTypeOptions = responseTypeOptions?.map((answerType: any) => ({
|
|
35
|
+
value: answerType?.Id,
|
|
36
|
+
label: answerType?.Name
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
console.log(filteredIds);
|
|
40
|
+
|
|
27
41
|
const onCheckboxMultipeChoiseHandler = (checked: boolean) => {
|
|
28
42
|
setMultipleChoiseCheckbox(checked);
|
|
29
43
|
handleChanges();
|
|
@@ -145,7 +159,8 @@ export const SingleQuestion = ({
|
|
|
145
159
|
<span>{t('components.category.emphasisAnswer')}</span>
|
|
146
160
|
</div>
|
|
147
161
|
|
|
148
|
-
|
|
162
|
+
{filteredIds.includes(formContext.getFieldsValue().questions?.[name]?.responseType) &&
|
|
163
|
+
< div className={styles.checkboxContainer}>
|
|
149
164
|
<Form.Item
|
|
150
165
|
{...restField}
|
|
151
166
|
name={[name, 'multipleChoise']}
|
|
@@ -156,6 +171,8 @@ export const SingleQuestion = ({
|
|
|
156
171
|
|
|
157
172
|
<span>{t('components.category.multipleChoise')}</span>
|
|
158
173
|
</div>
|
|
174
|
+
}
|
|
175
|
+
|
|
159
176
|
</>
|
|
160
177
|
}
|
|
161
178
|
|
|
@@ -166,7 +183,7 @@ export const SingleQuestion = ({
|
|
|
166
183
|
rules={[{ required: true, message: t('components.category.errorResponseType')! }]}
|
|
167
184
|
>
|
|
168
185
|
<Select
|
|
169
|
-
options={
|
|
186
|
+
options={answerTypeOptions}
|
|
170
187
|
onBlur={handleChanges}
|
|
171
188
|
className={styles.selectResponseType}
|
|
172
189
|
/>
|
|
@@ -177,7 +194,8 @@ export const SingleQuestion = ({
|
|
|
177
194
|
</div>
|
|
178
195
|
}
|
|
179
196
|
|
|
180
|
-
{
|
|
197
|
+
{
|
|
198
|
+
responseTypeComponent &&
|
|
181
199
|
<div className={styles.questionFooter}>
|
|
182
200
|
<div />
|
|
183
201
|
|
|
@@ -218,7 +236,7 @@ export const SingleQuestion = ({
|
|
|
218
236
|
</div>
|
|
219
237
|
</div>
|
|
220
238
|
}
|
|
221
|
-
</Space>
|
|
222
|
-
</div>
|
|
239
|
+
</Space >
|
|
240
|
+
</div >
|
|
223
241
|
);
|
|
224
242
|
};
|