@omniumretail/component-library 1.1.77 → 1.1.79

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.77",
3
+ "version": "1.1.79",
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
  }
@@ -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,6 +84,15 @@ const hasCategory = (currentKey: string, categories: Category[], direction: 'nex
84
84
  return !!category;
85
85
  };
86
86
 
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
+
87
96
  export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref) => {
88
97
  const { data } = props;
89
98
 
@@ -172,15 +181,18 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
172
181
 
173
182
  const onFinish = (values: any) => {
174
183
  const updatedQuestions = initialValues.Questions.map((question: any, index: number) => {
184
+
175
185
  return {
176
186
  ...question,
177
187
  Answer: !props.addButtons
178
188
  ? values.Questions[index].Answer
179
- : Array.isArray(values.Questions[index].Answer)
180
- ? values.Questions[index].Answer
181
- : values.Questions[index].Answer
182
- ? [values.Questions[index].Answer]
183
- : [],
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
+ : [],
184
196
  Note: values.Questions[index].Note,
185
197
  IsMultipleChoise: values.Questions[index].IsMultipleChoise,
186
198
  Files: fileLists[`${selectedCategory.Data.CategoryId}_${index}`] || [], // Include files in the form data
@@ -269,6 +281,7 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
269
281
  // any new generalEvaluationLevel is added to the backend we need to update our own without
270
282
  // deleting any of the previous so we dont mess up the project history.
271
283
  const selectedEvaluationOption = `scale_${selectedCategory?.Data?.GeneralEvaluationLevel}` as keyof typeof evaluationOptions;
284
+ const dateFormatList = ['DD/MM/YYYY', 'YYYY/MM/DD'];
272
285
 
273
286
  return (
274
287
  <div className={styles.categoryResponse}>
@@ -295,6 +308,7 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
295
308
  </div>
296
309
  {selectedCategory?.Data?.Questions.map((question: any, index: number) => {
297
310
  const isOpenAnswer = selectedCategory.Data.OpenAnswer || question.IsOpenAnswer;
311
+
298
312
  const questionWrapper = classNames({
299
313
  [styles.questionWrapperOpenAnswer]: isOpenAnswer || props.addButtons,
300
314
  }, [styles.questionWrapper]);
@@ -369,21 +383,32 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
369
383
  <TextArea />
370
384
  </Form.Item>
371
385
 
372
- : <Form.Item
373
- name={["Questions", index, "Answer"]}
374
- >
375
- <Select
376
- options={selectedCategory.Data.IsYesOrNo
377
- ? props.selectYesNoOption
378
- : question?.Options?.length > 0
379
- ? question?.Options?.map((option: any) => ({ label: option.Value, value: option.Value }))
380
- : evaluationOptions[selectedEvaluationOption]
381
- }
382
- // style={{ minWidth: '100%' }}
383
- mode={form.getFieldValue(`Questions`)?.[index]?.IsMultipleChoise ? "multiple" : undefined}
384
- customClass={styles.selectAnswerStyle}
385
- />
386
- </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>
387
412
  }
388
413
  </div>
389
414
  </div>