@xyo-network/react-wallet 2.47.18 → 2.47.20
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/cjs/components/MaxAccounts/MaxAccountsTableRow.js +43 -0
- package/dist/cjs/components/MaxAccounts/MaxAccountsTableRow.js.map +1 -0
- package/dist/cjs/components/MaxAccounts/OutOfBoundsSnackBar.js +10 -0
- package/dist/cjs/components/MaxAccounts/OutOfBoundsSnackBar.js.map +1 -0
- package/dist/cjs/components/MaxAccounts/index.js +5 -0
- package/dist/cjs/components/MaxAccounts/index.js.map +1 -0
- package/dist/cjs/components/WalletAccountSelect/Select.js.map +1 -1
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/docs.json +1528 -1300
- package/dist/esm/components/MaxAccounts/MaxAccountsTableRow.js +39 -0
- package/dist/esm/components/MaxAccounts/MaxAccountsTableRow.js.map +1 -0
- package/dist/esm/components/MaxAccounts/OutOfBoundsSnackBar.js +6 -0
- package/dist/esm/components/MaxAccounts/OutOfBoundsSnackBar.js.map +1 -0
- package/dist/esm/components/MaxAccounts/index.js +2 -0
- package/dist/esm/components/MaxAccounts/index.js.map +1 -0
- package/dist/esm/components/WalletAccountSelect/Select.js.map +1 -1
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/types/components/MaxAccounts/MaxAccountsTableRow.d.ts +9 -0
- package/dist/types/components/MaxAccounts/MaxAccountsTableRow.d.ts.map +1 -0
- package/dist/types/components/MaxAccounts/OutOfBoundsSnackBar.d.ts +10 -0
- package/dist/types/components/MaxAccounts/OutOfBoundsSnackBar.d.ts.map +1 -0
- package/dist/types/components/MaxAccounts/index.d.ts +2 -0
- package/dist/types/components/MaxAccounts/index.d.ts.map +1 -0
- package/dist/types/components/WalletAccountSelect/Select.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/index.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/components/MaxAccounts/MaxAccountsTableRow.tsx +68 -0
- package/src/components/MaxAccounts/OutOfBoundsSnackBar.tsx +31 -0
- package/src/components/MaxAccounts/index.ts +1 -0
- package/src/components/WalletAccountSelect/Select.tsx +0 -1
- package/src/components/index.ts +1 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ButtonGroup, TableCell, TableRow, Typography } from '@mui/material';
|
|
3
|
+
import { ButtonEx } from '@xylabs/react-button';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { OutOfBoundsSnackBar } from './OutOfBoundsSnackBar';
|
|
6
|
+
export const MaxAccountsTableRow = ({ activeAccountIndex, changeMaxAccounts, maxAccounts }) => {
|
|
7
|
+
const [desiredMaximumAccounts, setDesiredMaximumAccounts] = useState();
|
|
8
|
+
const [showSnackBar, setShowSnackBar] = useState(false);
|
|
9
|
+
const handleChangeMaxAccounts = (change) => {
|
|
10
|
+
if (maxAccounts !== undefined && activeAccountIndex !== undefined) {
|
|
11
|
+
switch (change) {
|
|
12
|
+
case 'decrease': {
|
|
13
|
+
const desiredMaximumAccounts = maxAccounts - 1;
|
|
14
|
+
const validMaximumAccounts = desiredMaximumAccounts > 0;
|
|
15
|
+
const maxAccountsWithinRange = activeAccountIndex + 1 <= desiredMaximumAccounts;
|
|
16
|
+
if (validMaximumAccounts && maxAccountsWithinRange) {
|
|
17
|
+
changeMaxAccounts?.(desiredMaximumAccounts);
|
|
18
|
+
}
|
|
19
|
+
if (!maxAccountsWithinRange)
|
|
20
|
+
setShowSnackBar(true);
|
|
21
|
+
setDesiredMaximumAccounts(desiredMaximumAccounts);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
case 'increase': {
|
|
25
|
+
changeMaxAccounts?.(maxAccounts + 1);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
default: {
|
|
29
|
+
console.error(change, 'is not a recognized value');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
throw new Error('Max Accounts is unset and needs a default');
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return (_jsxs(TableRow, { children: [_jsx(TableCell, { children: "Maximum Accounts" }), _jsx(TableCell, { align: "center", children: _jsx(Typography, { variant: 'caption', children: maxAccounts }) }), _jsxs(TableCell, { align: "center", children: [_jsxs(ButtonGroup, { children: [_jsx(ButtonEx, { onClick: () => handleChangeMaxAccounts('decrease'), variant: 'contained', size: 'small', children: "-" }), _jsx(ButtonEx, { onClick: () => handleChangeMaxAccounts('increase'), variant: 'contained', size: 'small', children: "+" })] }), _jsx(OutOfBoundsSnackBar, { desiredMaximumAccounts: desiredMaximumAccounts, activeAccountIndex: activeAccountIndex, setShowSnackBar: setShowSnackBar, showSnackBar: showSnackBar })] })] }));
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=MaxAccountsTableRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaxAccountsTableRow.js","sourceRoot":"","sources":["../../../../src/components/MaxAccounts/MaxAccountsTableRow.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAiB,UAAU,EAAE,MAAM,eAAe,CAAA;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAQ3D,MAAM,CAAC,MAAM,mBAAmB,GAAkC,CAAC,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,WAAW,EAAE,EAAE,EAAE;IAC3H,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,QAAQ,EAAsB,CAAA;IAC1F,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ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,OAAO,kBAEtF,EACX,KAAC,QAAQ,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,kBAEtF,IACC,EACd,KAAC,mBAAmB,IAClB,sBAAsB,EAAE,sBAAsB,EAC9C,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,GAC1B,IACQ,IACH,CACZ,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Alert, AlertTitle, Snackbar } from '@mui/material';
|
|
3
|
+
export const OutOfBoundsSnackBar = ({ activeAccountIndex, desiredMaximumAccounts, setShowSnackBar, showSnackBar, }) => {
|
|
4
|
+
return (_jsx(Snackbar, { anchorOrigin: { horizontal: 'center', vertical: 'top' }, autoHideDuration: 5000, onClose: () => setShowSnackBar?.(false), open: showSnackBar, children: _jsxs(Alert, { severity: 'error', onClose: () => setShowSnackBar?.(false), children: [_jsx(AlertTitle, { children: "Maximum Accounts Error" }), "Your currently selected account number (", activeAccountIndex !== undefined ? activeAccountIndex + 1 : '', ") cannot be greater than the desired Maximum Accounts (", desiredMaximumAccounts, ")."] }) }));
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=OutOfBoundsSnackBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OutOfBoundsSnackBar.js","sourceRoot":"","sources":["../../../../src/components/MaxAccounts/OutOfBoundsSnackBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAiB,MAAM,eAAe,CAAA;AAU1E,MAAM,CAAC,MAAM,mBAAmB,GAAuC,CAAC,EACtE,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,YAAY,GACb,EAAE,EAAE;IACH,OAAO,CACL,KAAC,QAAQ,IACP,YAAY,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EACvD,gBAAgB,EAAE,IAAI,EACtB,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,KAAK,CAAC,EACvC,IAAI,EAAE,YAAY,YAElB,MAAC,KAAK,IAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,KAAK,CAAC,aAC/D,KAAC,UAAU,yCAAoC,8CACN,kBAAkB,KAAK,SAAS,CAAC,CAAC,CAAC,kBAAkB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,6DACpF,sBAAsB,UACnC,GACC,CACZ,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/MaxAccounts/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../../src/components/WalletAccountSelect/Select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAe,MAAM,eAAe,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAgC,MAAM,mCAAmC,CAAA;AAErG,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../../src/components/WalletAccountSelect/Select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAe,MAAM,eAAe,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAgC,MAAM,mCAAmC,CA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C,EAC/E,IAAI,EAAE,IAAI,EACV,OAAO,EAAC,UAAU,KACd,KAAK,YAER,UAAU,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;gBACrC,MAAM,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;gBACtD,OAAO,CACL,KAAC,QAAQ,IAAiC,KAAK,EAAE,KAAK,YACpD,KAAC,mBAAmB,IAClB,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,GAAG,EAClC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,EACpC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,GAC1B,IARW,OAAO,EAAE,YAAY,CAAC,GAAG,CAS7B,CACZ,CAAA;YACH,CAAC,CAAC,GACO,CACZ,CAAC,CAAC,CAAC,CACF,KAAC,gBAAgB,IAAC,IAAI,EAAE,EAAE,GAAI,CAC/B,GACA,CACJ,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TableRowProps } from '@mui/material';
|
|
3
|
+
export interface MaxAccountsTableRow extends TableRowProps {
|
|
4
|
+
activeAccountIndex?: number;
|
|
5
|
+
changeMaxAccounts?: (maxAccounts: number) => void;
|
|
6
|
+
maxAccounts?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const MaxAccountsTableRow: React.FC<MaxAccountsTableRow>;
|
|
9
|
+
//# sourceMappingURL=MaxAccountsTableRow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaxAccountsTableRow.d.ts","sourceRoot":"","sources":["../../../../src/components/MaxAccounts/MaxAccountsTableRow.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAoC,aAAa,EAAc,MAAM,eAAe,CAAA;AAM3F,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,iBAAiB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;IACjD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAuD7D,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SnackbarProps } from '@mui/material';
|
|
2
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
3
|
+
export interface OutOfBoundsSnackBarProps extends SnackbarProps {
|
|
4
|
+
activeAccountIndex?: number;
|
|
5
|
+
desiredMaximumAccounts?: number;
|
|
6
|
+
setShowSnackBar?: Dispatch<SetStateAction<boolean>>;
|
|
7
|
+
showSnackBar?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const OutOfBoundsSnackBar: React.FC<OutOfBoundsSnackBarProps>;
|
|
10
|
+
//# sourceMappingURL=OutOfBoundsSnackBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OutOfBoundsSnackBar.d.ts","sourceRoot":"","sources":["../../../../src/components/MaxAccounts/OutOfBoundsSnackBar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,aAAa,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAEhD,MAAM,WAAW,wBAAyB,SAAQ,aAAa;IAC7D,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,eAAe,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;IACnD,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAoBlE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/MaxAccounts/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/WalletAccountSelect/Select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA8B,WAAW,EAAE,MAAM,eAAe,CAAA;AAEvE,OAAO,EAAuB,4BAA4B,EAAE,MAAM,mCAAmC,CAAA;AAIrG,KAAK,8BAA8B,GAAG,IAAI,CAAC,4BAA4B,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,cAAc,CAAC,CAAA;AAE5H,MAAM,WAAW,wBAAyB,SAAQ,8BAA8B,EAAE,WAAW,CAAC,MAAM,CAAC;IACnG,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/WalletAccountSelect/Select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA8B,WAAW,EAAE,MAAM,eAAe,CAAA;AAEvE,OAAO,EAAuB,4BAA4B,EAAE,MAAM,mCAAmC,CAAA;AAIrG,KAAK,8BAA8B,GAAG,IAAI,CAAC,4BAA4B,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,cAAc,CAAC,CAAA;AAE5H,MAAM,WAAW,wBAAyB,SAAQ,8BAA8B,EAAE,WAAW,CAAC,MAAM,CAAC;IACnG,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAMD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAiDlE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA"}
|
package/package.json
CHANGED
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"@xylabs/react-number-status": "^2.16.11",
|
|
18
18
|
"@xylabs/react-select": "^2.16.11",
|
|
19
19
|
"@xylabs/react-shared": "^2.16.11",
|
|
20
|
-
"@xyo-network/account": "^2.53.
|
|
21
|
-
"@xyo-network/account-model": "^2.53.
|
|
22
|
-
"@xyo-network/react-address-render": "^2.47.
|
|
23
|
-
"@xyo-network/react-network": "^2.47.
|
|
24
|
-
"@xyo-network/react-shared": "^2.47.
|
|
20
|
+
"@xyo-network/account": "^2.53.24",
|
|
21
|
+
"@xyo-network/account-model": "^2.53.24",
|
|
22
|
+
"@xyo-network/react-address-render": "^2.47.20",
|
|
23
|
+
"@xyo-network/react-network": "^2.47.20",
|
|
24
|
+
"@xyo-network/react-shared": "^2.47.20"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@mui/icons-material": "^5",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@storybook/react": "^6.5.16",
|
|
38
38
|
"@xylabs/ts-scripts-yarn3": "^2.16.1",
|
|
39
39
|
"@xylabs/tsconfig-react": "^2.16.1",
|
|
40
|
-
"@xyo-network/react-storybook": "^2.47.
|
|
40
|
+
"@xyo-network/react-storybook": "^2.47.20",
|
|
41
41
|
"require-from-string": "^2.0.2",
|
|
42
42
|
"typescript": "^4.9.5"
|
|
43
43
|
},
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
},
|
|
84
84
|
"sideEffects": false,
|
|
85
85
|
"types": "dist/types/index.d.ts",
|
|
86
|
-
"version": "2.47.
|
|
86
|
+
"version": "2.47.20"
|
|
87
87
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ButtonGroup, TableCell, TableRow, TableRowProps, Typography } from '@mui/material'
|
|
2
|
+
import { ButtonEx } from '@xylabs/react-button'
|
|
3
|
+
import { useState } from 'react'
|
|
4
|
+
|
|
5
|
+
import { OutOfBoundsSnackBar } from './OutOfBoundsSnackBar'
|
|
6
|
+
|
|
7
|
+
export interface MaxAccountsTableRow extends TableRowProps {
|
|
8
|
+
activeAccountIndex?: number
|
|
9
|
+
changeMaxAccounts?: (maxAccounts: number) => void
|
|
10
|
+
maxAccounts?: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const MaxAccountsTableRow: React.FC<MaxAccountsTableRow> = ({ activeAccountIndex, changeMaxAccounts, maxAccounts }) => {
|
|
14
|
+
const [desiredMaximumAccounts, setDesiredMaximumAccounts] = useState<number | undefined>()
|
|
15
|
+
const [showSnackBar, setShowSnackBar] = useState(false)
|
|
16
|
+
|
|
17
|
+
const handleChangeMaxAccounts = (change: 'increase' | 'decrease') => {
|
|
18
|
+
if (maxAccounts !== undefined && activeAccountIndex !== undefined) {
|
|
19
|
+
switch (change) {
|
|
20
|
+
case 'decrease': {
|
|
21
|
+
const desiredMaximumAccounts = maxAccounts - 1
|
|
22
|
+
const validMaximumAccounts = desiredMaximumAccounts > 0
|
|
23
|
+
const maxAccountsWithinRange = activeAccountIndex + 1 <= desiredMaximumAccounts
|
|
24
|
+
if (validMaximumAccounts && maxAccountsWithinRange) {
|
|
25
|
+
changeMaxAccounts?.(desiredMaximumAccounts)
|
|
26
|
+
}
|
|
27
|
+
if (!maxAccountsWithinRange) setShowSnackBar(true)
|
|
28
|
+
setDesiredMaximumAccounts(desiredMaximumAccounts)
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
case 'increase': {
|
|
32
|
+
changeMaxAccounts?.(maxAccounts + 1)
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
default: {
|
|
36
|
+
console.error(change, 'is not a recognized value')
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
throw new Error('Max Accounts is unset and needs a default')
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<TableRow>
|
|
46
|
+
<TableCell>Maximum Accounts</TableCell>
|
|
47
|
+
<TableCell align="center">
|
|
48
|
+
<Typography variant={'caption'}>{maxAccounts}</Typography>
|
|
49
|
+
</TableCell>
|
|
50
|
+
<TableCell align="center">
|
|
51
|
+
<ButtonGroup>
|
|
52
|
+
<ButtonEx onClick={() => handleChangeMaxAccounts('decrease')} variant={'contained'} size={'small'}>
|
|
53
|
+
-
|
|
54
|
+
</ButtonEx>
|
|
55
|
+
<ButtonEx onClick={() => handleChangeMaxAccounts('increase')} variant={'contained'} size={'small'}>
|
|
56
|
+
+
|
|
57
|
+
</ButtonEx>
|
|
58
|
+
</ButtonGroup>
|
|
59
|
+
<OutOfBoundsSnackBar
|
|
60
|
+
desiredMaximumAccounts={desiredMaximumAccounts}
|
|
61
|
+
activeAccountIndex={activeAccountIndex}
|
|
62
|
+
setShowSnackBar={setShowSnackBar}
|
|
63
|
+
showSnackBar={showSnackBar}
|
|
64
|
+
/>
|
|
65
|
+
</TableCell>
|
|
66
|
+
</TableRow>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Alert, AlertTitle, Snackbar, SnackbarProps } from '@mui/material'
|
|
2
|
+
import { Dispatch, SetStateAction } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface OutOfBoundsSnackBarProps extends SnackbarProps {
|
|
5
|
+
activeAccountIndex?: number
|
|
6
|
+
desiredMaximumAccounts?: number
|
|
7
|
+
setShowSnackBar?: Dispatch<SetStateAction<boolean>>
|
|
8
|
+
showSnackBar?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const OutOfBoundsSnackBar: React.FC<OutOfBoundsSnackBarProps> = ({
|
|
12
|
+
activeAccountIndex,
|
|
13
|
+
desiredMaximumAccounts,
|
|
14
|
+
setShowSnackBar,
|
|
15
|
+
showSnackBar,
|
|
16
|
+
}) => {
|
|
17
|
+
return (
|
|
18
|
+
<Snackbar
|
|
19
|
+
anchorOrigin={{ horizontal: 'center', vertical: 'top' }}
|
|
20
|
+
autoHideDuration={5000}
|
|
21
|
+
onClose={() => setShowSnackBar?.(false)}
|
|
22
|
+
open={showSnackBar}
|
|
23
|
+
>
|
|
24
|
+
<Alert severity={'error'} onClose={() => setShowSnackBar?.(false)}>
|
|
25
|
+
<AlertTitle>Maximum Accounts Error</AlertTitle>
|
|
26
|
+
Your currently selected account number ({activeAccountIndex !== undefined ? activeAccountIndex + 1 : ''}) cannot be greater than the desired
|
|
27
|
+
Maximum Accounts ({desiredMaximumAccounts}).
|
|
28
|
+
</Alert>
|
|
29
|
+
</Snackbar>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MaxAccountsTableRow'
|
package/src/components/index.ts
CHANGED