diff --git a/package-lock.json b/package-lock.json index e43df2a..7a73d9b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,8 +14,6 @@ "@mui/icons-material": "^6.1.6", "@mui/material": "^6.1.6", "@mui/styles": "^6.1.6", - "@mui/x-data-grid": "^7.22.2", - "@mui/x-date-pickers": "^7.22.2", "@sentry/react": "^8.38.0", "@types/classnames": "^2.3.0", "axios": "^1.7.7", @@ -1512,126 +1510,6 @@ } } }, - "node_modules/@mui/x-data-grid": { - "version": "7.22.2", - "resolved": "https://registry.npmjs.org/@mui/x-data-grid/-/x-data-grid-7.22.2.tgz", - "integrity": "sha512-yfy2s5A6tbajQZiEdsba49T4FYb9F0WPrzbbG30dl1+sIiX4ZRX7ma44UIDGPZrsZv8xkkE+p8qeJxZ7OaMteA==", - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.25.7", - "@mui/utils": "^5.16.6 || ^6.0.0", - "@mui/x-internals": "7.21.0", - "clsx": "^2.1.1", - "prop-types": "^15.8.1", - "reselect": "^5.1.1" - }, - "engines": { - "node": ">=14.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/mui-org" - }, - "peerDependencies": { - "@emotion/react": "^11.9.0", - "@emotion/styled": "^11.8.1", - "@mui/material": "^5.15.14 || ^6.0.0", - "@mui/system": "^5.15.14 || ^6.0.0", - "react": "^17.0.0 || ^18.0.0", - "react-dom": "^17.0.0 || ^18.0.0" - }, - "peerDependenciesMeta": { - "@emotion/react": { - "optional": true - }, - "@emotion/styled": { - "optional": true - } - } - }, - "node_modules/@mui/x-date-pickers": { - "version": "7.22.2", - "integrity": "sha512-1KHSlIlnSoY3oHm820By8X344pIdGYqPvCCvfVHrEeeIQ/pHdxDD8tjZFWkFl4Jgm9oVFK90fMcqNZAzc+WaCw==", - "dependencies": { - "@babel/runtime": "^7.25.7", - "@mui/utils": "^5.16.6 || ^6.0.0", - "@mui/x-internals": "7.21.0", - "@types/react-transition-group": "^4.4.11", - "clsx": "^2.1.1", - "prop-types": "^15.8.1", - "react-transition-group": "^4.4.5" - }, - "engines": { - "node": ">=14.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/mui-org" - }, - "peerDependencies": { - "@emotion/react": "^11.9.0", - "@emotion/styled": "^11.8.1", - "@mui/material": "^5.15.14 || ^6.0.0", - "@mui/system": "^5.15.14 || ^6.0.0", - "date-fns": "^2.25.0 || ^3.2.0 || ^4.0.0", - "date-fns-jalali": "^2.13.0-0 || ^3.2.0-0", - "dayjs": "^1.10.7", - "luxon": "^3.0.2", - "moment": "^2.29.4", - "moment-hijri": "^2.1.2 || ^3.0.0", - "moment-jalaali": "^0.7.4 || ^0.8.0 || ^0.9.0 || ^0.10.0", - "react": "^17.0.0 || ^18.0.0", - "react-dom": "^17.0.0 || ^18.0.0" - }, - "peerDependenciesMeta": { - "@emotion/react": { - "optional": true - }, - "@emotion/styled": { - "optional": true - }, - "date-fns": { - "optional": true - }, - "date-fns-jalali": { - "optional": true - }, - "dayjs": { - "optional": true - }, - "luxon": { - "optional": true - }, - "moment": { - "optional": true - }, - "moment-hijri": { - "optional": true - }, - "moment-jalaali": { - "optional": true - } - } - }, - "node_modules/@mui/x-internals": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@mui/x-internals/-/x-internals-7.21.0.tgz", - "integrity": "sha512-94YNyZ0BhK5Z+Tkr90RKf47IVCW8R/1MvdUhh6MCQg6sZa74jsX+x+gEZ4kzuCqOsuyTyxikeQ8vVuCIQiP7UQ==", - "dependencies": { - "@babel/runtime": "^7.25.7", - "@mui/utils": "^5.16.6 || ^6.0.0" - }, - "engines": { - "node": ">=14.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/mui-org" - }, - "peerDependencies": { - "react": "^17.0.0 || ^18.0.0" - } - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -4368,12 +4246,6 @@ "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" }, - "node_modules/reselect": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.1.tgz", - "integrity": "sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w==", - "license": "MIT" - }, "node_modules/resolve": { "version": "1.22.8", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", diff --git a/package.json b/package.json index 578a711..90413e1 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,6 @@ "@mui/icons-material": "^6.1.6", "@mui/material": "^6.1.6", "@mui/styles": "^6.1.6", - "@mui/x-data-grid": "^7.22.2", - "@mui/x-date-pickers": "^7.22.2", "@sentry/react": "^8.38.0", "@types/classnames": "^2.3.0", "axios": "^1.7.7", diff --git a/src/common/SearchSelect.tsx b/src/common/SearchSelect.tsx index f9af4c6..3564db3 100644 --- a/src/common/SearchSelect.tsx +++ b/src/common/SearchSelect.tsx @@ -52,7 +52,7 @@ export default function SearchSelect(props: Props) { multiple, variant, style, - getOptionSelected, + // getOptionSelected, onChange, onKeyDown } = props; @@ -65,6 +65,17 @@ export default function SearchSelect(props: Props) { return { value: s, label: s } as Option; }; + const anyToLabel = (o: any): string => { + if (o.text && o.value) { + return o.text + " - " + o.value + } else if (o.value) { + return o.value + } else if (o.label) { + return o.label + } + return o.toString(); + }; + return ( { + // return anyToLabel(option) + // console.log(option) + // console.log("Is Option: ",option instanceof Option) if (option instanceof Option) { return option.text + " - " + option.value + // } else if (option.text && option.value) { + } else { - return option as string + return anyToLabel(option) } }} // getOptionSelected={ diff --git a/src/navigation/Router.tsx b/src/navigation/Router.tsx index 300049e..15d9ee4 100644 --- a/src/navigation/Router.tsx +++ b/src/navigation/Router.tsx @@ -53,7 +53,7 @@ export default function Router(props: Props) { {/* Page routes */} } /> - } /> + } /> {/* } diff --git a/src/pages/Users.tsx b/src/pages/Users.tsx new file mode 100644 index 0000000..8cd6c8b --- /dev/null +++ b/src/pages/Users.tsx @@ -0,0 +1,468 @@ +import { + Avatar, + Box, + Button, + Collapse, + darken, + DialogActions, + DialogContent, + DialogTitle, + Divider, + IconButton, + List, + ListItem, + ListItemAvatar, + ListItemButton, + ListItemIcon, + ListItemText, + ListSubheader, + PaletteColor, + Paper, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TablePagination, + TableRow, + Theme, + Typography, +} from "@mui/material"; +import ResponsiveDialog from "common/ResponsiveDialog"; +// import { getTableIcons } from "common/ResponsiveTable"; +import SearchSelect, { Option } from "common/SearchSelect"; +// import SmartBreadcrumb from "common/SmartBreadcrumb"; +import { useMobile, useSnackbar, useUserAPI } from "hooks"; +// import MaterialTable, { Column } from "material-table"; +import { User } from "models"; +import PageContainer from "pages/PageContainer"; +// import { ListUsersResponse } from "providers/pond/userAPI"; +import React, { useEffect, useState } from "react"; +import { makeStyles } from "@mui/styles"; +import { pond } from "protobuf-ts/pond"; +import { getSecondaryColour, getSignatureAccentColour } from "services/whiteLabel"; +import { Add, ChevronRight, Face, Remove } from "@mui/icons-material"; + +const useStyles = makeStyles((theme: Theme) => { + // const isMobile = useMobile() + return ({ + gutter: { + backgroundColor: darken(theme.palette.background.paper, 0.03), + border: "none" + }, + dataTable: { + backgroundColor: theme.palette.background.paper + }, + tableContainer: { + margin: theme.spacing(1), + [theme.breakpoints.up("sm")]: { + margin: theme.spacing(2) + }, + width: "auto" + }, + title: { + padding: theme.spacing(1) + }, + titleContainer: { + border: "none" + }, + chipContainer: { + maxWidth: "100%", + maxHeight: "100%", + justifyContent: "flex-start", + alignItems: "flex-start" + }, + deleteIcon: { + color: "var(--status-alert)" + }, + userAvatar: { + color: "#fff", + backgroundColor: getSecondaryColour()["700" as keyof PaletteColor], + [theme.breakpoints.down("xs")]: { + width: "32px", + height: "32px" + } + }, + listItemButton: { + '&:hover': { + color: getSignatureAccentColour() + } + }, + avatarContainer: { + textAlign: "center", + justifyContent: "center", + }, + addIcon: { + color: "var(--status-ok)" + }})}, +); + +interface Props { + title: string | JSX.Element; +} + +export default function Users(props: Props) { + const { title } = props; + const classes = useStyles(); + const userAPI = useUserAPI(); + // let tableRef: any = React.createRef(); + const { error, success } = useSnackbar(); + const [pageSize, setPageSize] = useState(5); + const [page, setPage] = useState(0); + const [total, setTotal] = useState(0); + const [showAllowAction, setShowAllowAction] = useState(false); + const [selectedAction, setSelectedAction] = useState