@omniumretail/component-library 1.1.79 → 1.1.81

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.79",
3
+ "version": "1.1.81",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -114,7 +114,7 @@ Primary.args = {
114
114
  "Description": "This is a description ",
115
115
  "Grade": "0",
116
116
  "Note": "asasas",
117
- "Answer": null,
117
+ "Answer": [],
118
118
  "IsDate": true
119
119
  }
120
120
  ]
@@ -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, DatePicker, InputNumber } from 'antd';
3
+ import { Form, UploadFile, Upload, DatePicker } 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';
@@ -9,6 +9,7 @@ import { evaluationOptions } from './evaluationOptions';
9
9
  import React from 'react';
10
10
  import { t } from 'i18next';
11
11
  import { Button } from '../Button';
12
+ import dayjs from 'dayjs';
12
13
 
13
14
  interface CategoryResponse {
14
15
  data: any;
@@ -84,15 +85,6 @@ const hasCategory = (currentKey: string, categories: Category[], direction: 'nex
84
85
  return !!category;
85
86
  };
86
87
 
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
-
96
88
  export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref) => {
97
89
  const { data } = props;
98
90
 
@@ -102,6 +94,7 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
102
94
  const [selectedCategory, setSelectedCategory] = useState<any>(data.CategoryAnswers[0]);
103
95
  const [initialValues, setInitialValues] = useState<any>(data.CategoryAnswers[0].Data);
104
96
  const [fileLists, setFileLists] = useState<Record<string, UploadFile[]>>({});
97
+ const [dataValue, setDataValue] = useState<any>();
105
98
  const [isNoteVisible, setIsNoteVisible] = useState<{ categoryIndex: number; questionIndex: number } | null>(null);
106
99
  const [form] = useForm();
107
100
 
@@ -116,9 +109,11 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
116
109
  Questions: Questions.map((question: any) => ({
117
110
  Subject: question.Subject,
118
111
  Description: question.Description,
119
- Answer: question.Answer || "",
112
+ Answer: props.addButtons ? (question.IsDate ? (question?.Answer?.length > 0 ? dayjs.unix(Number(question?.Answer?.[0])) : null) : question.Answer) : question.Answer,
120
113
  Note: question.Note || "",
121
- IsMultipleChoise: question.IsMultipleChoise || false
114
+ IsMultipleChoise: question.IsMultipleChoise || false,
115
+ IsDate: question.IsDate || false,
116
+ IsOpenAnswer: question.IsOpenAnswer || false,
122
117
  })),
123
118
  OpenAnswer: OpenAnswer,
124
119
  IsYesOrNo: IsYesOrNo
@@ -186,8 +181,6 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
186
181
  ...question,
187
182
  Answer: !props.addButtons
188
183
  ? values.Questions[index].Answer
189
- : typeof values.Questions[index].Answer === "object"
190
- ? [getDateToUnixInUTC(values.Questions[index].Answer?.toDate())] || undefined
191
184
  : Array.isArray(values.Questions[index].Answer)
192
185
  ? values.Questions[index].Answer
193
186
  : values.Questions[index].Answer
@@ -391,6 +384,9 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
391
384
  className={styles.select}
392
385
  placeholder={''}
393
386
  format={dateFormatList}
387
+ value={dataValue}
388
+ defaultValue={form.getFieldValue(`Questions`)?.[index].Answer}
389
+ onChange={(value) => setDataValue(value)}
394
390
  />
395
391
  </Form.Item>
396
392