@omniumretail/component-library 1.1.89 → 1.1.91

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.89",
3
+ "version": "1.1.91",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -108,6 +108,7 @@ Primary.args = {
108
108
  "Grade": "0",
109
109
  "Note": "Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit",
110
110
  "Answer": null,
111
+ "ImagesList": ["https://omnium-user-images.s3.eu-west-1.amazonaws.com/blank-profile-picture-973460_1280.png"],
111
112
  "Actions": [
112
113
  {
113
114
  "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,7 +96,8 @@ 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();
@@ -183,11 +185,11 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
183
185
  ...question,
184
186
  Answer: !props.addButtons
185
187
  ? 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
- : [],
188
+ : Array.isArray(values.Questions[index].Answer)
189
+ ? values.Questions[index].Answer
190
+ : values.Questions[index].Answer
191
+ ? [values.Questions[index].Answer]
192
+ : [],
191
193
  Note: values.Questions[index].Note,
192
194
  IsMultipleChoise: values.Questions[index].IsMultipleChoise,
193
195
  Files: fileLists[`${selectedCategory.Data.CategoryId}_${index}`] || [], // Include files in the form data
@@ -351,9 +353,9 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
351
353
  <div className={styles.actionsButtonsContainer}>
352
354
  <Upload
353
355
  listType={"text"}
354
- fileList={fileLists[`${selectedCategory.Data.CategoryId}_${question.QuestionId}`] || []}
356
+ fileList={fileLists[`${selectedCategory.Data.CategoryId}_${question.Id}`] || []}
355
357
  beforeUpload={() => false} // Prevent automatic upload
356
- onChange={({ fileList }) => handleFileChange(fileList, selectedCategory.Data.CategoryId, question.QuestionId)}
358
+ onChange={({ fileList }) => handleFileChange(fileList, selectedCategory.Data.CategoryId, question.Id)}
357
359
  onPreview={onPreview}
358
360
  >
359
361
  <Button customClass={styles.loadFile}>{t('components.upload.loadFile')}</Button>