@omniumretail/component-library 1.1.66 → 1.1.67

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.66",
3
+ "version": "1.1.67",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -97,7 +97,8 @@ Primary.args = {
97
97
  "Grade": "0",
98
98
  "Note": "Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit",
99
99
  "Answer": null,
100
- "ActionNames": ["Ação12345662323", "A"]
100
+ "ActionNames": ["Ação12345662323", "A"],
101
+ "IsOpenAnswer": true
101
102
  },
102
103
  {
103
104
  "Id": "85562A64-A24B-425A-A345-560238CA2468",
@@ -251,7 +251,7 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
251
251
  }, [currentKey, localData.CategoryAnswers, props]);
252
252
 
253
253
  const questionWrapper = classNames({
254
- [styles.questionWrapperOpenAnswer]: selectedCategory.Data.OpenAnswer,
254
+ [styles.questionWrapperOpenAnswer]: (selectedCategory.Data.OpenAnswer),
255
255
  }, [styles.questionWrapper]);
256
256
 
257
257
  // This gets the scale we use for each select from the database using a key based variable,if
@@ -282,91 +282,98 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
282
282
  {selectedCategory?.Data?.Description}
283
283
  </div>
284
284
  </div>
285
- {selectedCategory?.Data?.Questions.map((question: any, index: number) => (
286
- <div className={questionWrapper} key={index}>
287
- <div className={styles.question}>
288
- <div className={styles.subject}>
289
- {question.Subject}
290
- </div>
291
-
292
- <div className={styles.description}>
293
- {question.Description}
294
- </div>
285
+ {selectedCategory?.Data?.Questions.map((question: any, index: number) => {
286
+ const isOpenAnswer = selectedCategory.Data.OpenAnswer || question.IsOpenAnswer;
287
+ const questionWrapper = classNames({
288
+ [styles.questionWrapperOpenAnswer]: isOpenAnswer,
289
+ }, [styles.questionWrapper]);
290
+
291
+ return (
292
+ <div className={questionWrapper} key={index}>
293
+ <div className={styles.question}>
294
+ <div className={styles.subject}>
295
+ {question.Subject}
296
+ </div>
297
+
298
+ <div className={styles.description}>
299
+ {question.Description}
300
+ </div>
301
+
302
+ {props.addButtons &&
303
+ <>
304
+ {(form.getFieldValue(`Questions`)?.[index].Note || isNoteVisible) &&
305
+ <div className={styles.noteContainer}>
306
+ <span className={styles.note}>{t('components.categoryResponse.note')}: </span>
307
+ {isNoteVisible?.categoryIndex === currentKey && isNoteVisible?.questionIndex === index ? (
308
+ <Form.Item name={["Questions", index, "Note"]} className={styles.form}>
309
+ <TextArea onBlur={() => setIsNoteVisible(null)} />
310
+ </Form.Item>
311
+ ) : (
312
+ <div className={styles.noteText}>{form.getFieldValue(`Questions`)?.[index].Note}</div>
313
+ )}
314
+ </div>
295
315
 
296
- {props.addButtons &&
297
- <>
298
- {(form.getFieldValue(`Questions`)?.[index].Note || isNoteVisible) &&
299
- <div className={styles.noteContainer}>
300
- <span className={styles.note}>{t('components.categoryResponse.note')}: </span>
301
- {isNoteVisible?.categoryIndex === currentKey && isNoteVisible?.questionIndex === index ? (
302
- <Form.Item name={["Questions", index, "Note"]} className={styles.form}>
303
- <TextArea onBlur={() => setIsNoteVisible(null)} />
304
- </Form.Item>
305
- ) : (
306
- <div className={styles.noteText}>{form.getFieldValue(`Questions`)?.[index].Note}</div>
307
- )}
308
- </div>
309
-
310
- }
316
+ }
311
317
 
312
- {question?.ActionNames &&
313
- <div className={styles.actionContainer}>
314
- <span className={styles.note}>{t('components.categoryResponse.actions')}: </span>
318
+ {question?.ActionNames &&
319
+ <div className={styles.actionContainer}>
320
+ <span className={styles.note}>{t('components.categoryResponse.actions')}: </span>
321
+
322
+ {question?.ActionNames?.map((action: any, index: number) => (
323
+ <span key={index} className={index > 0 ? styles.action : ''}>
324
+ {action}
325
+ <br />
326
+ </span>
327
+ ))}
328
+ </div>
329
+ }
315
330
 
316
- {question?.ActionNames?.map((action: any, index: number) => (
317
- <span key={index} className={index > 0 ? styles.action : ''}>
318
- {action}
319
- <br />
320
- </span>
321
- ))}
331
+ <div className={styles.actionsButtonsContainer}>
332
+ <Upload
333
+ listType={"text"}
334
+ fileList={fileLists[`${selectedCategory.Data.CategoryId}_${question.QuestionId}`] || []}
335
+ beforeUpload={() => false} // Prevent automatic upload
336
+ onChange={({ fileList }) => handleFileChange(fileList, selectedCategory.Data.CategoryId, question.QuestionId)}
337
+ onPreview={onPreview}
338
+ >
339
+ <Button customClass={styles.loadFile}>{t('components.upload.loadFile')}</Button>
340
+ </Upload>
341
+
342
+ <Button customClass={styles.actionsButtons} onClick={() => setIsNoteVisible({ categoryIndex: currentKey, questionIndex: index })}>
343
+ {form.getFieldValue(`Questions`)?.[index].Note ? t('components.categoryResponse.editNote') : t('components.categoryResponse.addNote')}
344
+ </Button>
345
+
346
+ <Button customClass={styles.actionsButtons} onClick={props.addAction}>{t('components.categoryResponse.createAction')}</Button>
322
347
  </div>
323
- }
324
-
325
- <div className={styles.actionsButtonsContainer}>
326
- <Upload
327
- listType={"text"}
328
- fileList={fileLists[`${selectedCategory.Data.CategoryId}_${question.QuestionId}`] || []}
329
- beforeUpload={() => false} // Prevent automatic upload
330
- onChange={({ fileList }) => handleFileChange(fileList, selectedCategory.Data.CategoryId, question.QuestionId)}
331
- onPreview={onPreview}
332
- >
333
- <Button customClass={styles.loadFile}>{t('components.upload.loadFile')}</Button>
334
- </Upload>
335
-
336
- <Button customClass={styles.actionsButtons} onClick={() => setIsNoteVisible({ categoryIndex: currentKey, questionIndex: index })}>
337
- {form.getFieldValue(`Questions`)?.[index].Note ? t('components.categoryResponse.editNote') : t('components.categoryResponse.addNote')}
338
- </Button>
339
-
340
- <Button customClass={styles.actionsButtons} onClick={props.addAction}>{t('components.categoryResponse.createAction')}</Button>
341
- </div>
342
- </>
343
- }
344
- </div>
345
- <div className={styles.answer}>
346
- {selectedCategory.Data.OpenAnswer
347
- ? <Form.Item
348
- name={["Questions", index, "Answer"]}
349
- >
350
- <TextArea />
351
- </Form.Item>
352
-
353
- : <Form.Item
354
- name={["Questions", index, "Answer"]}
355
- >
356
- <Select
357
- options={selectedCategory.Data.IsYesOrNo
358
- ? props.selectYesNoOption
359
- : question?.Options?.length > 0
360
- ? question?.Options?.map((option: any) => ({ label: option.Value, value: option.Value }))
361
- : evaluationOptions[selectedEvaluationOption]
362
- }
363
- style={{ minWidth: '100%' }}
364
- />
365
- </Form.Item>
366
- }
348
+ </>
349
+ }
350
+ </div>
351
+ <div className={styles.answer}>
352
+ {isOpenAnswer
353
+ ? <Form.Item
354
+ name={["Questions", index, "Answer"]}
355
+ >
356
+ <TextArea />
357
+ </Form.Item>
358
+
359
+ : <Form.Item
360
+ name={["Questions", index, "Answer"]}
361
+ >
362
+ <Select
363
+ options={selectedCategory.Data.IsYesOrNo
364
+ ? props.selectYesNoOption
365
+ : question?.Options?.length > 0
366
+ ? question?.Options?.map((option: any) => ({ label: option.Value, value: option.Value }))
367
+ : evaluationOptions[selectedEvaluationOption]
368
+ }
369
+ style={{ minWidth: '100%' }}
370
+ />
371
+ </Form.Item>
372
+ }
373
+ </div>
367
374
  </div>
368
- </div>
369
- ))}
375
+ );
376
+ })}
370
377
  </Form>
371
378
  </div >
372
379
  </div >