@bento-core/table 1.0.1-ccdihub.90 → 1.0.1-ccdihub.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.
Files changed (51) hide show
  1. package/dist/DefaultThemConfig.js +1 -1
  2. package/dist/ExtendedView.js +7 -5
  3. package/dist/TableView.js +11 -6
  4. package/dist/body/CustomTblBody.js +4 -2
  5. package/dist/body/DisplayBodyCell.js +8 -4
  6. package/dist/body/components/CPIModal.js +154 -7
  7. package/dist/body/components/CPIView.js +4 -2
  8. package/dist/body/components/assets/Cart_Icon.svg +3 -0
  9. package/dist/body/components/assets/Question_Icon.svg +4 -0
  10. package/dist/toolbar/DownloadButtonView.js +24 -14
  11. package/dist/toolbar/ManageColumnView.js +154 -41
  12. package/dist/toolbar/assets/Hidden_Column.svg +4 -0
  13. package/dist/toolbar/assets/View_Columns.svg +6 -0
  14. package/dist/wrapper/WrapperService.js +36 -0
  15. package/dist/wrapper/components/AddFiles.js +63 -0
  16. package/dist/wrapper/components/AddToCartDialog/AddToCartDialogAlertView.js +35 -0
  17. package/dist/wrapper/components/AddToCartDialog/AddToCartDialogController.js +36 -0
  18. package/dist/wrapper/components/AddToCartDialog/AddToCartDialogView.js +43 -0
  19. package/dist/wrapper/components/CPIFilesView/CPIFilesView.js +178 -0
  20. package/dist/wrapper/components/ReduxAddFile.js +27 -0
  21. package/dist/wrapper/components/Snackbar/Snackbar.js +40 -0
  22. package/dist/wrapper/components/Snackbar/SnackbarRedux.js +16 -0
  23. package/dist/wrapper/components/Snackbar/SuccessOutlined.js +17 -0
  24. package/dist/wrapper/components/TextFieldView.js +37 -0
  25. package/dist/wrapper/components/TooltipView.js +40 -0
  26. package/package.json +8 -2
  27. package/src/DefaultThemConfig.js +1 -1
  28. package/src/ExtendedView.js +8 -6
  29. package/src/TableView.js +10 -5
  30. package/src/body/CustomTblBody.js +2 -0
  31. package/src/body/DisplayBodyCell.js +4 -0
  32. package/src/body/components/CPIModal.js +163 -1
  33. package/src/body/components/CPIView.js +2 -0
  34. package/src/body/components/assets/Cart_Icon.svg +3 -0
  35. package/src/body/components/assets/Question_Icon.svg +4 -0
  36. package/src/toolbar/DownloadButtonView.js +15 -12
  37. package/src/toolbar/ManageColumnView.js +163 -44
  38. package/src/toolbar/assets/Hidden_Column.svg +4 -0
  39. package/src/toolbar/assets/View_Columns.svg +6 -0
  40. package/src/wrapper/WrapperService.js +25 -0
  41. package/src/wrapper/components/AddFiles.js +62 -0
  42. package/src/wrapper/components/AddToCartDialog/AddToCartDialogAlertView.js +37 -0
  43. package/src/wrapper/components/AddToCartDialog/AddToCartDialogController.js +32 -0
  44. package/src/wrapper/components/AddToCartDialog/AddToCartDialogView.js +57 -0
  45. package/src/wrapper/components/CPIFilesView/CPIFilesView.js +190 -0
  46. package/src/wrapper/components/ReduxAddFile.js +20 -0
  47. package/src/wrapper/components/Snackbar/Snackbar.js +43 -0
  48. package/src/wrapper/components/Snackbar/SnackbarRedux.js +11 -0
  49. package/src/wrapper/components/Snackbar/SuccessOutlined.js +10 -0
  50. package/src/wrapper/components/TextFieldView.js +32 -0
  51. package/src/wrapper/components/TooltipView.js +35 -0
