@bento-core/table 1.0.1-ccdiintegrated.1 → 1.0.1-ccdiintegrated.10
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/dist/ExtendedView.js +2 -2
- package/dist/TableView.js +3 -1
- package/dist/body/DefaultThemConfig.js +1 -1
- package/dist/body/DisplayBodyCell.js +6 -2
- package/dist/body/components/CPIMappingView.js +2 -2
- package/dist/body/components/CPIModal.js +12 -7
- package/dist/body/components/CustomLinkView.js +2 -1
- package/dist/body/components/DataFormatView.js +1 -1
- package/dist/body/components/assets/CPI_Icon_Dataset.svg +3 -3
- package/dist/body/components/assets/CPI_Icon_Multi.svg +1 -1
- package/dist/body/components/assets/CPI_Icon_Single.svg +1 -1
- package/dist/body/components/assets/CPI_Icon_Study.svg +1 -1
- package/dist/index.js +18 -0
- package/dist/util/Dataformat.js +50 -2
- package/dist/util/downloadTable.js +77 -53
- package/dist/wrapper/components/AddFiles.js +6 -14
- package/dist/wrapper/components/AddToCart/AddToCartView.js +5 -3
- package/dist/wrapper/components/AddToCart/ReduxAddToCart.js +1 -0
- package/dist/wrapper/components/CPIFilesView/CPIFilesView.js +12 -6
- package/dist/wrapper/components/ReduxAddFile.js +1 -0
- package/dist/wrapper/components/Snackbar/CartToast.js +96 -0
- package/dist/wrapper/components/Snackbar/Snackbar.js +8 -2
- package/dist/wrapper/components/Snackbar/SnackbarRedux.js +2 -1
- package/package.json +4 -4
- package/src/ExtendedView.js +2 -2
- package/src/TableView.js +2 -0
- package/src/body/DefaultThemConfig.js +1 -1
- package/src/body/DisplayBodyCell.js +18 -2
- package/src/body/components/CPIMappingView.js +2 -2
- package/src/body/components/CPIModal.js +50 -46
- package/src/body/components/CustomLinkView.js +4 -1
- package/src/body/components/DataFormatView.js +4 -2
- package/src/body/components/assets/CPI_Icon_Dataset.svg +3 -3
- package/src/body/components/assets/CPI_Icon_Multi.svg +1 -1
- package/src/body/components/assets/CPI_Icon_Single.svg +1 -1
- package/src/body/components/assets/CPI_Icon_Study.svg +1 -1
- package/src/index.js +6 -1
- package/src/util/Dataformat.js +47 -0
- package/src/util/downloadTable.js +75 -34
- package/src/wrapper/components/AddFiles.js +7 -14
- package/src/wrapper/components/AddToCart/AddToCartView.js +4 -2
- package/src/wrapper/components/AddToCart/ReduxAddToCart.js +1 -0
- package/src/wrapper/components/CPIFilesView/CPIFilesView.js +15 -9
- package/src/wrapper/components/ReduxAddFile.js +1 -0
- package/src/wrapper/components/Snackbar/CartToast.js +99 -0
- package/src/wrapper/components/Snackbar/Snackbar.js +8 -4
- package/src/wrapper/components/Snackbar/SnackbarRedux.js +2 -1
|
@@ -1,6 +1,40 @@
|
|
|
1
|
-
import { formatBytes, formatColumnValues } from './Dataformat';
|
|
1
|
+
import { formatBytes, formatColumnValues, stripSurroundingBrackets } from './Dataformat';
|
|
2
2
|
import { actionCellTypes, notIncludedCellStyle } from './Types';
|
|
3
3
|
|
|
4
|
+
const AGE_FIELDS = new Set([
|
|
5
|
+
'age_at_diagnosis',
|
|
6
|
+
'participant_age_at_collection',
|
|
7
|
+
'age_at_treatment_start',
|
|
8
|
+
'age_at_treatment_end',
|
|
9
|
+
'age_at_response',
|
|
10
|
+
'age_at_last_known_survival_status',
|
|
11
|
+
'age_at_event_free_survival_status',
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Sentinel OpenSearch age values (-999) become "Not Reported" for CSV/JSON download.
|
|
16
|
+
* Supports scalars, arrays (files table), and bracketed strings.
|
|
17
|
+
*/
|
|
18
|
+
export function formatAgeForDownload(value) {
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
if (value.length === 0) {
|
|
21
|
+
return 'Not Reported';
|
|
22
|
+
}
|
|
23
|
+
return value.map((item) => formatAgeForDownload(item)).join('; ');
|
|
24
|
+
}
|
|
25
|
+
if (value === -999 || value === '-999' || value == null || value === '') {
|
|
26
|
+
return 'Not Reported';
|
|
27
|
+
}
|
|
28
|
+
if (typeof value === 'string' && value.startsWith('[') && value.endsWith(']')) {
|
|
29
|
+
const inner = value.slice(1, -1).trim();
|
|
30
|
+
if (!inner) {
|
|
31
|
+
return 'Not Reported';
|
|
32
|
+
}
|
|
33
|
+
return inner.split(',').map((item) => formatAgeForDownload(item.trim())).join('; ');
|
|
34
|
+
}
|
|
35
|
+
return String(value);
|
|
36
|
+
}
|
|
37
|
+
|
|
4
38
|
export function createFileName(fileName, type) {
|
|
5
39
|
const date = new Date();
|
|
6
40
|
const yyyy = date.getFullYear();
|
|
@@ -40,22 +74,25 @@ export function convertToCSV(jsonse, keysToInclude, header) {
|
|
|
40
74
|
if (line !== '') line += ',';
|
|
41
75
|
if (keyName === 'file_size') {
|
|
42
76
|
line += entry[keyName] !== null ? `"${formatBytes(entry[keyName])}"` : ' ';
|
|
43
|
-
} else if (keyName
|
|
44
|
-
if (entry[keyName]
|
|
45
|
-
line += '
|
|
77
|
+
} else if (AGE_FIELDS.has(keyName)) {
|
|
78
|
+
if (entry[keyName] == null) {
|
|
79
|
+
line += ' ';
|
|
46
80
|
} else {
|
|
47
|
-
line +=
|
|
81
|
+
line += `"${formatAgeForDownload(entry[keyName])}"`;
|
|
48
82
|
}
|
|
49
|
-
} else
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
line += `"${entry[keyName].toString().substring(1, entry[keyName].length - 1)}"`;
|
|
83
|
+
} else {
|
|
84
|
+
const raw = entry[keyName];
|
|
85
|
+
if (raw == null) {
|
|
86
|
+
line += ' ';
|
|
54
87
|
} else {
|
|
55
|
-
|
|
88
|
+
const stripped = stripSurroundingBrackets(raw);
|
|
89
|
+
if (stripped === '' || stripped === '[]') {
|
|
90
|
+
line += '';
|
|
91
|
+
} else {
|
|
92
|
+
const display = Array.isArray(stripped) ? stripped.join(', ') : stripped;
|
|
93
|
+
line += `"${display}"`;
|
|
94
|
+
}
|
|
56
95
|
}
|
|
57
|
-
} else {
|
|
58
|
-
line += entry[keyName] !== null ? `"${entry[keyName]}"` : ' ';
|
|
59
96
|
}
|
|
60
97
|
return line;
|
|
61
98
|
});
|
|
@@ -70,11 +107,18 @@ export function convertToCSV(jsonse, keysToInclude, header) {
|
|
|
70
107
|
return str;
|
|
71
108
|
}
|
|
72
109
|
|
|
110
|
+
/** Columns shown in the table, or marked downloadOnly (hidden in the UI, included in export). */
|
|
111
|
+
const isIncludedInDownload = ({ display, downloadOnly }) => Boolean(display || downloadOnly);
|
|
112
|
+
|
|
113
|
+
export function getDownloadColumns(columns = []) {
|
|
114
|
+
return columns.filter(({ cellType }) => !actionCellTypes.includes(cellType))
|
|
115
|
+
.filter(({ cellStyle }) => !notIncludedCellStyle.includes(cellStyle))
|
|
116
|
+
.filter(isIncludedInDownload);
|
|
117
|
+
}
|
|
118
|
+
|
|
73
119
|
export function downloadCSV(tableData, table, downloadFileName) {
|
|
74
120
|
const { columns = [] } = table;
|
|
75
|
-
const filterColumns = columns
|
|
76
|
-
.filter(({ cellStyle }) => !notIncludedCellStyle.includes(cellStyle))
|
|
77
|
-
.filter(({ display }) => display);
|
|
121
|
+
const filterColumns = getDownloadColumns(columns);
|
|
78
122
|
const formatDataVal = formatColumnValues(filterColumns, tableData);
|
|
79
123
|
const jsonse = JSON.stringify(formatDataVal);
|
|
80
124
|
const keysToInclude = filterColumns.filter(({ dataField }) => dataField)
|
|
@@ -95,28 +139,25 @@ export function downloadCSV(tableData, table, downloadFileName) {
|
|
|
95
139
|
|
|
96
140
|
export function downloadJson(tableData, table, downloadFileName) {
|
|
97
141
|
const { columns = [] } = table;
|
|
98
|
-
const toDelete = columns.filter((e) => !e.display);
|
|
99
|
-
const filterColumns = columns
|
|
100
|
-
.filter(({ display }) => display);
|
|
142
|
+
const toDelete = columns.filter((e) => !e.display && !e.downloadOnly);
|
|
143
|
+
const filterColumns = getDownloadColumns(columns);
|
|
101
144
|
let formatDataVal = formatColumnValues(filterColumns, tableData);
|
|
102
145
|
formatDataVal = formatDataVal.map((entry) => {
|
|
103
|
-
let survivalStatus = entry.last_known_survival_status;
|
|
104
|
-
let sampleId = entry.sample_id;
|
|
105
|
-
let dataCategory = entry.data_category;
|
|
106
146
|
const toReturn = { ...entry };
|
|
107
147
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
toReturn[
|
|
119
|
-
}
|
|
148
|
+
AGE_FIELDS.forEach((field) => {
|
|
149
|
+
if (Object.prototype.hasOwnProperty.call(entry, field) && entry[field] != null) {
|
|
150
|
+
toReturn[field] = formatAgeForDownload(entry[field]);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
Object.keys(toReturn).forEach((key) => {
|
|
155
|
+
if (AGE_FIELDS.has(key)) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
toReturn[key] = stripSurroundingBrackets(toReturn[key]);
|
|
159
|
+
});
|
|
160
|
+
|
|
120
161
|
toDelete.forEach((column) => delete toReturn[column.dataField]);
|
|
121
162
|
return toReturn;
|
|
122
163
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { useApolloClient } from '@apollo/client';
|
|
3
3
|
import CPIFilesView from './CPIFilesView/CPIFilesView';
|
|
4
|
-
import
|
|
4
|
+
import CartToast from './Snackbar/CartToast';
|
|
5
5
|
import AlertView from './AddToCartDialog/AddToCartDialogAlertView';
|
|
6
6
|
|
|
7
7
|
export const btnTypes = {
|
|
@@ -10,29 +10,21 @@ export const btnTypes = {
|
|
|
10
10
|
DOWNLOAD_MANIFEST: 'DOWNLOAD_MANIFEST',
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* Explore CPI add-files button. Uses CartToast (body portal) instead of the
|
|
14
|
+
* Global Search MUI Snackbar so the toast stays visible above the Explore Modal.
|
|
15
15
|
*/
|
|
16
16
|
const AddFilesView = (props) => {
|
|
17
17
|
const {
|
|
18
18
|
count,
|
|
19
|
+
alreadyInCartCount,
|
|
19
20
|
alertMessage,
|
|
20
21
|
cartFiles,
|
|
21
22
|
buttonStyle,
|
|
22
23
|
} = props;
|
|
23
|
-
/**
|
|
24
|
-
* snackbar state
|
|
25
|
-
*/
|
|
26
24
|
const [openSnackbar, setOpenSnackbar] = useState(false);
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* conditionally display max file Alter/Error dialog view
|
|
30
|
-
*/
|
|
31
25
|
const [displayAlter, setAlterDisplay] = useState(false);
|
|
32
|
-
/**
|
|
33
|
-
* acess bento app client via ApolloProvider
|
|
34
|
-
*/
|
|
35
26
|
const client = useApolloClient();
|
|
27
|
+
|
|
36
28
|
return (
|
|
37
29
|
<>
|
|
38
30
|
<CPIFilesView
|
|
@@ -43,9 +35,10 @@ const AddFilesView = (props) => {
|
|
|
43
35
|
cartFiles={cartFiles}
|
|
44
36
|
buttonStyle={buttonStyle}
|
|
45
37
|
/>
|
|
46
|
-
<
|
|
38
|
+
<CartToast
|
|
47
39
|
open={openSnackbar}
|
|
48
40
|
count={count}
|
|
41
|
+
alreadyInCartCount={alreadyInCartCount}
|
|
49
42
|
onClose={() => setOpenSnackbar(false)}
|
|
50
43
|
/>
|
|
51
44
|
{(displayAlter) && (
|
|
@@ -66,6 +66,7 @@ const AddToCartView = (props) => {
|
|
|
66
66
|
buttonStyle,
|
|
67
67
|
addFiles,
|
|
68
68
|
count,
|
|
69
|
+
alreadyInCartCount,
|
|
69
70
|
} = props;
|
|
70
71
|
|
|
71
72
|
// const [isDataloading, setIsDataloading] = useState(false);
|
|
@@ -85,14 +86,14 @@ const AddToCartView = (props) => {
|
|
|
85
86
|
*/
|
|
86
87
|
const addAllFiles = () => {
|
|
87
88
|
const idsInitial = fileId || [];
|
|
88
|
-
const ids = [idsInitial];
|
|
89
|
+
const ids = Array.isArray(idsInitial) ? idsInitial : [idsInitial];
|
|
89
90
|
const fileCount = ids.length;
|
|
90
91
|
const upperLimit = 200000;
|
|
91
92
|
const cartCount = cartFiles.length;
|
|
92
93
|
if (fileCount <= upperLimit && cartCount < upperLimit) {
|
|
93
94
|
const newIds = checkDuplicate(cartFiles, ids);
|
|
94
95
|
if (cartCount + newIds.length <= upperLimit) {
|
|
95
|
-
addFiles(
|
|
96
|
+
addFiles(ids);
|
|
96
97
|
setOpenSnackbar(true);
|
|
97
98
|
} else {
|
|
98
99
|
setAlterDisplay(true);
|
|
@@ -116,6 +117,7 @@ const AddToCartView = (props) => {
|
|
|
116
117
|
<SnackbarView
|
|
117
118
|
open={openSnackbar}
|
|
118
119
|
count={count}
|
|
120
|
+
alreadyInCartCount={alreadyInCartCount}
|
|
119
121
|
onClose={() => setOpenSnackbar(false)}
|
|
120
122
|
/>
|
|
121
123
|
{displayAlter && (
|
|
@@ -10,6 +10,7 @@ const AddToCartRedux = (props) => <AddToCartView {...props} />;
|
|
|
10
10
|
*/
|
|
11
11
|
const mapStateToProps = (state) => ({
|
|
12
12
|
count: state.cartReducer && state.cartReducer.count,
|
|
13
|
+
alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount,
|
|
13
14
|
cartFiles: state.cartReducer && state.cartReducer.filesId,
|
|
14
15
|
});
|
|
15
16
|
|
|
@@ -62,12 +62,12 @@ export const ToolTipView = (props) => {
|
|
|
62
62
|
const checkDuplicate = (cartFiles, ids) => (ids.filter((id) => !cartFiles[id]));
|
|
63
63
|
|
|
64
64
|
const addFileQuery = gql`
|
|
65
|
-
query search (
|
|
66
|
-
$
|
|
65
|
+
query search (
|
|
66
|
+
$pid: [String],
|
|
67
67
|
){
|
|
68
|
-
fileIDsFromList (
|
|
69
|
-
|
|
70
|
-
)
|
|
68
|
+
fileIDsFromList (
|
|
69
|
+
pid: $pid,
|
|
70
|
+
)
|
|
71
71
|
}
|
|
72
72
|
`;
|
|
73
73
|
|
|
@@ -86,6 +86,7 @@ const CPIFilesComponent = (props) => {
|
|
|
86
86
|
participantIds,
|
|
87
87
|
buttonStyle,
|
|
88
88
|
rowID,
|
|
89
|
+
onOptionClick,
|
|
89
90
|
} = props;
|
|
90
91
|
/**
|
|
91
92
|
* conditionally display dialog view
|
|
@@ -108,20 +109,25 @@ const CPIFilesComponent = (props) => {
|
|
|
108
109
|
* verify and set file ids
|
|
109
110
|
*/
|
|
110
111
|
const addAllFiles = () => {
|
|
112
|
+
if (typeof onOptionClick === 'function') {
|
|
113
|
+
onOptionClick();
|
|
114
|
+
}
|
|
111
115
|
let toAdd = [];
|
|
112
116
|
if (btnType === 'ADD_ALL_FILES') {
|
|
117
|
+
// Always include the modal participant pid plus any internal CPI-mapped ids.
|
|
118
|
+
toAdd = rowID ? [rowID] : [];
|
|
113
119
|
participantIds.forEach((e) => {
|
|
114
120
|
if (e.data_type === 'internal' && e.p_id) {
|
|
115
121
|
toAdd = toAdd.concat(e.p_id);
|
|
116
122
|
}
|
|
117
|
-
toAdd = toAdd.concat(rowID);
|
|
118
123
|
});
|
|
119
124
|
} else {
|
|
120
|
-
toAdd =
|
|
125
|
+
toAdd = (rowID ? [rowID] : []).concat(participantIds);
|
|
121
126
|
}
|
|
127
|
+
toAdd = [...new Set(toAdd.filter((id) => typeof id === 'string' && id))];
|
|
122
128
|
const fileIds = getFilesID({
|
|
123
129
|
client,
|
|
124
|
-
variables: {
|
|
130
|
+
variables: { pid: toAdd },
|
|
125
131
|
query: addFileQuery,
|
|
126
132
|
});
|
|
127
133
|
const upperLimit = 200000;
|
|
@@ -136,7 +142,7 @@ const CPIFilesComponent = (props) => {
|
|
|
136
142
|
setOpen(true);
|
|
137
143
|
setAddFilesId(ids);
|
|
138
144
|
} else {
|
|
139
|
-
const newIds = checkDuplicate(
|
|
145
|
+
const newIds = checkDuplicate(cartFilesDict, ids);
|
|
140
146
|
if (cartCount + newIds.length <= upperLimit) {
|
|
141
147
|
setOpen(true);
|
|
142
148
|
setAddFilesId(newIds);
|
|
@@ -10,6 +10,7 @@ const AddFilesRedux = (props) => <AddFiles {...props} />;
|
|
|
10
10
|
*/
|
|
11
11
|
const mapStateToProps = (state) => ({
|
|
12
12
|
count: state.cartReducer && state.cartReducer.count,
|
|
13
|
+
alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount,
|
|
13
14
|
cartFiles: state.cartReducer && state.cartReducer.filesId,
|
|
14
15
|
});
|
|
15
16
|
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import { formatCartAddMessage } from '@bento-core/cart';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Explore CPI cart toast.
|
|
7
|
+
* Body portal keeps it visible above the Explore Modal; styling matches the
|
|
8
|
+
* Global Search CPI MUI snackbar. Dropdown closes on option click so the toast
|
|
9
|
+
* does not need width hacks to avoid overlap.
|
|
10
|
+
*/
|
|
11
|
+
const SuccessIcon = () => (
|
|
12
|
+
<svg
|
|
13
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
14
|
+
width="24"
|
|
15
|
+
height="24"
|
|
16
|
+
viewBox="0 0 24 24"
|
|
17
|
+
aria-hidden="true"
|
|
18
|
+
focusable="false"
|
|
19
|
+
style={{ display: 'block', fill: 'currentColor' }}
|
|
20
|
+
>
|
|
21
|
+
<path d="M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z" />
|
|
22
|
+
</svg>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const CartToast = ({
|
|
26
|
+
open,
|
|
27
|
+
count,
|
|
28
|
+
alreadyInCartCount = 0,
|
|
29
|
+
onClose,
|
|
30
|
+
}) => {
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!open) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const timer = setTimeout(() => {
|
|
36
|
+
onClose();
|
|
37
|
+
}, 3000);
|
|
38
|
+
return () => clearTimeout(timer);
|
|
39
|
+
}, [open, onClose]);
|
|
40
|
+
|
|
41
|
+
if (!open || typeof document === 'undefined') {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return ReactDOM.createPortal(
|
|
46
|
+
<div
|
|
47
|
+
className="snackBar exploreCpiCartToast"
|
|
48
|
+
role="status"
|
|
49
|
+
aria-live="polite"
|
|
50
|
+
style={{
|
|
51
|
+
position: 'fixed',
|
|
52
|
+
bottom: '20px',
|
|
53
|
+
right: '24px',
|
|
54
|
+
zIndex: 99999,
|
|
55
|
+
pointerEvents: 'none',
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
<div
|
|
59
|
+
className="snackBarMessage"
|
|
60
|
+
style={{
|
|
61
|
+
display: 'flex',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
backgroundColor: '#323232',
|
|
64
|
+
color: '#fff',
|
|
65
|
+
padding: '6px 16px',
|
|
66
|
+
borderRadius: '4px',
|
|
67
|
+
boxShadow: '0px 3px 5px -1px rgba(0,0,0,0.2), 0px 6px 10px 0px rgba(0,0,0,0.14), 0px 1px 18px 0px rgba(0,0,0,0.12)',
|
|
68
|
+
minWidth: 288,
|
|
69
|
+
maxWidth: 568,
|
|
70
|
+
boxSizing: 'border-box',
|
|
71
|
+
fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
|
|
72
|
+
fontWeight: 400,
|
|
73
|
+
fontSize: '0.875rem',
|
|
74
|
+
lineHeight: 1.43,
|
|
75
|
+
letterSpacing: '0.01071em',
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<span
|
|
79
|
+
className="snackBarMessageIcon"
|
|
80
|
+
style={{
|
|
81
|
+
display: 'inline-flex',
|
|
82
|
+
alignItems: 'center',
|
|
83
|
+
marginRight: 8,
|
|
84
|
+
color: '#fff',
|
|
85
|
+
flexShrink: 0,
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
<SuccessIcon />
|
|
89
|
+
</span>
|
|
90
|
+
<span className="snackBarText">
|
|
91
|
+
{formatCartAddMessage(count, alreadyInCartCount)}
|
|
92
|
+
</span>
|
|
93
|
+
</div>
|
|
94
|
+
</div>,
|
|
95
|
+
document.body,
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export default CartToast;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Snackbar } from '@material-ui/core';
|
|
3
|
+
import { formatCartAddMessage } from '@bento-core/cart';
|
|
3
4
|
import SuccessOutlinedIcon from './SuccessOutlined';
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Legacy MUI snackbar kept for non-CPI table cart actions.
|
|
8
|
+
* Explore CPI uses CartToast instead.
|
|
9
|
+
*/
|
|
5
10
|
const SnackbarView = (props) => {
|
|
6
11
|
const {
|
|
7
12
|
count,
|
|
13
|
+
alreadyInCartCount = 0,
|
|
8
14
|
open,
|
|
9
15
|
onClose,
|
|
10
16
|
} = props;
|
|
@@ -22,7 +28,7 @@ const SnackbarView = (props) => {
|
|
|
22
28
|
open={open}
|
|
23
29
|
autoHideDuration={3000}
|
|
24
30
|
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
|
|
25
|
-
style={{ bottom: '-45%', zIndex:
|
|
31
|
+
style={{ bottom: '-45%', zIndex: 15000, pointerEvents: 'none' }}
|
|
26
32
|
message={(
|
|
27
33
|
<div className="snackBarMessage">
|
|
28
34
|
<span className="snackBarMessageIcon">
|
|
@@ -30,9 +36,7 @@ const SnackbarView = (props) => {
|
|
|
30
36
|
{' '}
|
|
31
37
|
</span>
|
|
32
38
|
<span className="snackBarText">
|
|
33
|
-
{count}
|
|
34
|
-
{' '}
|
|
35
|
-
File(s) successfully added to your cart
|
|
39
|
+
{formatCartAddMessage(count, alreadyInCartCount)}
|
|
36
40
|
</span>
|
|
37
41
|
</div>
|
|
38
42
|
)}
|
|
@@ -5,7 +5,8 @@ import SnackbarView from './Snackbar';
|
|
|
5
5
|
const ReduxSnackbar = ((props) => <SnackbarView {...props} />);
|
|
6
6
|
|
|
7
7
|
const mapStateToProps = (state) => ({
|
|
8
|
-
count: state.cartReducer.count,
|
|
8
|
+
count: state.cartReducer && state.cartReducer.count,
|
|
9
|
+
alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount,
|
|
9
10
|
});
|
|
10
11
|
|
|
11
12
|
export default connect(mapStateToProps, null)(ReduxSnackbar);
|