@omniumretail/component-library 1.1.90 → 1.1.92

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.
@@ -10,6 +10,7 @@ interface CategoryResponse {
10
10
  openAction?: (actionId: string) => void;
11
11
  addButtons?: boolean;
12
12
  fileList?: React.Dispatch<React.SetStateAction<Record<string, UploadFile<any>[]>>>;
13
+ initialFileList?: any;
13
14
  }
14
15
  export declare const CategoryResponse: React.ForwardRefExoticComponent<CategoryResponse & React.RefAttributes<unknown>>;
15
16
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omniumretail/component-library",
3
- "version": "1.1.90",
3
+ "version": "1.1.92",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -14,7 +14,16 @@ const Template: Story<any> = (args) => {
14
14
  const categoryResponseRef = useRef(null);
15
15
  const [hasNext, setHasNext] = useState(true);
16
16
  const [hasPrevious, setHasPrevious] = useState(false);
17
- const [fileLists, setFileLists] = useState<Record<string, UploadFile[]>>({});
17
+ const [fileLists, setFileLists] = useState<Record<string, UploadFile[]>>({
18
+ "CATEGORYID1_65562A64-A24B-425A-A345-560238CA2468": [
19
+ {
20
+ "uid": "iv919l10io",
21
+ "name": "https://omnium-user-images.s3.eu-west-1.amazonaws.com/omnium-retail_icon.png",
22
+ "status": "done",
23
+ "url": "https://omnium-user-images.s3.eu-west-1.amazonaws.com/omnium-retail_icon.png"
24
+ }
25
+ ]
26
+ });
18
27
 
19
28
  const handleNextCategoryAvailabilityChange = (hasNext: boolean) => {
20
29
  setHasNext(hasNext);
@@ -58,6 +67,7 @@ const Template: Story<any> = (args) => {
58
67
  fileList={setFileLists}
59
68
  addAction={handleAddAction}
60
69
  openAction={handleOpenAction}
70
+ initialFileList={fileLists}
61
71
  >
62
72
  </CategoryResponse>
63
73
  </div>
@@ -108,6 +118,7 @@ Primary.args = {
108
118
  "Grade": "0",
109
119
  "Note": "Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit",
110
120
  "Answer": null,
121
+ "ImagesList": [],
111
122
  "Actions": [
112
123
  {
113
124
  "Id": "05D49F7B-C293-48AD-980F-D6ED5B3C0DAB",
@@ -21,6 +21,7 @@ interface CategoryResponse {
21
21
  openAction?: (actionId: string) => void;
22
22
  addButtons?: boolean;
23
23
  fileList?: React.Dispatch<React.SetStateAction<Record<string, UploadFile<any>[]>>>;
24
+ initialFileList?: any;
24
25
  };
25
26
 
26
27
  type Category = {
@@ -38,7 +39,7 @@ const updateCategoryAnswers = (CategoryAnswers: any[], categoryToUpdate: any, up
38
39
  ...question,
39
40
  Answer: updatedQuestions[index].Answer,
40
41
  Note: updatedQuestions[index].Note,
41
- Files: updatedQuestions[index].Files
42
+ ImagesList: updatedQuestions[index].ImagesList
42
43
  };
43
44
  });
44
45
  }
@@ -95,11 +96,15 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
95
96
  // Setting first set of questions as default open
96
97
  const [selectedCategory, setSelectedCategory] = useState<any>(data.CategoryAnswers[0]);
97
98
  const [initialValues, setInitialValues] = useState<any>(data.CategoryAnswers[0].Data);
98
- const [fileLists, setFileLists] = useState<Record<string, UploadFile[]>>({});
99
+ // const [fileLists, setFileLists] = useState<Record<string, UploadFile[]>>(props.initialFileList || []);
100
+ const [fileLists, setFileLists] = useState<Record<string, UploadFile[]>>(props.initialFileList || []);
99
101
  const [dataValue, setDataValue] = useState<any>();
100
102
  const [isNoteVisible, setIsNoteVisible] = useState<{ categoryIndex: number; questionIndex: number } | null>(null);
101
103
  const [form] = useForm();
102
104
 
105
+ console.log(fileLists, "fileLists");
106
+ console.log(props.initialFileList, "props.initialFileList");
107
+
103
108
  const updateInitialValues = (data: any) => {
104
109
  const {
105
110
  Questions,
@@ -183,11 +188,11 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
183
188
  ...question,
184
189
  Answer: !props.addButtons
185
190
  ? values.Questions[index].Answer
186
- : Array.isArray(values.Questions[index].Answer)
187
- ? values.Questions[index].Answer
188
- : values.Questions[index].Answer
189
- ? [values.Questions[index].Answer]
190
- : [],
191
+ : Array.isArray(values.Questions[index].Answer)
192
+ ? values.Questions[index].Answer
193
+ : values.Questions[index].Answer
194
+ ? [values.Questions[index].Answer]
195
+ : [],
191
196
  Note: values.Questions[index].Note,
192
197
  IsMultipleChoise: values.Questions[index].IsMultipleChoise,
193
198
  Files: fileLists[`${selectedCategory.Data.CategoryId}_${index}`] || [], // Include files in the form data