@@ -1,56 +1,130 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useRef, useEffect } from 'react';
2
2
  import {
3
3
  Checkbox,
4
+ FormControlLabel,
4
5
  IconButton,
5
6
  List,
6
7
  ListItem,
7
- Popover,
8
8
  Tooltip,
9
9
  Typography,
10
10
  withStyles,
11
+ Divider,
11
12
  } from '@material-ui/core';
12
13
  import {
13
- ViewColumn,
14
14
  CheckBox as CheckBoxIcon,
15
15
  CheckBoxOutlineBlank as CheckBoxBlankIcon,
16
16
  Close,
17
17
  } from '@material-ui/icons';
18
+ import KeyboardArrowDownOutlinedIcon from '@material-ui/icons/KeyboardArrowDownOutlined';
18
19
  import { cellTypes } from '../util/Types';
20
+ import viewColumnsIcon from './assets/View_Columns.svg';
21
+ import hiddenColumnsIcon from './assets/Hidden_Column.svg';
19
22
 
20
23
  const ManageColumnView = ({
21
24
  table,
22
25
  onColumnViewChange,
26
+ onAllColumnViewChange,
23
27
  manageViewColumns,
24
28
  }) => {
25
29
  if (!manageViewColumns) {
26
30
  return null;
27
31
  }
28
- const [anchorEl, setAnchorEl] = useState(null);
29
- const handleClick = (event) => {
30
- setAnchorEl(event.currentTarget);
32
+ const { columns } = table;
33
+ const [listDisplay, setListDisplay] = useState('none');
34
+ const [selectAll, setSelectAll] = useState(false);
35
+
36
+ const viewColumns = columns.filter((col) => col.role === cellTypes.DISPLAY);
37
+
38
+ const dropdownSelection = useRef(null);
39
+
40
+ const handleClose = () => {
41
+ setListDisplay('none');
31
42
  };
32
43
 
33
- const handleClose = () => setAnchorEl(null);
44
+ const handleClickButton = () => {
45
+ if (listDisplay === 'none') {
46
+ setListDisplay('block');
47
+ } else {
48
+ setListDisplay('none');
49
+ }
50
+ };
34
51
 
35
- const open = Boolean(anchorEl);
36
- const { columns } = table;
37
- const viewColumns = columns.filter((col) => col.role === cellTypes.DISPLAY && col.hideable);
52
+ const useOutsideAlerter = (ref) => {
53
+ useEffect(() => {
54
+ function handleClickOutside(event) {
55
+ console.log(event.target);
56
+ if (!(event.target.getAttribute('id') && event.target.getAttribute('id').includes('dropdownListItem'))
57
+ && !(event.target.getAttribute('class') && event.target.getAttribute('class').includes('MuiFormControlLabel'))
58
+ ) {
59
+ setListDisplay('none');
60
+ }
61
+ }
62
+ document.addEventListener('mousedown', handleClickOutside);
63
+ return () => {
64
+ document.removeEventListener('mousedown', handleClickOutside);
65
+ };
66
+ }, [ref]);
67
+ };
68
+ useOutsideAlerter(dropdownSelection);
69
+
70
+ const handleSelectAll = () => {
71
+ const state = selectAll;
72
+ setSelectAll(!selectAll);
73
+ onAllColumnViewChange(!state);
74
+ };
75
+
76
+ const columnDropdown = {
77
+ width: '48px',
78
+ height: '36px',
79
+ paddingLeft: '5px',
80
+ border: `${listDisplay === 'none' ? '0.75px solid #606060' : '1.5px solid #5666BD'}`,
81
+ borderRadius: '5px',
82
+ display: 'inline-flex',
83
+ position: 'relative',
84
+ marginTop: '2px',
85
+ marginRight: '7px',
86
+ };
87
+
88
+ const displayColumnStyle = {
89
+ position: 'absolute',
90
+ right: '35px',
91
+ bottom: '23px',
92
+ };
93
+
94
+ const viewColumnsStyle = {
95
+ marginTop: '6px',
96
+ height: '24px',
97
+ backgroundColor: 'transparent',
98
+ };
99
+
100
+ const dropdownList = {
101
+ position: 'absolute',
102
+ width: '230px',
103
+ marginTop: '38px',
104
+ marginLeft: '-187px',
105
+ overflow: 'auto',
106
+ zIndex: '5',
107
+ border: '1.5px solid #5666BD',
108
+ borderRadius: '5px',
109
+ background: '#ffffff',
110
+ display: listDisplay,
111
+ };
112
+
113
+ const arrowdownIcon = {
114
+ fill: '#606060',
115
+ };
38
116
  return (
39
- <>
117
+ <div style={columnDropdown}>
118
+ <Tooltip title="Columns may be hidden">
119
+ <img src={hiddenColumnsIcon} alt="hiddenColumnsIcon" style={displayColumnStyle} />
120
+ </Tooltip>
40
121
  <Tooltip title={manageViewColumns.title}>
41
- <IconButton variant="contained" onClick={handleClick} style={{ marginLeft: '10px', marginTop: '9px', height: '24px' }}>
42
- <ViewColumn />
122
+ <IconButton variant="contained" onClick={handleClickButton} style={viewColumnsStyle}>
123
+ <img src={viewColumnsIcon} alt="viewColumnsIcon" />
124
+ <KeyboardArrowDownOutlinedIcon style={arrowdownIcon} />
43
125
  </IconButton>
44
126
  </Tooltip>
45
- <Popover
46
- open={open}
47
- anchorEl={anchorEl}
48
- onClose={handleClose}
49
- anchorOrigin={{
50
- vertical: 'bottom',
51
- horizontal: 'left',
52
- }}
53
- >
127
+ <div style={dropdownList}>
54
128
  <Typography variant="caption" className="viewColumnText">
55
129
  {manageViewColumns.title}
56
130
  </Typography>
@@ -62,38 +136,83 @@ const ManageColumnView = ({
62
136
  <Close />
63
137
  </IconButton>
64
138
  <List className="viewColumnList">
65
- {viewColumns.map((column) => (
139
+ {viewColumns.map((column, index) => (
66
140
  <ListItem
67
141
  width={1}
68
142
  className="viewColumnListItem"
143
+ id={`dropdownListItem-${index}`}
69
144
  >
70
- <Checkbox
71
- icon={(
72
- <CheckBoxBlankIcon
73
- style={{ fontSize: 18 }}
74
- className="checkBoxIcon"
75
- />
76
- )}
77
- onClick={() => onColumnViewChange(column)}
78
- checked={column.display}
79
- checkedIcon={(
80
- <CheckBoxIcon
81
- style={{
82
- fontSize: 18,
83
- }}
84
- className="checkBoxIcon"
145
+ <FormControlLabel
146
+ control={(
147
+ <Checkbox
148
+ icon={(
149
+ <CheckBoxBlankIcon
150
+ style={{ fontSize: 18 }}
151
+ className="checkBoxIcon"
152
+ />
153
+ )}
154
+ onClick={() => onColumnViewChange(column)}
155
+ checked={column.display}
156
+ id={`dropdownListItemCheckbox-${index}`}
157
+ checkedIcon={(
158
+ <CheckBoxIcon
159
+ style={{
160
+ fontSize: 18,
161
+ color: column.hideable ? 'rgba(11, 53, 86, 1)' : 'rgba(11, 53, 86, 0.38)',
162
+ }}
163
+ className="checkBoxIcon"
164
+ />
165
+ )}
166
+ disableRipple
167
+ color="secondary"
168
+ className="checkBox"
169
+ disabled={!column.hideable}
85
170
  />
86
171
  )}
87
- disableRipple
88
- color="secondary"
89
- className="checkBox"
172
+ disabled={!column.hideable}
173
+ label={column.header}
174
+ id={`dropdownListItem-${index}-label`}
90
175
  />
91
- <Typography>{column.header}</Typography>
92
176
  </ListItem>
93
177
  ))}
178
+ <Divider style={{ color: '#375F9A', marginTop: '5px', marginBottom: '5px' }} />
179
+ <ListItem
180
+ width={1}
181
+ className="viewColumnListItem"
182
+ >
183
+ <FormControlLabel
184
+ control={(
185
+ <Checkbox
186
+ icon={(
187
+ <CheckBoxBlankIcon
188
+ style={{ fontSize: 18 }}
189
+ className="checkBoxIcon"
190
+ />
191
+ )}
192
+ onClick={() => handleSelectAll()}
193
+ checked={selectAll}
194
+ id="dropdownListItem-all"
195
+ checkedIcon={(
196
+ <CheckBoxIcon
197
+ style={{
198
+ fontSize: 18,
199
+ color: 'rgba(11, 53, 86, 1)',
200
+ }}
201
+ className="checkBoxIcon"
202
+ />
203
+ )}
204
+ disableRipple
205
+ color="secondary"
206
+ className="checkBox"
207
+ />
208
+ )}
209
+ label={selectAll ? 'Deselect All' : 'Select All'}
210
+ id="dropdownListItem-all-label"
211
+ />
212
+ </ListItem>
94
213
  </List>
95
- </Popover>
96
- </>
214
+ </div>
215
+ </div>
97
216
  );
98
217
  };
99
218
 
@@ -0,0 +1,4 @@
1
+ <svg width="20" height="19" viewBox="0 0 20 19" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="10" y="0.928786" width="12.2783" height="12.2783" rx="2.5" transform="rotate(45 10 0.928786)" fill="#FFEB13" stroke="black"/>
3
+ <path d="M9.99994 7.14529C9.74072 7.14529 9.52354 7.06575 9.3484 6.90667C9.18026 6.74068 9.09619 6.53664 9.09619 6.29457C9.09619 6.05249 9.18026 5.85192 9.3484 5.69284C9.52354 5.52684 9.74072 5.44385 9.99994 5.44385C10.2592 5.44385 10.4728 5.52684 10.641 5.69284C10.8161 5.85192 10.9037 6.05249 10.9037 6.29457C10.9037 6.53664 10.8161 6.74068 10.641 6.90667C10.4728 7.06575 10.2592 7.14529 9.99994 7.14529ZM10.725 7.83001V13.5776H9.25382V7.83001H10.725Z" fill="black"/>
4
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg width="20" height="18" viewBox="0 0 20 18" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M2.88892 1.40607H17.1116C17.6636 1.40633 18.1116 1.85394 18.1116 2.40607V15.5936C18.1116 16.1457 17.6636 16.5933 17.1116 16.5936H2.88892C2.33663 16.5936 1.88892 16.1459 1.88892 15.5936V2.40607C1.88892 1.85378 2.33663 1.40607 2.88892 1.40607Z" fill="white" stroke="#606060" stroke-width="2"/>
3
+ <line x1="1.79956" y1="6.08969" x2="19.1106" y2="6.08969" stroke="#606060" stroke-width="2"/>
4
+ <line x1="13.2661" y1="7.09055" x2="13.2661" y2="17.5941" stroke="#606060" stroke-width="2"/>
5
+ <line x1="7.6936" y1="7.0903" x2="7.6936" y2="17.5939" stroke="#606060" stroke-width="2"/>
6
+ </svg>
@@ -0,0 +1,25 @@
1
+ /**
2
+ * query varibales to fetch all the selected files id
3
+ */
4
+ export const getQueryVariables = (variables) => {
5
+ const queryVariables = { ...variables };
6
+ queryVariables.first = 200000;
7
+ return queryVariables;
8
+ };
9
+
10
+ export const getFilesID = ({
11
+ client,
12
+ variables,
13
+ query,
14
+ }) => {
15
+ const queryVariables = getQueryVariables(variables);
16
+ return async function getFileIDs() {
17
+ const fetchResult = await client
18
+ .query({
19
+ query,
20
+ variables: queryVariables,
21
+ })
22
+ .then((response) => response.data);
23
+ return fetchResult;
24
+ };
25
+ };
@@ -0,0 +1,62 @@
1
+ import React, { useState } from 'react';
2
+ import { useApolloClient } from '@apollo/client';
3
+ import CPIFilesView from './CPIFilesView/CPIFilesView';
4
+ import SnackbarView from './Snackbar/Snackbar';
5
+ import AlertView from './AddToCartDialog/AddToCartDialogAlertView';
6
+
7
+ export const btnTypes = {
8
+ ADD_ALL_FILES: 'ADD_ALL_FILES',
9
+ ADD_SELECTED_FILES: 'ADD_SELECTED_FILES',
10
+ DOWNLOAD_MANIFEST: 'DOWNLOAD_MANIFEST',
11
+ };
12
+ /**
13
+ * customize button based on configuration
14
+ * refer config table (wrapper component config)
15
+ */
16
+ const AddFilesView = (props) => {
17
+ const {
18
+ count,
19
+ alertMessage,
20
+ cartFiles,
21
+ buttonStyle,
22
+ } = props;
23
+ /**
24
+ * snackbar state
25
+ */
26
+ const [openSnackbar, setOpenSnackbar] = useState(false);
27
+
28
+ /**
29
+ * conditionally display max file Alter/Error dialog view
30
+ */
31
+ const [displayAlter, setAlterDisplay] = useState(false);
32
+ /**
33
+ * acess bento app client via ApolloProvider
34
+ */
35
+ const client = useApolloClient();
36
+ return (
37
+ <>
38
+ <CPIFilesView
39
+ {...props}
40
+ client={client}
41
+ setAlterDisplay={setAlterDisplay}
42
+ setOpenSnackbar={setOpenSnackbar}
43
+ cartFiles={cartFiles}
44
+ buttonStyle={buttonStyle}
45
+ />
46
+ <SnackbarView
47
+ open={openSnackbar}
48
+ count={count}
49
+ onClose={() => setOpenSnackbar(false)}
50
+ />
51
+ {(displayAlter) && (
52
+ <AlertView
53
+ alertMessage={alertMessage}
54
+ open={displayAlter}
55
+ onClose={() => setAlterDisplay(false)}
56
+ />
57
+ )}
58
+ </>
59
+ );
60
+ };
61
+
62
+ export default AddFilesView;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import {
3
+ Dialog, DialogContent, DialogContentText,
4
+ } from '@material-ui/core';
5
+
6
+ function AddToCartDialogAlertView(props) {
7
+ const {
8
+ open,
9
+ onClose,
10
+ alertMessage,
11
+ } = props;
12
+ const closeAlertModelTimer = 4000;
13
+
14
+ const AlertDialog = (
15
+ <>
16
+ <Dialog
17
+ open={open}
18
+ aria-labelledby="alert-dialog-title"
19
+ aria-describedby="alert-dialog-description"
20
+ >
21
+ <DialogContent className="alter-content">
22
+ <DialogContentText id="alert-dialog-description">
23
+ {alertMessage}
24
+ </DialogContentText>
25
+ </DialogContent>
26
+ </Dialog>
27
+ </>
28
+ );
29
+
30
+ if (open) {
31
+ // close the Dialog after 3 seconds.
32
+ setTimeout(() => { onClose(); }, closeAlertModelTimer);
33
+ }
34
+ return AlertDialog;
35
+ }
36
+
37
+ export default AddToCartDialogAlertView;
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import Dialog from './AddToCartDialogView';
3
+ import Alert from './AddToCartDialogAlertView';
4
+
5
+ const AddToCartDialogController = (props) => {
6
+ const [open, setOpen] = React.useState(false);
7
+
8
+ const handleClose = () => {
9
+ setOpen(false);
10
+ };
11
+
12
+ const {
13
+ cartWillFull = false,
14
+ numberOfFilesSelected,
15
+ onYesClick,
16
+ onNoClick,
17
+ } = props;
18
+
19
+ if (cartWillFull) {
20
+ return <Alert open={open} onClose={handleClose} />;
21
+ }
22
+ return (
23
+ <Dialog
24
+ open={open}
25
+ numberOfFilesSelected={numberOfFilesSelected}
26
+ onYesClick={onYesClick}
27
+ onNoClick={onNoClick}
28
+ />
29
+ );
30
+ };
31
+
32
+ export default AddToCartDialogController;
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import {
3
+ Dialog, DialogActions, DialogContent, DialogContentText, Button,
4
+ } from '@material-ui/core';
5
+ import Alert from './AddToCartDialogAlertView';
6
+
7
+ function AddToCartDialogView(props) {
8
+ const {
9
+ open,
10
+ numberOfFilesSelected,
11
+ onYesClick,
12
+ onNoClick,
13
+ cartWillFull = false,
14
+ alertMessage,
15
+ dialogText,
16
+ } = props;
17
+
18
+ if (cartWillFull) {
19
+ return (
20
+ <Alert
21
+ alertMessage={alertMessage}
22
+ open={open}
23
+ onClose={() => onNoClick()}
24
+ />
25
+ );
26
+ }
27
+
28
+ return (
29
+ <>
30
+ <Dialog
31
+ open={open}
32
+ aria-labelledby="alert-dialog-title"
33
+ aria-describedby="alert-dialog-description"
34
+ >
35
+ <DialogContent>
36
+ <DialogContentText id="alert-dialog-description">
37
+ {dialogText}
38
+ {' '}
39
+ {numberOfFilesSelected}
40
+ {' '}
41
+ to cart
42
+ </DialogContentText>
43
+ </DialogContent>
44
+ <DialogActions>
45
+ <Button className="yesBtn" onClick={() => onYesClick()}>
46
+ Yes
47
+ </Button>
48
+ <Button className="noBtn" onClick={() => onNoClick()}>
49
+ No
50
+ </Button>
51
+ </DialogActions>
52
+ </Dialog>
53
+ </>
54
+ );
55
+ }
56
+
57
+ export default AddToCartDialogView;
@@ -0,0 +1,190 @@
1
+ import React, { useState } from 'react';
2
+ import ToolTip from '@bento-core/tool-tip';
3
+ import { Button } from '@material-ui/core';
4
+ import clsx from 'clsx';
5
+ import gql from 'graphql-tag';
6
+ import { getFilesID } from '../../WrapperService';
7
+ import AddToCartDialogView from '../AddToCartDialog/AddToCartDialogView';
8
+
9
+ const customTooltip = {
10
+ border: '#03A383 1px solid',
11
+ };
12
+
13
+ const customArrow = {
14
+ '&::before': {
15
+ border: '#03A383 1px solid',
16
+ },
17
+ };
18
+
19
+ const iconStyle = {
20
+ paddingRight: '20px',
21
+ paddingBottom: '20px',
22
+ paddingLeft: '5px',
23
+ };
24
+
25
+ export const ToolTipView = (props) => {
26
+ const {
27
+ section,
28
+ tooltipCofig,
29
+ } = props;
30
+ const {
31
+ icon,
32
+ src,
33
+ alt,
34
+ arrow = false,
35
+ tooltipText,
36
+ } = tooltipCofig;
37
+ return (
38
+ <ToolTip
39
+ placement="top"
40
+ title={tooltipText || `${tooltipCofig[section]}`}
41
+ arrow={arrow}
42
+ classes={{
43
+ tooltip: customTooltip,
44
+ arrow: customArrow,
45
+ }}
46
+ >
47
+ <img src={icon || src} alt={alt} style={iconStyle} />
48
+ </ToolTip>
49
+ );
50
+ };
51
+
52
+ // const checkDuplicate = (cartFiles, ids) => {
53
+ // const newIds = [];
54
+ // for (let i = 0; i < ids.length; i += 1) {
55
+ // if (!cartFiles.includes(ids[i])) {
56
+ // newIds.push(ids[i]);
57
+ // }
58
+ // }
59
+ // return newIds;
60
+ // };
61
+
62
+ const checkDuplicate = (cartFiles, ids) => (ids.filter((id) => !cartFiles[id]));
63
+
64
+ const addFileQuery = gql`
65
+ query search (
66
+ $participant_ids: [String],
67
+ ){
68
+ fileIDsFromList (
69
+ participant_ids: $participant_ids,
70
+ )
71
+ }
72
+ `;
73
+
74
+ const CPIFilesComponent = (props) => {
75
+ const {
76
+ title,
77
+ btnType,
78
+ clsName,
79
+ section,
80
+ addFiles,
81
+ setAlterDisplay,
82
+ setOpenSnackbar,
83
+ client,
84
+ tooltipCofig,
85
+ cartFiles,
86
+ participantIds,
87
+ buttonStyle,
88
+ rowID,
89
+ } = props;
90
+ /**
91
+ * conditionally display dialog view
92
+ */
93
+ const [openAddDialog, setOpen] = useState(false);
94
+ const toggleOpen = () => setOpen(!openAddDialog);
95
+ const [addFilesId, setAddFilesId] = useState([]);
96
+ // const [isDataloading, setIsDataloading] = useState(false);
97
+ const responseKeys = ['fileIDsFromList'];
98
+
99
+ const cartFilesDict = {};
100
+ cartFiles.forEach((file) => { cartFilesDict[file] = true; });
101
+
102
+ // const backdropCls = {
103
+ // width: '100%',
104
+ // zIndex: 99999,
105
+ // background: 'rgba(0, 0, 0, 0.1)',
106
+ // };
107
+ /**
108
+ * verify and set file ids
109
+ */
110
+ const addAllFiles = () => {
111
+ let toAdd = [];
112
+ if (btnType === 'ADD_ALL_FILES') {
113
+ participantIds.forEach((e) => {
114
+ if (e.data_type === 'internal' && e.p_id) {
115
+ toAdd = toAdd.concat(e.p_id);
116
+ }
117
+ toAdd = toAdd.concat(rowID);
118
+ });
119
+ } else {
120
+ toAdd = participantIds.concat(rowID);
121
+ }
122
+ const fileIds = getFilesID({
123
+ client,
124
+ variables: { participant_ids: toAdd },
125
+ query: addFileQuery,
126
+ });
127
+ const upperLimit = 200000;
128
+ const cartCount = cartFiles.length;
129
+ if (cartCount < upperLimit) {
130
+ fileIds().then((response) => {
131
+ const idsInitial = response[responseKeys[0]] || [];
132
+ const ids = [...new Set(idsInitial)];
133
+ const fileCount = ids.length;
134
+ if (fileCount <= upperLimit && cartCount < upperLimit) {
135
+ if (cartCount + ids.length <= upperLimit) {
136
+ setOpen(true);
137
+ setAddFilesId(ids);
138
+ } else {
139
+ const newIds = checkDuplicate(cartFiles, ids);
140
+ if (cartCount + newIds.length <= upperLimit) {
141
+ setOpen(true);
142
+ setAddFilesId(newIds);
143
+ } else {
144
+ setAlterDisplay(true);
145
+ }
146
+ }
147
+ } else {
148
+ setAlterDisplay(true);
149
+ }
150
+ });
151
+ } else {
152
+ setAlterDisplay(true);
153
+ }
154
+ };
155
+
156
+ /**
157
+ * use wrapper service to add files to cart
158
+ */
159
+ const addFilesToCart = () => {
160
+ addFiles(addFilesId);
161
+ toggleOpen();
162
+ setOpenSnackbar(true);
163
+ };
164
+
165
+ return (
166
+ <>
167
+ <Button
168
+ onClick={addAllFiles}
169
+ className={clsx(clsName, `${clsName}_${section}`)}
170
+ disableRipple
171
+ style={buttonStyle}
172
+ disabled={btnType === 'ADD_SELECTED_FILES' && participantIds.length === 0}
173
+ >
174
+ {title}
175
+ </Button>
176
+ {tooltipCofig && (<ToolTipView {...props} />)}
177
+ <AddToCartDialogView
178
+ open={openAddDialog}
179
+ onYesClick={addFilesToCart}
180
+ onNoClick={toggleOpen}
181
+ dialogText={btnType === 'ADD_SELECTED_FILES' ? 'Are you sure to add selected files' : 'Are you sure to add All Files'}
182
+ />
183
+ {/* <Backdrop className={backdropCls} style={backdropCls} open={isDataloading}>
184
+ <CircularProgress color="inherit" />
185
+ </Backdrop> */}
186
+ </>
187
+ );
188
+ };
189
+
190
+ export default CPIFilesComponent;