@omniumretail/component-library 1.1.76 → 1.1.78

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.76",
3
+ "version": "1.1.78",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -102,9 +102,10 @@ Primary.args = {
102
102
  "Description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit",
103
103
  "Grade": "0",
104
104
  "Note": "Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit",
105
- "Answer": "wdddddddddddddddddddddddddswdddddddddddddddddddddddddddddd",
105
+ "Answer": null,
106
106
  "ActionNames": ["Ação12345662323", "A"],
107
- "IsOpenAnswer": true
107
+ "IsOpenAnswer": true,
108
+ "IsNumeric": true
108
109
  },
109
110
  {
110
111
  "Id": "85562A64-A24B-425A-A345-560238CA2468",
@@ -113,7 +114,8 @@ Primary.args = {
113
114
  "Description": "This is a description ",
114
115
  "Grade": "0",
115
116
  "Note": "asasas",
116
- "Answer": "dwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"
117
+ "Answer": null,
118
+ "IsDate": true
117
119
  }
118
120
  ]
119
121
  }
@@ -167,7 +169,7 @@ Primary.args = {
167
169
  "Subject": "This is a Subject",
168
170
  "Description": "This is a description",
169
171
  "Grade": "50",
170
- "Answer": null
172
+ "Answer": []
171
173
  },
172
174
  {
173
175
  "Id": "35562A64-A24B-425A-A345-560238CA2468",
@@ -175,7 +177,7 @@ Primary.args = {
175
177
  "Subject": "This is a Subject",
176
178
  "Description": "This is a description",
177
179
  "Grade": "25",
178
- "Answer": null,
180
+ "Answer": ["1"],
179
181
  "IsMultipleChoise": false
180
182
  },
181
183
  {
@@ -184,7 +186,7 @@ Primary.args = {
184
186
  "Subject": "This is a Subject",
185
187
  "Description": "This is a description",
186
188
  "Grade": "25",
187
- "Answer": null,
189
+ "Answer": [],
188
190
  "IsMultipleChoise": true
189
191
  }
190
192
  ]
@@ -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 } from 'antd';
3
+ import { Form, UploadFile, Upload, DatePicker, InputNumber } 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';
@@ -84,14 +84,14 @@ const hasCategory = (currentKey: string, categories: Category[], direction: 'nex
84
84
  return !!category;
85
85
  };
86
86
 
87
- const getTitleWithQuestionCount = (category: any): string => {
88
- const questionCount = category?.Data?.Questions?.length;
89
- const answeredQuestions = category?.Data?.Questions?.filter((question: any) => question.Answer !== null && question.Answer !== undefined && question.Answer !== '').length;
87
+ const getDateToUnixInUTC = (date: Date): string | null => {
88
+ if (date === null) {
89
+ return null;
90
+ }
90
91
 
91
- return questionCount
92
- ? `${category.Title} - ${answeredQuestions} / ${questionCount}`
93
- : category.Title;
94
- };
92
+ const dateInUtc = new Date(Date.UTC(date?.getFullYear(), date?.getMonth(), date?.getDate(), 0, 0, 0));
93
+ return `${dateInUtc.getTime() / 1000}`;
94
+ }
95
95
 
96
96
  export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref) => {
97
97
  const { data } = props;
@@ -128,6 +128,16 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
128
128
  form.setFieldsValue(initial);
129
129
  };
130
130
 
