@omniumretail/component-library 1.1.36 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omniumretail/component-library",
3
- "version": "1.1.36",
3
+ "version": "1.1.38",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -10,9 +10,9 @@ export default {
10
10
  const Template: Story<any> = (args) => {
11
11
  const [serverData, setServerData] = useState<any>();
12
12
 
13
- // useEffect(() => {
14
- // console.log(serverData);
15
- // }, [serverData])
13
+ useEffect(() => {
14
+ console.log(serverData);
15
+ }, [serverData])
16
16
 
17
17
  return <Category {...args} serverReadyData={setServerData} data={[
18
18
  {
@@ -21,6 +21,7 @@ const Template: Story<any> = (args) => {
21
21
  "data": {
22
22
  "categoryName": "2",
23
23
  "openAnswer": false,
24
+ "isYesOrNo": true,
24
25
  "generalEvaluationLevel": "0",
25
26
  "grade": "2",
26
27
  "questions": []
@@ -33,6 +34,7 @@ const Template: Story<any> = (args) => {
33
34
  "data": {
34
35
  "categoryName": "1",
35
36
  "openAnswer": false,
37
+ "isYesOrNo": false,
36
38
  "generalEvaluationLevel": "0",
37
39
  "grade": "1",
38
40
  "questions": []
@@ -44,6 +46,7 @@ const Template: Story<any> = (args) => {
44
46
  "data": {
45
47
  "categoryName": "1.1",
46
48
  "openAnswer": false,
49
+ "isYesOrNo": false,
47
50
  "generalEvaluationLevel": "0",
48
51
  "grade": "1.1",
49
52
  "questions": []
@@ -55,6 +58,7 @@ const Template: Story<any> = (args) => {
55
58
  "data": {
56
59
  "categoryName": "1.1.1",
57
60
  "openAnswer": false,
61
+ "isYesOrNo": false,
58
62
  "generalEvaluationLevel": "0",
59
63
  "grade": "1.1.1",
60
64
  "questions": []
@@ -70,7 +74,8 @@ const Template: Story<any> = (args) => {
70
74
  "key": "2",
71
75
  "data": {
72
76
  "categoryName": "3",
73
- "openAnswer": false,
77
+ "openAnswer": true,
78
+ "isYesOrNo": false,
74
79
  "generalEvaluationLevel": "0",
75
80
  "grade": "3",
76
81
  "questions": []
@@ -35,7 +35,8 @@ export const CategoryContent = (props: categoryContent) => {
35
35
  const [form] = useForm();
36
36
 
37
37
  const onFinish = (values: any) => {
38
- setContentInfo(values);
38
+ const combinedValues = { ...initialValues, ...values };
39
+ setContentInfo(combinedValues);
39
40
  };
40
41
 
41
42
  const openSwitchHandler = (enabled: boolean) => {
@@ -127,6 +128,7 @@ export const CategoryContent = (props: categoryContent) => {
127
128
  </Label>
128
129
  <Form.Item
129
130
  name={['openAnswer']}
131
+ initialValue={switchOpenAnswStatus}
130
132
  >
131
133
  <Switch onChange={(enabled: boolean) => { openSwitchHandler(enabled) }} checked={switchOpenAnswStatus} />
132
134
  </Form.Item>
@@ -140,6 +142,7 @@ export const CategoryContent = (props: categoryContent) => {
140
142
  </Label>
141
143
  <Form.Item
142
144
  name={['isYesOrNo']}
145
+ initialValue={switchYesOrNoAnswStatus}
143
146
  >
144
147
  <Switch onChange={(enabled: boolean) => { yesNoSwitchHandler(enabled) }} checked={switchYesOrNoAnswStatus} />
145
148
  </Form.Item>
@@ -8,43 +8,6 @@ interface Category {
8
8
  serverReadyData: any;
9
9
  }
10
10
 
11
- const fakeData: any = {
12
- data: [
13
- {
14
- "title": "opgg (Q: 1) ",
15
- "key": "0",
16
- "data": {
17
- "categoryName": "opgg",
18
- "openAnswer": true,
19
- "questions": [
20
- {
21
- "question": "1",
22
- "info": "2"
23
- }
24
- ]
25
- }
26
- },
27
- {
28
- "title": "abcd (Q: 1) (G: 2)",
29
- "key": "1",
30
- "data": {
31
- "categoryName": "abcd",
32
- "openAnswer": false,
33
- "questions": [
34
- {
35
- "question": "ax1",
36
- "info": "se2",
37
- "grade": "1s"
38
- }
39
- ],
40
- "generalEvaluationLevel": "2",
41
- "grade": "2"
42
- }
43
- }
44
- ],
45
- noData: []
46
- }
47
-
48
11
  export const Category = (props: Category) => {
49
12
  const {
50
13
  data
@@ -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": "2"
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": "5"
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}>Categorias</div>
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
- : <Form.Item
263
- name={["Questions", index, "Answer"]}
264
- >
265
- <Select options={evaluationOptions[selectedEvaluationOption]}
266
- style={{ minWidth: '100%' }}
267
- />
268
- </Form.Item>
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>
@@ -62,7 +62,9 @@
62
62
  },
63
63
  "categoryResponse": {
64
64
  "notApplicable": "Not Applicable",
65
- "answer": "Answer"
65
+ "answer": "Answer",
66
+ "yes": "Yes",
67
+ "no": "No"
66
68
  },
67
69
  "categoryReadOnly": {
68
70
  "categories": "Categories",
@@ -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/Não",
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",
@@ -62,7 +62,9 @@
62
62
  },
63
63
  "categoryResponse": {
64
64
  "notApplicable": "Não Aplicável",
65
- "answer": "Resposta"
65
+ "answer": "Resposta",
66
+ "yes": "Sim",
67
+ "no": "Não"
66
68
  },
67
69
  "categoryReadOnly": {
68
70
  "categories": "Categorias",