@omniumretail/component-library 1.1.66 → 1.1.68

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.
@@ -6,7 +6,7 @@ interface CategoryResponse {
6
6
  onNextCategoryAvailabilityChange: (hasNext: boolean) => void;
7
7
  onPreviousCategoryAvailabilityChange: (hasPrevious: boolean) => void;
8
8
  selectYesNoOption?: any;
9
- addAction?: () => void;
9
+ addAction?: (questionId: string) => void;
10
10
  addButtons?: boolean;
11
11
  fileList?: React.Dispatch<React.SetStateAction<Record<string, UploadFile<any>[]>>>;
12
12
  }
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.68",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -32,6 +32,11 @@ const Template: Story<any> = (args) => {
32
32
  (categoryResponseRef.current as any).handlePreviousClick();
33
33
  }
34
34
 
35
+ const handleAddAction = (questionId: string) => {
36
+ console.log(`Ação adicionada para a pergunta com ID: ${questionId}`);
37
+ // Sua lógica para adicionar a ação, como uma chamada de API ou atualização de estado
38
+ };
39
+
35
40
  useEffect(() => {
36
41
  // console.log(serverData);
37
42
  }, [serverData])
@@ -47,6 +52,7 @@ const Template: Story<any> = (args) => {
47
52
  onPreviousCategoryAvailabilityChange={handlePreviousCategoryAvailabilityChange}
48
53
  addButtons
49
54
  fileList={setFileLists}
55
+ addAction={handleAddAction}
50
56
  >
51
57
  </CategoryResponse>
52
58
  </div>
@@ -97,7 +103,8 @@ Primary.args = {
97
103
  "Grade": "0",
98
104
  "Note": "Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit",
99
105
  "Answer": null,
100
- "ActionNames": ["Ação12345662323", "A"]
106
+ "ActionNames": ["Ação12345662323", "A"],
107
+ "IsOpenAnswer": true
101
108
  },
102
109
  {
103
110
  "Id": "85562A64-A24B-425A-A345-560238CA2468",
@@ -16,7 +16,7 @@ interface CategoryResponse {
16
16
  onNextCategoryAvailabilityChange: (hasNext: boolean) => void;
17
17
  onPreviousCategoryAvailabilityChange: (hasPrevious: boolean) => void;
18
18
  selectYesNoOption?: any;
19
- addAction?: () => void;
19
+ addAction?: (questionId: string) => void;
20
20
  addButtons?: boolean;
21
21
  fileList?: React.Dispatch<React.SetStateAction<Record<string, UploadFile<any>[]>>>;
22
22
  };
@@ -162,6 +162,13 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
162
162
  imgWindow?.document.write(image.outerHTML);
163
163
  };
164
164
 
165
+ const handleAddAction = (questionId: string) => {
166
+ if (props.addAction) {
167
+ console.log(questionId);
168
+ props.addAction(questionId);
169
+ }
170
+ };
171
+
165
172
  const onFinish = (values: any) => {
166
173
  const updatedQuestions = initialValues.Questions.map((question: any, index: number) => {
167
174
  return {
@@ -250,10 +257,6 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
250
257
  props.onPreviousCategoryAvailabilityChange(hasPrevious);
251
258
  }, [currentKey, localData.CategoryAnswers, props]);
252
259
 
253
- const questionWrapper = classNames({
254
- [styles.questionWrapperOpenAnswer]: selectedCategory.Data.OpenAnswer,
255
- }, [styles.questionWrapper]);
256
-
257
260
  // This gets the scale we use for each select from the database using a key based variable,if
258
261
  // any new generalEvaluationLevel is added to the backend we need to update our own without
259
262
  // deleting any of the previous so we dont mess up the project history.
@@ -282,91 +285,100 @@ export const CategoryResponse = React.forwardRef((props: CategoryResponse, ref)
282
285
  {selectedCategory?.Data?.Description}
283
286
  </div>
284
287
  </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>
295
-
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>
288
+ {selectedCategory?.Data?.Questions.map((question: any, index: number) => {
289
+ const isOpenAnswer = selectedCategory.Data.OpenAnswer || question.IsOpenAnswer;
290
+ const questionWrapper = classNames({
291
+ [styles.questionWrapperOpenAnswer]: isOpenAnswer,
292
+ }, [styles.questionWrapper]);
293
+
294
+ return (
295
+ <div className={questionWrapper} key={index}>
296
+ <div className={styles.question}>
297
+ <div className={styles.subject}>
298
+ {question.Subject}
299
+ </div>
300
+
301
+ <div className={styles.description}>
302
+ {question.Description}
303
+ </div>
304
+
305
+ {props.addButtons &&
306
+ <>
307
+ {(form.getFieldValue(`Questions`)?.[index].Note || isNoteVisible) &&
308
+ <div className={styles.noteContainer}>
309
+ <span className={styles.note}>{t('components.categoryResponse.note')}: </span>
310
+ {isNoteVisible?.categoryIndex === currentKey && isNoteVisible?.questionIndex === index ? (
311
+ <Form.Item name={["Questions", index, "Note"]} className={styles.form}>
312
+ <TextArea onBlur={() => setIsNoteVisible(null)} />
313
+ </Form.Item>
314
+ ) : (
315
+ <div className={styles.noteText}>{form.getFieldValue(`Questions`)?.[index].Note}</div>
316
+ )}
317
+ </div>
309
318
 
310
- }
319
+ }
311
320
 
312
- {question?.ActionNames &&
313
- <div className={styles.actionContainer}>
314
- <span className={styles.note}>{t('components.categoryResponse.actions')}: </span>
321
+ {question?.ActionNames &&
322
+ <div className={styles.actionContainer}>
323
+ <span className={styles.note}>{t('components.categoryResponse.actions')}: </span>
324
+
325
+ {question?.ActionNames?.map((action: any, index: number) => (
326
+ <span key={index} className={index > 0 ? styles.action : ''}>
327
+ {action}
328
+ <br />
329
+ </span>
330
+ ))}
331
+ </div>
332
+ }
315
333
 
316
- {question?.ActionNames?.map((action: any, index: number) => (
317
- <span key={index} className={index > 0 ? styles.action : ''}>
318
- {action}
319
- <br />
320
- </span>
321
- ))}
334
+ <div className={styles.actionsButtonsContainer}>
335
+ <Upload
336
+ listType={"text"}
337
+ fileList={fileLists[`${selectedCategory.Data.CategoryId}_${question.QuestionId}`] || []}
338
+ beforeUpload={() => false} // Prevent automatic upload
339
+ onChange={({ fileList }) => handleFileChange(fileList, selectedCategory.Data.CategoryId, question.QuestionId)}
340
+ onPreview={onPreview}
341
+ >
342
+ <Button customClass={styles.loadFile}>{t('components.upload.loadFile')}</Button>
343
+ </Upload>
344
+
345
+ <Button customClass={styles.actionsButtons} onClick={() => setIsNoteVisible({ categoryIndex: currentKey, questionIndex: index })}>
346
+ {form.getFieldValue(`Questions`)?.[index].Note ? t('components.categoryResponse.editNote') : t('components.categoryResponse.addNote')}
347
+ </Button>
348
+
349
+ <Button customClass={styles.actionsButtons} onClick={() => handleAddAction(question.Id)}>
350
+ {t('components.categoryResponse.createAction')}
351
+ </Button>
322
352
  </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
- }
353
+ </>
354
+ }
355
+ </div>
356
+ <div className={styles.answer}>
357
+ {isOpenAnswer
358
+ ? <Form.Item
359
+ name={["Questions", index, "Answer"]}
360
+ >
361
+ <TextArea />
362
+ </Form.Item>
363
+
364
+ : <Form.Item
365
+ name={["Questions", index, "Answer"]}
366
+ >
367
+ <Select
368
+ options={selectedCategory.Data.IsYesOrNo
369
+ ? props.selectYesNoOption
370
+ : question?.Options?.length > 0
371
+ ? question?.Options?.map((option: any) => ({ label: option.Value, value: option.Value }))
372
+ : evaluationOptions[selectedEvaluationOption]
373
+ }
374
+ style={{ minWidth: '100%' }}
375
+ />
376
+ </Form.Item>
377
+ }
378
+ </div>
367
379
  </div>
368
- </div>
369
- ))}
380
+ );
381
+ })}
370
382
  </Form>
371
383
  </div >
372
384
  </div >