131
+ const getTitleWithQuestionCount = (category: any): string => {
132
+ const questionCount = category?.Data?.Questions?.length;
133
+ const answeredQuestions = category?.Data?.Questions?.filter
134
+ ((question: any) => question.Answer !== null && question.Answer !== undefined && question.Answer !== '' && question.Answer.length > 0).length;
135
+
136
+ return questionCount
137
+ ? `${category.Title} - ${answeredQuestions} / ${questionCount}`
138
+ : category.Title;
139
+ };
140
+
131
141
  const handleLabelClick = (category: any, index: number) => {
132
142
  setSelectedCategory(category);
133
143
  updateInitialValues(category.Data);
@@ -171,9 +181,18 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
171
181
 
172
182
  const onFinish = (values: any) => {
173
183
  const updatedQuestions = initialValues.Questions.map((question: any, index: number) => {
184
+
174
185
  return {
175
186
  ...question,
176
- Answer: values.Questions[index].Answer,
187
+ Answer: !props.addButtons
188
+ ? values.Questions[index].Answer
189
+ : typeof values.Questions[index].Answer === "object"
190
+ ? [getDateToUnixInUTC(values.Questions[index].Answer?.toDate())] || undefined
191
+ : Array.isArray(values.Questions[index].Answer)
192
+ ? values.Questions[index].Answer
193
+ : values.Questions[index].Answer
194
+ ? [values.Questions[index].Answer]
195
+ : [],
177
196
  Note: values.Questions[index].Note,
178
197
  IsMultipleChoise: values.Questions[index].IsMultipleChoise,
179
198
  Files: fileLists[`${selectedCategory.Data.CategoryId}_${index}`] || [], // Include files in the form data
@@ -262,6 +281,7 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
262
281
  // any new generalEvaluationLevel is added to the backend we need to update our own without
263
282
  // deleting any of the previous so we dont mess up the project history.
264
283
  const selectedEvaluationOption = `scale_${selectedCategory?.Data?.GeneralEvaluationLevel}` as keyof typeof evaluationOptions;
284
+ const dateFormatList = ['DD/MM/YYYY', 'YYYY/MM/DD'];
265
285
 
266
286
  return (
267
287
  <div className={styles.categoryResponse}>
@@ -288,6 +308,7 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
288
308
  </div>
289
309
  {selectedCategory?.Data?.Questions.map((question: any, index: number) => {
290
310
  const isOpenAnswer = selectedCategory.Data.OpenAnswer || question.IsOpenAnswer;
311
+
291
312
  const questionWrapper = classNames({
292
313
  [styles.questionWrapperOpenAnswer]: isOpenAnswer || props.addButtons,
293
314
  }, [styles.questionWrapper]);
@@ -362,21 +383,32 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
362
383
  <TextArea />
363
384
  </Form.Item>
364
385
 
365
- : <Form.Item
366
- name={["Questions", index, "Answer"]}
367
- >
368
- <Select
369
- options={selectedCategory.Data.IsYesOrNo
370
- ? props.selectYesNoOption
371
- : question?.Options?.length > 0
372
- ? question?.Options?.map((option: any) => ({ label: option.Value, value: option.Value }))
373
- : evaluationOptions[selectedEvaluationOption]
374
- }
375
- // style={{ minWidth: '100%' }}
376
- mode={form.getFieldValue(`Questions`)?.[index]?.IsMultipleChoise ? "multiple" : undefined}
377
- customClass={styles.selectAnswerStyle}
378
- />
379
- </Form.Item>
386
+ : question.IsDate
387
+ ? <Form.Item
388
+ name={["Questions", index, "Answer"]}
389
+ >
390
+ <DatePicker
391
+ className={styles.select}
392
+ placeholder={''}
393
+ format={dateFormatList}
394
+ />
395
+ </Form.Item>
396
+
397
+ : <Form.Item
398
+ name={["Questions", index, "Answer"]}
399
+ >
400
+ <Select
401
+ options={selectedCategory.Data.IsYesOrNo
402
+ ? props.selectYesNoOption
403
+ : question?.Options?.length > 0
404
+ ? question?.Options?.map((option: any) => ({ label: option.Value, value: option.Value }))
405
+ : evaluationOptions[selectedEvaluationOption]
406
+ }
407
+ // style={{ minWidth: '100%' }}
408
+ mode={form.getFieldValue(`Questions`)?.[index]?.IsMultipleChoise ? "multiple" : undefined}
409
+ customClass={styles.selectAnswerStyle}
410
+ />
411
+ </Form.Item>
380
412
  }
381
413
  </div>
382
414
  </div>