@omniumretail/component-library 1.1.37 → 1.1.38
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
|
@@ -184,6 +184,7 @@ Primary.args = {
|
|
|
184
184
|
"CategoryId": "PCDED10D-0984-46D4-A9B3-7EC518D74A63",
|
|
185
185
|
"CategoryName": "Category 2.2",
|
|
186
186
|
"OpenAnswer": false,
|
|
187
|
+
"IsYesOrNo": true,
|
|
187
188
|
"GeneralEvaluationLevel": 0,
|
|
188
189
|
"Grade": "50",
|
|
189
190
|
"Description": "This is a description",
|
|
@@ -195,7 +196,7 @@ Primary.args = {
|
|
|
195
196
|
"Subject": "This is a Subject",
|
|
196
197
|
"Description": "This is a description",
|
|
197
198
|
"Grade": "50",
|
|
198
|
-
"Answer":
|
|
199
|
+
"Answer": null
|
|
199
200
|
},
|
|
200
201
|
{
|
|
201
202
|
"Id": "P5562A64-A24B-425A-A345-560238CA2468",
|
|
@@ -203,7 +204,7 @@ Primary.args = {
|
|
|
203
204
|
"Subject": "This is a Subject",
|
|
204
205
|
"Description": "This is a description",
|
|
205
206
|
"Grade": "50",
|
|
206
|
-
"Answer": "
|
|
207
|
+
"Answer": "Yes"
|
|
207
208
|
}
|
|
208
209
|
]
|
|
209
210
|
},
|
|
@@ -24,6 +24,17 @@ type Category = {
|
|
|
24
24
|
Children?: Category[];
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
const selectYesNoOption = [
|
|
28
|
+
{
|
|
29
|
+
value: 'Yes',
|
|
30
|
+
label: t('components.categoryResponse.yes'),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
value: 'No',
|
|
34
|
+
label: t('components.categoryResponse.no'),
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
|
|
27
38
|
const updateCategoryAnswers = (CategoryAnswers: any[], categoryToUpdate: any, updatedQuestions: any) => {
|
|
28
39
|
CategoryAnswers.forEach((category: any) => {
|
|
29
40
|
if (category.Data.CategoryId === categoryToUpdate.CategoryId) {
|
|
@@ -83,9 +94,9 @@ const getTitleWithQuestionCount = (category: any): string => {
|
|
|
83
94
|
const questionCount = category?.Data?.Questions?.length;
|
|
84
95
|
const answeredQuestions = category?.Data?.Questions?.filter((question: any) => question.Answer !== null && question.Answer !== undefined && question.Answer !== '').length;
|
|
85
96
|
|
|
86
|
-
return questionCount
|
|
87
|
-
? `${category.Title} - ${answeredQuestions} / ${questionCount}`
|
|
88
|
-
: category.Title
|
|
97
|
+
return questionCount
|
|
98
|
+
? `${category.Title} - ${answeredQuestions} / ${questionCount}`
|
|
99
|
+
: category.Title;
|
|
89
100
|
};
|
|
90
101
|
|
|
91
102
|
export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref) => {
|
|
@@ -97,12 +108,13 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
|
|
|
97
108
|
const [selectedCategory, setSelectedCategory] = useState<any>(data.CategoryAnswers[0]);
|
|
98
109
|
const [initialValues, setInitialValues] = useState<any>(data.CategoryAnswers[0].Data);
|
|
99
110
|
const [form] = useForm();
|
|
100
|
-
|
|
111
|
+
|
|
101
112
|
|
|
102
113
|
const updateInitialValues = (data: any) => {
|
|
103
114
|
const {
|
|
104
115
|
Questions,
|
|
105
|
-
OpenAnswer
|
|
116
|
+
OpenAnswer,
|
|
117
|
+
IsYesOrNo
|
|
106
118
|
} = data;
|
|
107
119
|
|
|
108
120
|
const initial = {
|
|
@@ -111,7 +123,8 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
|
|
|
111
123
|
Description: question.Description,
|
|
112
124
|
Answer: question.Answer || ""
|
|
113
125
|
})),
|
|
114
|
-
OpenAnswer: OpenAnswer
|
|
126
|
+
OpenAnswer: OpenAnswer,
|
|
127
|
+
IsYesOrNo: IsYesOrNo
|
|
115
128
|
};
|
|
116
129
|
|
|
117
130
|
setInitialValues(initial);
|
|
@@ -175,19 +188,19 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
|
|
|
175
188
|
setCurrentKey(nextCategory.Key);
|
|
176
189
|
setSelectedCategory(nextCategory);
|
|
177
190
|
}
|
|
178
|
-
|
|
191
|
+
|
|
179
192
|
const nextCategoryData = getCategoryObject(currentKey, localData.CategoryAnswers, 'next');
|
|
180
193
|
setSelectedCategory(nextCategoryData ? { ...nextCategory, data: nextCategoryData } : null);
|
|
181
194
|
updateInitialValues(nextCategoryData);
|
|
182
195
|
};
|
|
183
|
-
|
|
196
|
+
|
|
184
197
|
const handlePreviousClick = () => {
|
|
185
198
|
const prevCategory = findCategoryWithQuestions(currentKey, localData.CategoryAnswers, 'prev');
|
|
186
199
|
if (prevCategory) {
|
|
187
200
|
setCurrentKey(prevCategory.Key);
|
|
188
201
|
setSelectedCategory(prevCategory);
|
|
189
202
|
}
|
|
190
|
-
|
|
203
|
+
|
|
191
204
|
const prevCategoryData = getCategoryObject(currentKey, localData.CategoryAnswers, 'prev');
|
|
192
205
|
setSelectedCategory(prevCategoryData ? { ...prevCategory, data: prevCategoryData } : null);
|
|
193
206
|
updateInitialValues(prevCategoryData);
|
|
@@ -222,7 +235,7 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
|
|
|
222
235
|
return (
|
|
223
236
|
<div className={styles.categoryResponse}>
|
|
224
237
|
<div className={styles.sidebarWrapper}>
|
|
225
|
-
<div className={styles.title}>
|
|
238
|
+
<div className={styles.title}>{t('components.categoryReadOnly.categories')}</div>
|
|
226
239
|
{renderCategories(localData.CategoryAnswers)}
|
|
227
240
|
</div>
|
|
228
241
|
<div className={styles.contentWrapper}>
|
|
@@ -259,13 +272,23 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
|
|
|
259
272
|
>
|
|
260
273
|
<TextArea />
|
|
261
274
|
</Form.Item>
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
275
|
+
|
|
276
|
+
: selectedCategory.Data.IsYesOrNo
|
|
277
|
+
? <Form.Item
|
|
278
|
+
name={["Questions", index, "Answer"]}
|
|
279
|
+
>
|
|
280
|
+
<Select options={selectYesNoOption}
|
|
281
|
+
style={{ minWidth: '100%' }}
|
|
282
|
+
/>
|
|
283
|
+
</Form.Item>
|
|
284
|
+
|
|
285
|
+
: <Form.Item
|
|
286
|
+
name={["Questions", index, "Answer"]}
|
|
287
|
+
>
|
|
288
|
+
<Select options={evaluationOptions[selectedEvaluationOption]}
|
|
289
|
+
style={{ minWidth: '100%' }}
|
|
290
|
+
/>
|
|
291
|
+
</Form.Item>
|
|
269
292
|
}
|
|
270
293
|
</div>
|
|
271
294
|
</div>
|
package/src/locales/en.json
CHANGED
package/src/locales/es.json
CHANGED
|
@@ -56,13 +56,15 @@
|
|
|
56
56
|
"categoryNameError": "Error/Nombre de Categoría Faltante",
|
|
57
57
|
"weighting": "Ponderación",
|
|
58
58
|
"openAnswer": "Respuesta Abierta",
|
|
59
|
-
"yesNoAnswer": "Respuesta Si/
|
|
59
|
+
"yesNoAnswer": "Respuesta Si/No",
|
|
60
60
|
"answerOption": "Opción de Respuesta",
|
|
61
61
|
"answers": "Respuestas"
|
|
62
62
|
},
|
|
63
63
|
"categoryResponse": {
|
|
64
64
|
"notApplicable": "No Aplicable",
|
|
65
|
-
"answer": "Respuesta"
|
|
65
|
+
"answer": "Respuesta",
|
|
66
|
+
"yes": "Si",
|
|
67
|
+
"no": "No"
|
|
66
68
|
},
|
|
67
69
|
"categoryReadOnly": {
|
|
68
70
|
"categories": "Categorías",
|