@mui/material#Divider JavaScript Examples
The following examples show how to use
@mui/material#Divider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js From fireact with MIT License | 6 votes |
AppMenu = () => {
return (
<List>
<Link to="/" style={{textDecoration:'none'}}>
<ListItem button key="My Accounts">
<ListItemIcon><AppIcon /></ListItemIcon>
<ListItemText primary={<Typography color="textPrimary">My Accounts</Typography>} />
</ListItem>
</Link>
<Divider />
<Link to="/user/profile" style={{textDecoration:'none'}}>
<ListItem button key="Profile">
<ListItemIcon><AccountBoxIcon /></ListItemIcon>
<ListItemText primary={<Typography color="textPrimary">Profile</Typography>} />
</ListItem>
</Link>
<Link to="/user/log" style={{textDecoration:'none'}}>
<ListItem button key="Activity Logs">
<ListItemIcon><ListAltIcon /></ListItemIcon>
<ListItemText primary={<Typography color="textPrimary">Activity Logs</Typography>} />
</ListItem>
</Link>
</List>
)
}
Example #2
Source File: Permissions.js From admin-web with GNU Affero General Public License v3.0 | 6 votes |
render() {
const { classes, t } = this.props;
const { snackbar, permittedUsers } = this.state;
return (
<FormControl className={classes.form}>
<Grid container alignItems="center" className={classes.headline}>
<Typography variant="h6">{t('Permitted Users')}</Typography>
<IconButton onClick={this.handleAddDialog(true)} size="large">
<AddCircleOutline color="primary" fontSize="small"/>
</IconButton>
</Grid>
<List>
{(permittedUsers || []).map((user, key) => <Fragment key={key}>
<ListItem className={classes.listItem}>
<ListItemText primary={user.displayName} />
<IconButton onClick={this.handleRemoveUser(user.ID, key)} size="large">
<Delete color="error" />
</IconButton>
</ListItem>
<Divider />
</Fragment>)}
</List>
<Feedback
snackbar={snackbar}
onClose={() => this.setState({ snackbar: '' })}
/>
</FormControl>
);
}
Example #3
Source File: AuthSocial.js From Django-REST-Framework-React-BoilerPlate with MIT License | 6 votes |
// ----------------------------------------------------------------------
export default function AuthSocial() {
return (
<>
<Stack direction="row" spacing={2}>
<Button fullWidth size="large" color="inherit" variant="outlined">
<Iconify icon="eva:google-fill" color="#DF3E30" width={22} height={22} />
</Button>
<Button fullWidth size="large" color="inherit" variant="outlined">
<Iconify icon="eva:facebook-fill" color="#1877F2" width={22} height={22} />
</Button>
<Button fullWidth size="large" color="inherit" variant="outlined">
<Iconify icon="eva:twitter-fill" color="#1C9CEA" width={22} height={22} />
</Button>
</Stack>
<Divider sx={{ my: 3 }}>
<Typography variant="body2" sx={{ color: 'text.secondary' }}>
OR
</Typography>
</Divider>
</>
);
}
Example #4
Source File: SideDrawer.js From react-saas-template with MIT License | 6 votes |
function SideDrawer(props) {
const { classes, onClose, open } = props;
return (
<Drawer anchor="right" open={open} variant="temporary" onClose={onClose}>
<Toolbar disableGutters className={classes.toolbar}>
<Box
pl={3}
pr={3}
display="flex"
justifyContent="space-between"
width="100%"
alignItems="center"
>
<Typography variant="h6">A Sidedrawer</Typography>
<IconButton
onClick={onClose}
color="primary"
aria-label="Close Sidedrawer"
size="large">
<CloseIcon />
</IconButton>
</Box>
</Toolbar>
<Divider />
</Drawer>
);
}
Example #5
Source File: Subscription.js From react-saas-template with MIT License | 6 votes |
function Subscription(props) {
const {
transactions,
classes,
openAddBalanceDialog,
selectSubscription
} = props;
useEffect(selectSubscription, [selectSubscription]);
return (
<Paper>
<List disablePadding>
<SubscriptionInfo openAddBalanceDialog={openAddBalanceDialog} />
<Divider className={classes.divider} />
<SubscriptionTable transactions={transactions} />
</List>
</Paper>
);
}
Example #6
Source File: DetailedExpansionPanel.jsx From matx-react with MIT License | 5 votes |
export default function DetailedExpansionPanel() {
return (
<AccordionRoot>
<Accordion defaultExpanded>
<AccordionSummary
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1c-content"
id="panel1c-header"
>
<Box className="column">
<Typography className="heading">Location</Typography>
</Box>
<Box className="column">
<Typography className="secondaryHeading">Select trip destination</Typography>
</Box>
</AccordionSummary>
<AccordionDetails className="details">
<Box className="column" />
<Box className="column">
<Chip label="Barbados" onDelete={() => {}} />
</Box>
<Box className="column helper">
<Typography variant="caption">
Select your destination of choice
<br />
<a href="#sub-labels-and-columns" className="link">
Learn more
</a>
</Typography>
</Box>
</AccordionDetails>
<Divider />
<AccordionActions>
<Button size="small">Cancel</Button>
<Button size="small" color="primary">
Save
</Button>
</AccordionActions>
</Accordion>
</AccordionRoot>
);
}
Example #7
Source File: index.js From fireact with MIT License | 5 votes |
Layout = ({drawerMenu, toolbarChildren, toolBarMenu, children}) => {
const theme = useTheme();
const [open, setOpen] = React.useState(false);
const handleDrawerOpen = () => {
setOpen(true);
};
const handleDrawerClose = () => {
setOpen(false);
};
const [breadcrumb, setBreadcrumb] = useState([]);
return (
<Box sx={{ display: 'flex'}}>
<CssBaseline />
<AppBar position="fixed" open={open}>
<Toolbar>
<div style={{paddingRight: '20px', display: open?"none":"inline-flex"}}><Logo /></div>
<IconButton
color="inherit"
aria-label="open drawer"
onClick={handleDrawerOpen}
edge="start"
sx={{
marginRight: '36px',
...(open && { display: 'none' }),
}}
>
<MenuIcon />
</IconButton>
{toolbarChildren}
<div style={{
marginLeft: "auto",
marginRight: "0px",
}}>{toolBarMenu}</div>
</Toolbar>
</AppBar>
<Drawer
variant="permanent"
open={open}
>
<DrawerHeader>
{open && <div style={{marginLeft:'0px', marginRight:'auto', display:'inline-flex',alignItems: 'center', flexWrap: 'wrap',}}>
<div style={{display: 'inline-flex', paddingRight: '20px'}}>
<Logo />
</div>
<h2>FIREACT</h2>
</div>}
<IconButton onClick={handleDrawerClose}>
{theme.direction === 'rtl' ? <ChevronRightIcon /> : <ChevronLeftIcon />}
</IconButton>
</DrawerHeader>
<Divider />
{drawerMenu}
<Divider />
</Drawer>
<Box component="main" sx={{ flexGrow: 1, overflow:'hidden'}}>
<DrawerHeader />
<Box width={1} style={{position:"fixed", zIndex: '1200'}}>
<Paper square>
<Box p={2}>
<Breadcrumb links={breadcrumb} />
</Box>
</Paper>
</Box>
<div style={{position: 'relative'}}>
<Box mt={10} ml={3} mr={3} mb={3}>
<BreadcrumbContext.Provider value={{setBreadcrumb}}>
{children}
</BreadcrumbContext.Provider>
</Box>
</div>
</Box>
</Box>
);
}
Example #8
Source File: Ldap.js From admin-web with GNU Affero General Public License v3.0 | 5 votes |
render() {
const { classes, t, domain, ldapUsers } = this.props;
const { loading, snackbar, confirming } = this.state;
const writable = this.context.includes(DOMAIN_ADMIN_WRITE);
return (
<ViewWrapper
topbarTitle={domain.domainname}
snackbar={snackbar}
onSnackbarClose={() => this.setState({ snackbar: '' })}
>
<Typography variant="h2" className={classes.pageTitle}>
<BackIcon onClick={this.handleNavigation(domain.ID + '/users')} className={classes.backIcon} />
<span className={classes.pageTitleSecondary}>| </span>
{t("LDAP")}
</Typography>
<Grid container justifyContent="center">
<TextField
autoFocus
placeholder={t("Search LDAP")}
onChange={this.handleLdapSearch}
variant="outlined"
color="primary"
fullWidth
className={classes.searchTf}
InputProps={{
startAdornment: (
<InputAdornment position="start">
<Search color="primary"/>
</InputAdornment>
),
}}
/>
</Grid>
{ldapUsers.length > 0 && <Paper elevation={1}>
<List>
{ldapUsers.map((user, idx) => <React.Fragment key={idx}>
<ListItem >
<ListItemText
primary={user.name}
primaryTypographyProps={{ color: 'primary' }}
secondary={user.email}
/>
{writable && <IconButton onClick={this.handleImport(user)} size="large">
<Import />
</IconButton>}
</ListItem>
<Divider />
</React.Fragment>
)}
</List>
</Paper>}
<Grid container justifyContent="center" className={classes.loaderContainer}>
<Grow
in={loading}
timeout={{
appear: 500,
enter: 10,
exit: 10,
}}
>
<CircularProgress color="primary" size={40}/>
</Grow>
</Grid>
<ImportDialog
open={!!confirming}
user={confirming || {}}
onSuccess={this.handleSuccess}
onClose={this.handleClose}
onError={this.handleError}
/>
</ViewWrapper>
);
}
Example #9
Source File: DBService.js From admin-web with GNU Affero General Public License v3.0 | 5 votes |
render() {
const { classes, t } = this.props;
const { name, snackbar, files, deleting } = this.state;
const writable = this.context.includes(SYSTEM_ADMIN_WRITE);
return (
<ViewWrapper
topbarTitle={t('DB Service')}
snackbar={snackbar}
onSnackbarClose={() => this.setState({ snackbar: '' })}
>
<Paper className={classes.paper} elevation={1}>
<Grid container>
<Typography
color="primary"
variant="h5"
>
{t('editHeadline', { item: 'Service' })}
</Typography>
</Grid>
<FormControl className={classes.form}>
<TextField
label={t("Service")}
className={classes.input}
value={name || ''}
autoFocus
onChange={this.handleInput('name')}
/>
</FormControl>
<Typography variant="h6">Files</Typography>
<List>
{files.map((file, idx) => <React.Fragment key={idx}>
<ListItem button onClick={this.handleNavigation(`dbconf/${name}/${file}`)}>
<ListItemText
primary={file}
/>
{writable && <IconButton onClick={this.handleDelete(file)} size="large">
<Delete color="error" />
</IconButton>}
</ListItem>
<Divider />
</React.Fragment>
)}
</List>
<Button
color="secondary"
onClick={this.handleNavigation('dbconf')}
style={{ marginRight: 8 }}
>
{t('Back')}
</Button>
<Button
variant="contained"
color="primary"
onClick={this.handleEdit}
disabled={!writable}
>
{t('Save')}
</Button>
</Paper>
<DomainDataDelete
open={!!deleting}
delete={this.props.delete}
onSuccess={this.handleDeleteSuccess}
onError={this.handleDeleteError}
onClose={this.handleDeleteClose}
item={deleting}
id={deleting}
domainID={name}
/>
</ViewWrapper>
);
}
Example #10
Source File: MessagePopperButton.js From react-saas-template with MIT License | 5 votes |
function MessagePopperButton(props) {
const { classes, messages } = props;
const anchorEl = useRef();
const [isOpen, setIsOpen] = useState(false);
const handleClick = useCallback(() => {
setIsOpen(!isOpen);
}, [isOpen, setIsOpen]);
const handleClickAway = useCallback(() => {
setIsOpen(false);
}, [setIsOpen]);
const id = isOpen ? "scroll-playground" : null;
return (
<Fragment>
<IconButton
onClick={handleClick}
buttonRef={anchorEl}
aria-label="Open Messages"
aria-describedby={id}
color="primary"
size="large">
<MessageIcon />
</IconButton>
<Popover
disableScrollLock
id={id}
open={isOpen}
anchorEl={anchorEl.current}
anchorOrigin={{
vertical: "bottom",
horizontal: "left",
}}
transformOrigin={{
vertical: "top",
horizontal: "right",
}}
classes={{ paper: classes.popoverPaper }}
onClose={handleClickAway}
>
<AppBar position="static" color="inherit" className={classes.noShadow}>
<Box pt={1} pl={2} pb={1} pr={1}>
<Typography variant="subtitle1">Messages</Typography>
</Box>
<Divider className={classes.divider} />
</AppBar>
<List dense className={classes.tabContainer}>
{messages.length === 0 ? (
<ListItem>
<ListItemText>
You haven't received any messages yet.
</ListItemText>
</ListItem>
) : (
messages.map((element, index) => (
<MessageListItem
key={index}
message={element}
divider={index !== messages.length - 1}
/>
))
)}
</List>
</Popover>
</Fragment>
);
}
Example #11
Source File: index.js From fireact with MIT License | 5 votes |
UserMenu = () => {
const [anchorEl, setAnchorEl] = useState(null);
const open = Boolean(anchorEl);
const handleMenu = (event) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
const history = useHistory();
return (
<>
<AuthContext.Consumer>
{(context) => (
<>
<IconButton
ria-label="account of current user"
aria-controls="menu-appbar"
aria-haspopup="true"
onClick={handleMenu}
color="inherit"
>
<Avatar alt={context.authUser.user.displayName} src={context.authUser.user.photoURL} />
</IconButton>
<Menu
id="menu-appbar"
anchorEl={anchorEl}
anchorOrigin={{
vertical: 'top',
horizontal: 'right',
}}
keepMounted
transformOrigin={{
vertical: 'top',
horizontal: 'right',
}}
open={open}
onClose={handleClose}
>
<MenuItem onClick={(e)=>{
e.preventDefault();
handleClose();
history.push("/user/profile");
}}>
<AccountBoxIcon style={{marginRight: '10px'}} />
Profile
</MenuItem>
<MenuItem onClick={(e)=>{
e.preventDefault();
handleClose();
history.push("/user/log");
}}>
<ListAltIcon style={{marginRight: '10px'}} />
Activity Logs
</MenuItem>
<Divider />
<MenuItem onClick={() => userSignOut()}>
<ExitToAppIcon style={{marginRight: '10px'}} />
Sign Out
</MenuItem>
</Menu>
</>
)}
</AuthContext.Consumer>
</>
)
}
Example #12
Source File: index.js From fireact with MIT License | 5 votes |
AccountMenu = () => {
const { accountId } = useParams();
const { userData } = useContext(AuthContext);
useEffect(() => {
document.querySelectorAll('.c-sidebar').forEach(element => {
window.coreui.Sidebar._sidebarInterface(element)
});
})
return (
<List>
<Link to={'/account/'+accountId+'/'} style={{textDecoration:'none'}}>
<ListItem button key="Demo App">
<ListItemIcon><DashboardIcon /></ListItemIcon>
<ListItemText primary={<Typography color="textPrimary">Demo App</Typography>} />
</ListItem>
</Link>
{userData.currentAccount.role === 'admin' &&
<>
<Divider />
<Link to={'/account/'+accountId+'/users'} style={{textDecoration:'none'}}>
<ListItem button key="Users">
<ListItemIcon><PeopleIcon /></ListItemIcon>
<ListItemText primary={<Typography color="textPrimary">Users</Typography>} />
</ListItem>
</Link>
<Link to={'/account/'+accountId+'/billing'} style={{textDecoration:'none'}}>
<ListItem button key="Billing">
<ListItemIcon><PaymentIcon /></ListItemIcon>
<ListItemText primary={<Typography color="textPrimary">Billing</Typography>} />
</ListItem>
</Link>
</>
}
</List>
)
}
Example #13
Source File: PostContent.js From react-saas-template with MIT License | 4 votes |
function PostContent(props) {
const {
pushMessageToSnackbar,
setPosts,
posts,
openAddPostModal,
classes,
} = props;
const [page, setPage] = useState(0);
const [isDeletePostDialogOpen, setIsDeletePostDialogOpen] = useState(false);
const [isDeletePostDialogLoading, setIsDeletePostDialogLoading] = useState(
false
);
const closeDeletePostDialog = useCallback(() => {
setIsDeletePostDialogOpen(false);
setIsDeletePostDialogLoading(false);
}, [setIsDeletePostDialogOpen, setIsDeletePostDialogLoading]);
const deletePost = useCallback(() => {
setIsDeletePostDialogLoading(true);
setTimeout(() => {
const _posts = [...posts];
const index = _posts.find((element) => element.id === deletePost.id);
_posts.splice(index, 1);
setPosts(_posts);
pushMessageToSnackbar({
text: "Your post has been deleted",
});
closeDeletePostDialog();
}, 1500);
}, [
posts,
setPosts,
setIsDeletePostDialogLoading,
pushMessageToSnackbar,
closeDeletePostDialog,
]);
const onDelete = useCallback(() => {
setIsDeletePostDialogOpen(true);
}, [setIsDeletePostDialogOpen]);
const handleChangePage = useCallback(
(__, page) => {
setPage(page);
},
[setPage]
);
const printImageGrid = useCallback(() => {
if (posts.length > 0) {
return (
<Box p={1}>
<Grid container spacing={1}>
{posts
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
.map((post) => (
<Grid item xs={6} sm={4} md={3} key={post.id}>
<SelfAligningImage
src={post.src}
title={post.name}
timeStamp={post.timestamp}
options={[
{
name: "Delete",
onClick: () => {
onDelete(post);
},
icon: <DeleteIcon />,
},
]}
/>
</Grid>
))}
</Grid>
</Box>
);
}
return (
<Box m={2}>
<HighlightedInformation>
No posts added yet. Click on "NEW" to create your first one.
</HighlightedInformation>
</Box>
);
}, [posts, onDelete, page]);
return (
<Paper>
<Toolbar className={classes.toolbar}>
<Typography variant="h6">Your Posts</Typography>
<Button
variant="contained"
color="secondary"
onClick={openAddPostModal}
disableElevation
>
Add Post
</Button>
</Toolbar>
<Divider />
{printImageGrid()}
<TablePagination
component="div"
count={posts.length}
rowsPerPage={rowsPerPage}
page={page}
backIconButtonProps={{
"aria-label": "Previous Page",
}}
nextIconButtonProps={{
"aria-label": "Next Page",
}}
onPageChange={handleChangePage}
classes={{
select: classes.dNone,
selectIcon: classes.dNone,
actions: posts.length > 0 ? classes.dBlock : classes.dNone,
caption: posts.length > 0 ? classes.dBlock : classes.dNone,
}}
labelRowsPerPage=""
/>
<ConfirmationDialog
open={isDeletePostDialogOpen}
title="Confirmation"
content="Do you really want to delete the post?"
onClose={closeDeletePostDialog}
loading={isDeletePostDialogLoading}
onConfirm={deletePost}
/>
</Paper>
);
}
Example #14
Source File: AccountPopover.js From Django-REST-Framework-React-BoilerPlate with MIT License | 4 votes |
// ----------------------------------------------------------------------
export default function AccountPopover() {
const dispatch = useDispatch();
const navigate = useNavigate();
const anchorRef = useRef(null);
const [open, setOpen] = useState(null);
const handleOpen = (event) => {
setOpen(event.currentTarget);
};
const handleClose = () => {
setOpen(null);
};
const userLogin = useSelector((state) => state.userLogin);
const { userInfo } = userLogin;
useEffect(() => {
if (!userInfo) {
navigate('/login', { replace: true });
dispatch({ type: LOGOUT });
}
}, [navigate, userInfo]);
const logoutHandler = () => {
dispatch(logout());
};
return (
<>
<IconButton
ref={anchorRef}
onClick={handleOpen}
sx={{
p: 0,
...(open && {
'&:before': {
zIndex: 1,
content: "''",
width: '100%',
height: '100%',
borderRadius: '50%',
position: 'absolute',
bgcolor: (theme) => alpha(theme.palette.grey[900], 0.8),
},
}),
}}
>
<Avatar src={account.photoURL} alt="photoURL" />
</IconButton>
<MenuPopover
open={Boolean(open)}
anchorEl={open}
onClose={handleClose}
sx={{
p: 0,
mt: 1.5,
ml: 0.75,
'& .MuiMenuItem-root': {
typography: 'body2',
borderRadius: 0.75,
},
}}
>
<Box sx={{ my: 1.5, px: 2.5 }}>
<Typography variant="subtitle2" noWrap>
{userInfo ? <>{userInfo.name}</> : 'John Doe'}
</Typography>
<Typography variant="body2" sx={{ color: 'text.secondary' }} noWrap>
{userInfo ? <>{userInfo.email}</> : '[email protected]'}
</Typography>
</Box>
<Divider sx={{ borderStyle: 'dashed' }} />
<Stack sx={{ p: 1 }}>
{MENU_OPTIONS.map((option) => (
<MenuItem key={option.label} to={option.linkTo} component={RouterLink} onClick={handleClose}>
{option.label}
</MenuItem>
))}
</Stack>
<Divider sx={{ borderStyle: 'dashed' }} />
<MenuItem onClick={logoutHandler} sx={{ m: 1 }}>
Logout
</MenuItem>
</MenuPopover>
</>
);
}
Example #15
Source File: FolderPermissions.js From admin-web with GNU Affero General Public License v3.0 | 4 votes |
render() {
const { classes, t, open, onCancel, owners, domain, folderID } = this.props;
const { permissions, selected, adding, deleting } = this.state;
return (
<Dialog
onClose={onCancel}
open={open}
maxWidth="sm"
fullWidth
TransitionProps={{
onEnter: this.handleEnter,
}}
>
<DialogTitle>{t('Permissions')}</DialogTitle>
<DialogContent style={{ minWidth: 400 }}>
{owners.length > 0 ? <List className={classes.list}>
{owners.map((user, idx) => <Fragment key={idx}>
<ListItem disablePadding>
<ListItemButton
selected={user.memberID === selected?.memberID}
component="a"
onClick={this.handleUserSelect(user)}
>
<ListItemText primary={user.username}/>
</ListItemButton>
</ListItem>
<Divider />
</Fragment>)}
</List> : <div className={classes.noOwnersContainer}>
<em>{t('No owners')}</em>
</div>}
<div className={classes.addUserRow}>
<Button
onClick={this.handleAdd}
variant="contained"
color="primary"
style={{ marginRight: 8 }}
>
{t('Add')}
</Button>
<Button
onClick={this.handleDelete}
color="secondary"
>
{t('Remove')}
</Button>
</div>
<FormControl fullWidth style={{ marginBottom: 4 }}>
<InputLabel>{t('Profile')}</InputLabel>
<Select
labelId="demo-simple-select-label"
value={permissionProfiles.findIndex(profile => profile.value === permissions) === -1 ? "" : permissions}
label={t('Profile')}
onChange={this.handleProfileSelect}
>
{permissionProfiles.map((profile, idx) =>
<MenuItem key={idx} value={profile.value}>
{profile.name}
</MenuItem>
)}
</Select>
</FormControl>
<Grid container>
<Grid item xs={6}>
<FormControl className={classes.form}>
<FormLabel>Read</FormLabel>
<RadioGroup defaultValue={0} value={permissions & 1} onChange={this.handlePermissions}>
<FormControlLabel
value={0x0}
control={<Radio size="small" className={classes.radio}/>}
label="None"
/>
<FormControlLabel
value={0x1}
control={<Radio size="small" className={classes.radio}/>}
label="Full Details"
/>
</RadioGroup>
</FormControl>
</Grid>
<Grid item xs={6}>
<FormControl className={classes.form}>
<FormLabel>Write</FormLabel>
<FormControlLabel
control={
<Checkbox
value={0x2}
checked={Boolean(permissions & 0x2)}
onChange={this.handlePermissions}
className={classes.radio}
color="primary"
/>
}
label={t('Create items')}
/>
<FormControlLabel
control={
<Checkbox
value={0x80}
checked={Boolean(permissions & 0x80)}
className={classes.radio}
onChange={this.handlePermissions}
color="primary"
/>
}
label={t('Create subfolders')}
/>
<FormControlLabel
control={
<Checkbox
checked={Boolean(permissions & 0x8)}
value={0x8}
className={classes.radio}
onChange={this.handlePermissions}
color="primary"
/>
}
label={t('Edit own')}
/>
<FormControlLabel
control={
<Checkbox
className={classes.radio}
checked={Boolean(permissions & 0x20)}
value={0x20}
onChange={this.handlePermissions}
color="primary"
/>
}
label={t('Edit all')}
/>
</FormControl>
</Grid>
</Grid>
<Grid container style={{ marginTop: 16 }}>
<Grid item xs={6}>
<FormControl className={classes.form}>
<FormLabel>Delete items</FormLabel>
<RadioGroup
value={(permissions & 0x50) || true /* This is a bit janky */}
defaultValue={true}
onChange={this.handleRadioPermissions}
>
<FormControlLabel
value={(permissions & 0x50) === 0} // Has explicit handling
control={<Radio size="small" className={classes.radio}/>}
label="None" />
<FormControlLabel
value={0x10}
control={<Radio size="small" className={classes.radio}/>}
label="Own"
/>
<FormControlLabel
value={0x50}
control={<Radio size="small" className={classes.radio}/>}
label="All"
/>
</RadioGroup>
</FormControl>
</Grid>
<Grid item xs={6}>
<FormControl className={classes.form}>
<FormLabel>Other</FormLabel>
<FormControlLabel
control={
<Checkbox
className={classes.radio}
checked={Boolean(permissions & 0x100)}
value={0x100}
onChange={this.handlePermissions}
color="primary"
/>
}
label={t('Folder owner')}
/>
<FormControlLabel
control={
<Checkbox
className={classes.radio}
checked={Boolean(permissions & 0x200)}
onChange={this.handlePermissions}
color="primary"
value={0x200}
/>
}
label={t('Folder contact')}
/>
<FormControlLabel
control={
<Checkbox
className={classes.radio}
checked={Boolean(permissions & 0x400)}
onChange={this.handlePermissions}
color="primary"
value={0x400}
/>
}
label={t('Folder visible')}
/>
</FormControl>
</Grid>
</Grid>
</DialogContent>
<DialogActions>
<Button
onClick={onCancel}
color="secondary"
>
{t('Close')}
</Button>
<Button
onClick={this.handleSave}
variant="contained"
color="primary"
disabled={owners.length === 0 || !selected}
>
{t('Save')}
</Button>
</DialogActions>
<AddOwner
open={adding}
onSuccess={this.handleAddingSuccess}
onError={this.handleAddingError}
onCancel={this.handleAddingCancel}
domain={domain}
folderID={folderID}
/>
{selected && <RemoveOwner
open={deleting}
onSuccess={this.handleDeleteSuccess}
onError={this.handleDeleteError}
onClose={this.handleDeleteClose}
ownerName={selected.username}
domainID={domain.ID}
folderID={folderID}
memberID={selected.memberID}
/>}
</Dialog>
);
}
Example #16
Source File: Contact.js From admin-web with GNU Affero General Public License v3.0 | 4 votes |
render() {
const { classes, t, user, handlePropertyChange } = this.props;
const { properties, ldapID } = user;
const { mobiletelephonenumber, comment, hometelephonenumber, home2telephonenumber, businesstelephonenumber,
business2telephonenumber, pagertelephonenumber, primaryfaxnumber, assistanttelephonenumber } = properties;
return (
<FormControl className={classes.form}>
<div className={classes.flexRow}>
<Typography variant="h6">{t('Telephone')}</Typography>
{ldapID && <Tooltip title={t("Warning") + ": " + t("Changes will be overwritten with next LDAP sync")}>
<Warning color="warning" fontSize="inherit" style={{ fontSize: 32 }}/>
</Tooltip>}
</div>
<Grid container>
<Grid item xs={12} className={classes.gridItem}>
<TextField
className={classes.input}
label={t("Business 1")}
fullWidth
value={businesstelephonenumber || ''}
onChange={handlePropertyChange('businesstelephonenumber')}
variant={ldapID ? "filled" : 'outlined'}
/>
<TextField
className={classes.input}
label={t("Privat 1")}
fullWidth
value={hometelephonenumber || ''}
onChange={handlePropertyChange('hometelephonenumber')}
variant={ldapID ? "filled" : 'outlined'}
/>
</Grid>
<Grid item xs={12} className={classes.gridItem}>
<TextField
className={classes.input}
label={t("Business 2")}
fullWidth
value={business2telephonenumber || ''}
onChange={handlePropertyChange('business2telephonenumber')}
variant={ldapID ? "filled" : 'outlined'}
/>
<TextField
className={classes.input}
label={t("Privat 2")}
fullWidth
value={home2telephonenumber || ''}
onChange={handlePropertyChange('home2telephonenumber')}
variant={ldapID ? "filled" : 'outlined'}
/>
</Grid>
<Grid item xs={12} className={classes.gridItem}>
<TextField
className={classes.input}
label={t("Fax")}
fullWidth
value={primaryfaxnumber || ''}
onChange={handlePropertyChange('primaryfaxnumber')}
variant={ldapID ? "filled" : 'outlined'}
/>
<TextField
className={classes.input}
label={t("Mobile")}
fullWidth
value={mobiletelephonenumber || ''}
onChange={handlePropertyChange('mobiletelephonenumber')}
variant={ldapID ? "filled" : 'outlined'}
/>
</Grid>
<Grid item xs={12} className={classes.gridItem}>
<TextField
className={classes.input}
label={t("Assistant")}
fullWidth
value={assistanttelephonenumber || ''}
onChange={handlePropertyChange('assistanttelephonenumber')}
variant={ldapID ? "filled" : 'outlined'}
/>
<TextField
className={classes.input}
label={t("Pager")}
fullWidth
value={pagertelephonenumber || ''}
onChange={handlePropertyChange('pagertelephonenumber')}
variant={ldapID ? "filled" : 'outlined'}
/>
</Grid>
</Grid>
<Divider className={classes.divider}/>
<div className={classes.flexRow}>
<Typography variant="h6">{t('Annotation')}</Typography>
{ldapID && <Tooltip title={t("Warning") + ": " + t("Changes will be overwritten with next LDAP sync")}>
<Warning color="warning" fontSize="inherit" style={{ fontSize: 32 }}/>
</Tooltip>}
</div>
<TextField
className={classes.input}
fullWidth
value={comment || ''}
onChange={handlePropertyChange('comment')}
multiline
rows={4}
variant={ldapID ? "filled" : 'outlined'}
/>
</FormControl>
);
}
Example #17
Source File: index.js From fireact with MIT License | 4 votes |
Plans = () => {
const title = 'Select a Plan';
const countries = countryJSON.countries;
const { userData, authUser } = useContext(AuthContext);
const stripe = useStripe();
const elements = useElements();
const mountedRef = useRef(true);
const { setBreadcrumb } = useContext(BreadcrumbContext);
const CARD_ELEMENT_OPTIONS = {
style: {
base: {
color: '#32325d',
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
fontSmoothing: 'antialiased',
fontSize: '16px',
'::placeholder': {
color: '#aab7c4'
}
},
invalid: {
color: '#fa755a',
iconColor: '#fa755a'
}
},
hidePostalCode: true
};
const [loading, setLoading] = useState(true);
const [processing, setProcessing] = useState(false);
const [plans, setPlans] = useState([]);
const [selectedPlan, setSelectedPlan] = useState({id: 0});
const [cardError, setCardError] = useState(null);
const [errorMessage, setErrorMessage] = useState(null);
const [country, setCountry] = useState("");
const [countryError, setCountryError] = useState(null);
const [state, setState] = useState("");
const [states, setStates] = useState([]);
const [stateError, setStateError] = useState(null);
useEffect(() => {
setBreadcrumb([
{
to: "/",
text: "Home",
active: false
},
{
to: "/account/"+userData.currentAccount.id+"/",
text: userData.currentAccount.name,
active: false
},
{
to: null,
text: title,
active: true
}
]);
setLoading(true);
const plansQuery = FirebaseAuth.firestore().collection('plans').orderBy('price', 'asc');
plansQuery.get().then(planSnapShots => {
if (!mountedRef.current) return null
let p = [];
planSnapShots.forEach(doc => {
p.push({
'id': doc.id,
'name': doc.data().name,
'price': doc.data().price,
'currency': doc.data().currency,
'paymentCycle': doc.data().paymentCycle,
'features': doc.data().features,
'stripePriceId': doc.data().stripePriceId,
'current': (userData.currentAccount.planId===doc.id)?true:false
});
});
if(p.length > 0){
const ascendingOrderPlans = p.sort((a, b) => parseFloat(a.price) - parseFloat(b.price));
setPlans(ascendingOrderPlans);
}
setLoading(false);
});
},[userData, setBreadcrumb, title]);
useEffect(() => {
return () => {
mountedRef.current = false
}
},[]);
const subscribe = async(event) => {
event.preventDefault();
setProcessing(true);
setErrorMessage(null);
let hasError = false;
let paymentMethodId = '';
if(selectedPlan.price !== 0){
if(country === ''){
setCountryError('Please select a country.');
hasError = true;
}
if(state === '' && countries[country] && countries[country].states){
setStateError('Please select a state.');
hasError = true;
}
setCardError(null);
if (!stripe || !elements) {
// Stripe.js has not loaded yet. Make sure to disable
// form submission until Stripe.js has loaded.
return;
}
// Get a reference to a mounted CardElement. Elements knows how
// to find your CardElement because there can only ever be one of
// each type of element.
const cardElement = elements.getElement(CardElement);
// Use your card Element with other Stripe.js APIs
const {error, paymentMethod} = await stripe.createPaymentMethod({
type: 'card',
card: cardElement
});
if (error) {
setCardError(error.message);
hasError = true;
} else {
paymentMethodId = paymentMethod.id;
}
}
if(!hasError){
const createSubscription = CloudFunctions.httpsCallable('createSubscription');
createSubscription({
planId: selectedPlan.id,
accountId: userData.currentAccount.id,
paymentMethodId: paymentMethodId,
billing: {
country: country,
state: state
}
}).then(res => {
// physical page load to reload the account data
if (!mountedRef.current) return null
document.location = '/account/'+userData.currentAccount.id+'/';
}).catch(err => {
if (!mountedRef.current) return null
setProcessing(false);
setErrorMessage(err.message);
});
}else{
setProcessing(false);
}
}
return (
<>
{(!loading)?(
<>{(userData.currentAccount.owner === authUser.user.uid)?(
<>{plans.length > 0 ? (
<Paper>
<Box p={3} style={{textAlign: 'center'}} >
<h2>{title}</h2>
<Grid container spacing={3}>
<>
{plans.map((plan,i) =>
<Grid container item xs={12} md={4} key={i} >
<Card style={{
width: '100%',
display: 'flex',
flexDirection: 'column',
paddingBottom: '20px',
}}>
<CardHeader title={plan.name} subheader={"$"+plan.price+"/"+plan.paymentCycle} />
<CardContent>
<Divider />
<ul style={{listStyleType: 'none', paddingLeft: '0px'}}>
{plan.features.map((feature, i) =>
<li key={i}>
<i className="fa fa-check" style={{color: "#2e7d32"}} /> {feature}
</li>
)}
</ul>
</CardContent>
<CardActions style={{
marginTop: 'auto',
justifyContent: 'center',
}}>
{plan.current?(
<Button color="success" variant="contained" disabled={true}>Current Plan</Button>
):(
<Button color="success" variant={(plan.id!==selectedPlan.id)?"outlined":"contained"} onClick={() => {
for(let i=0; i<plans.length; i++){
if(plans[i].id === plan.id){
setSelectedPlan(plan);
}
}
}}>{plan.id===selectedPlan.id && <><i className="fa fa-check" /> </>}{(plan.id!==selectedPlan.id)?"Select":"Selected"}</Button>
)}
</CardActions>
</Card>
</Grid>
)}
</>
</Grid>
{selectedPlan.id !== 0 && selectedPlan.price > 0 &&
<div style={{justifyContent: 'center', marginTop: '50px'}}>
<h2>Billing Details</h2>
<Grid container spacing={3}>
<Grid container item xs={12}>
<Card style={{
width: '100%',
paddingBottom: '20px',
}}>
<CardContent>
<Container maxWidth="sm">
<Stack spacing={3}>
{countryError !== null &&
<Alert severity="error" onClose={() => setCountryError(null)}>{countryError}</Alert>
}
<Autocomplete
value={(country !== '')?(countries.find(obj =>{
return obj.code === country
})):(null)}
options={countries}
autoHighlight
getOptionLabel={(option) => option.label}
renderOption={(props, option) => (
<Box component="li" sx={{ '& > img': { mr: 2, flexShrink: 0 } }} {...props}>
<img
loading="lazy"
width="20"
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
srcSet={`https://flagcdn.com/w40/${option.code.toLowerCase()}.png 2x`}
alt=""
/>
{option.label}
</Box>
)}
renderInput={(params) => (
<TextField
{...params}
label="Country"
inputProps={{
...params.inputProps,
autoComplete: 'new-password',
}}
/>
)}
onChange={(event, newValue) => {
if(newValue && newValue.code){
setCountry(newValue.code);
setState("");
if(newValue.states){
setStates(newValue.states);
}else{
setStates([]);
}
setCountryError(null);
}
}}
/>
{states.length > 0 &&
<>
{stateError !== null &&
<Alert severity="error" onClose={() => setStateError(null)}>{stateError}</Alert>
}
<Autocomplete
value={(state !== '')?(states.find(obj =>{
return obj.code === state
})):(null)}
options={states}
autoHighlight
getOptionLabel={(option) => option.label}
renderOption={(props, option) => (
<Box component="li" {...props}>
{option.label}
</Box>
)}
renderInput={(params) => (
<TextField
{...params}
label="State"
inputProps={{
...params.inputProps,
autoComplete: 'new-password',
}}
/>
)}
onChange={(event, newValue) => {
if(newValue && newValue.code){
setState(newValue.code);
setStateError(null);
}
}}
/>
</>
}
{cardError !== null &&
<Alert severity="error" onClose={() => setCardError(null)}>{cardError}</Alert>
}
<div style={{position: "relative", minHeight: '56px', padding: '15px'}}>
<CardElement options={CARD_ELEMENT_OPTIONS}></CardElement>
<fieldset style={{
borderColor: 'rgba(0, 0, 0, 0.23)',
borderStyle: 'solid',
borderWidth: '1px',
borderRadius: '4px',
position: 'absolute',
top: '-5px',
left: '0',
right: '0',
bottom: '0',
margin: '0',
padding: '0 8px',
overflow: 'hidden',
pointerEvents: 'none'
}}></fieldset>
</div>
</Stack>
</Container>
</CardContent>
</Card>
</Grid>
</Grid>
</div>
}
{selectedPlan.id!==0 &&
<div style={{marginTop: '50px'}}>
<Container maxWidth="sm">
<Stack spacing={3}>
{errorMessage !== null &&
<Alert severity="error" onClose={() => setErrorMessage(null)}>{errorMessage}</Alert>
}
<Button color="success" size="large" variant="contained" disabled={selectedPlan.id===0||processing?true:false} onClick={e => {
subscribe(e);
}}>{processing?(<><Loader /> Processing...</>):(<>Subscribe Now</>)}</Button>
</Stack>
</Container>
</div>
}
</Box>
</Paper>
):(
<Alert severity="warning">No plan is found.</Alert>
)}</>
):(
<Alert severity="error" >Access Denied.</Alert>
)}</>
):(
<Loader text="loading plans..." />
)}
</>
)
}
Example #18
Source File: User.js From admin-web with GNU Affero General Public License v3.0 | 4 votes |
render() {
const { classes, t, user, handlePropertyChange } = this.props;
const { properties, ldapID } = user;
const { title, displayname, nickname, primarytelephonenumber, streetaddress,
departmentname, companyname, officelocation, givenname, surname, initials,
assistant, country, locality, stateorprovince, postalcode } = properties;
return (
<FormControl className={classes.form}>
<div className={classes.flexRow}>
<Typography variant="h6">{t('Name')}</Typography>
{ldapID && <Tooltip title={t("Warning") + ": " + t("Changes will be overwritten with next LDAP sync")}>
<Warning color="warning" fontSize="inherit" style={{ fontSize: 32 }}/>
</Tooltip>}
</div>
<Grid container>
<Grid item xs={12} className={classes.gridItem}>
<div className={classes.grid}>
<TextField
className={classes.flexTextfield}
label={t("First name")}
value={givenname || ''}
onChange={handlePropertyChange('givenname')}
variant={ldapID ? "filled" : 'outlined'}
/>
<TextField
//className={classes.flexTextfield}
label={t("Initials")}
value={initials || ''}
onChange={handlePropertyChange('initials')}
variant={ldapID ? "filled" : 'outlined'}
/>
</div>
<TextField
className={classes.propertyInput}
label={t("Surname")}
fullWidth
value={surname || ''}
onChange={handlePropertyChange('surname')}
variant={ldapID ? "filled" : 'outlined'}
/>
</Grid>
<Grid item xs={12} className={classes.gridItem}>
<TextField
className={classes.propertyInput}
label={t("Display name")}
fullWidth
value={displayname || ''}
onChange={handlePropertyChange('displayname')}
variant={ldapID ? "filled" : 'outlined'}
/>
<TextField
className={classes.propertyInput}
label={t("Nickname")}
fullWidth
value={nickname || ''}
onChange={handlePropertyChange('nickname')}
variant={ldapID ? "filled" : 'outlined'}
/>
</Grid>
</Grid>
<Divider className={classes.divider} />
<Grid container>
<Grid item xs={6} style={{ display: 'flex' }}>
<TextField
className={classes.address}
label={t("Address")}
value={streetaddress || ''}
onChange={handlePropertyChange('streetaddress')}
multiline
rows={3}
variant={ldapID ? "filled" : 'outlined'}
inputProps={{
style: {
height: 95,
},
}}
/>
</Grid>
<Grid item xs={6} style={{ paddingRight: 16 }}>
<TextField
className={classes.input}
label={t("Position")}
fullWidth
value={title || ''}
onChange={handlePropertyChange('title')}
variant={ldapID ? "filled" : 'outlined'}
/>
<TextField
className={classes.input}
label={t("Company")}
fullWidth
value={companyname || ''}
onChange={handlePropertyChange('companyname')}
variant={ldapID ? "filled" : 'outlined'}
/>
</Grid>
</Grid>
<Grid container>
<Grid item xs={12} className={classes.gridItem}>
<TextField
className={classes.propertyInput}
label={t("Locality")}
fullWidth
value={locality || ''}
onChange={handlePropertyChange('locality')}
variant={ldapID ? "filled" : 'outlined'}
/>
<TextField
className={classes.propertyInput}
label={t("Department")}
fullWidth
value={departmentname || ''}
onChange={handlePropertyChange('departmentname')}
variant={ldapID ? "filled" : 'outlined'}
/>
</Grid>
<Grid item xs={12} className={classes.gridItem}>
<TextField
className={classes.propertyInput}
label={t("State")}
fullWidth
value={stateorprovince || ''}
onChange={handlePropertyChange('stateorprovince')}
variant={ldapID ? "filled" : 'outlined'}
/>
<TextField
className={classes.propertyInput}
label={t("Office")}
fullWidth
value={officelocation || ''}
onChange={handlePropertyChange('officelocation')}
variant={ldapID ? "filled" : 'outlined'}
/>
</Grid>
<Grid item xs={12} className={classes.gridItem}>
<TextField
className={classes.propertyInput}
label={t("Postal Code")}
fullWidth
value={postalcode || ''}
onChange={handlePropertyChange('postalcode')}
variant={ldapID ? "filled" : 'outlined'}
/>
<TextField
className={classes.propertyInput}
label={t("Assistant")}
fullWidth
value={assistant || ''}
onChange={handlePropertyChange('assistant')}
variant={ldapID ? "filled" : 'outlined'}
/>
</Grid>
<Grid item xs={12} className={classes.gridItem}>
<FormControl className={classes.countrySelect}>
<InputLabel variant="standard">{t("Country")}</InputLabel>
<NativeSelect
value={country || "Germany"}
onChange={handlePropertyChange('country')}
fullWidth
>
{world.map(country =>
<option key={country.id} value={country.name}>
{country.name}
</option>
)}
</NativeSelect>
</FormControl>
<TextField
className={classes.propertyInput}
label={t("Telephone")}
fullWidth
value={primarytelephonenumber || ''}
onChange={handlePropertyChange('primarytelephonenumber')}
variant={ldapID ? "filled" : 'outlined'}
/>
</Grid>
</Grid>
</FormControl>
);
}
Example #19
Source File: index.js From fireact with MIT License | 4 votes |
UserProfileView = () => {
const history = useHistory();
return (
<AuthContext.Consumer>
{(context) => (
<List component="nav">
<ListItem>
<Grid container spacing={1}>
<Grid container item xs={12} md={4}>
<Box p={2}><strong>AVATAR</strong><br /><Typography color="textSecondary">Update via social login</Typography></Box>
</Grid>
<Grid container item xs={12} md={4}>
<Box p={2}></Box>
</Grid>
<Grid container item xs={12} md={4}>
<Box p={2} style={{marginLeft: "auto", marginRight: "0px",}}>
<Avatar alt={context.authUser.user.displayName} src={context.authUser.user.photoURL} style={{height:'64px',width:'64px'}} />
</Box>
</Grid>
</Grid>
</ListItem>
<Divider />
<ListItem button onClick={() => {
history.push('/user/profile/update-name');
}}>
<Grid container spacing={1}>
<Grid container item xs={12} md={4}>
<Box p={2}><strong>NAME</strong></Box>
</Grid>
<Grid container item xs={12} md={4}>
<Box p={2}>{context.authUser.user.displayName}</Box>
</Grid>
<Grid container item xs={12} md={4}>
<Box p={2} style={{marginLeft: "auto", marginRight: "0px",}}>
<EditIcon />
</Box>
</Grid>
</Grid>
</ListItem>
<Divider />
<ListItem button onClick={() => {
history.push('/user/profile/update-email');
}}>
<Grid container spacing={1}>
<Grid container item xs={12} md={4}>
<Box p={2}><strong>EMAIL</strong></Box>
</Grid>
<Grid container item xs={12} md={4}>
<Box p={2}>{context.authUser.user.email}</Box>
</Grid>
<Grid container item xs={12} md={4}>
<Box p={2} style={{marginLeft: "auto", marginRight: "0px",}}>
<EditIcon />
</Box>
</Grid>
</Grid>
</ListItem>
<Divider />
<ListItem button={!context.authUser.user.emailVerified} onClick={() => {
if(!context.authUser.user.emailVerified)history.push('/user/profile/verify-email');
}}>
<Grid container spacing={1}>
<Grid container item xs={12} md={4}>
<Box p={2}><strong>EMAIL VERIFIED</strong></Box>
</Grid>
<Grid container item xs={12} md={4}>
<Box p={2}>{(context.authUser.user.emailVerified?" Verified":"Unverified email")}</Box>
</Grid>
<Grid container item xs={12} md={4}>
<Box p={2} style={{marginLeft: "auto", marginRight: "0px",}}>
{context.authUser.user.emailVerified?(<VerifiedUserIcon />):(<SendIcon />)}
</Box>
</Grid>
</Grid>
</ListItem>
<Divider />
<ListItem button onClick={() => {
history.push('/user/profile/update-phone');
}}>
<Grid container spacing={1}>
<Grid container item xs={12} md={4}>
<Box p={2}><strong>PHONE</strong></Box>
</Grid>
<Grid container item xs={12} md={4}>
<Box p={2}>{context.authUser.user.phoneNumber}</Box>
</Grid>
<Grid container item xs={12} md={4}>
<Box p={2} style={{marginLeft: "auto", marginRight: "0px",}}>
<EditIcon />
</Box>
</Grid>
</Grid>
</ListItem>
<Divider />
<ListItem button onClick={() => {
history.push('/user/profile/update-password');
}}>
<Grid container spacing={1}>
<Grid container item xs={12} md={4}>
<Box p={2}><strong>PASSWORD</strong></Box>
</Grid>
<Grid container item xs={12} md={4}>
<Box p={2}>••••••••</Box>
</Grid>
<Grid container item xs={12} md={4}>
<Box p={2} style={{marginLeft: "auto", marginRight: "0px",}}>
<EditIcon />
</Box>
</Grid>
</Grid>
</ListItem>
<Divider />
<ListItem button onClick={() => {
history.push('/user/profile/delete');
}}>
<Grid container spacing={1}>
<Grid container item xs={12} md={4}>
<Box p={2}><Typography color="error"><strong>DELETE ACCOUNT</strong></Typography></Box>
</Grid>
</Grid>
</ListItem>
</List>
)}
</AuthContext.Consumer>
)
}
Example #20
Source File: TaskDetails.js From admin-web with GNU Affero General Public License v3.0 | 4 votes |
render() {
const { classes, t } = this.props;
const { snackbar, ID, command, state, created, updated, message, params } = this.state;
return (
<ViewWrapper
topbarTitle={t('Task queue')}
snackbar={snackbar}
onSnackbarClose={() => this.setState({ snackbar: '' })}
>
<Paper className={classes.paper} elevation={1}>
<Grid container direction="column" className={classes.container}>
<Typography variant="h6" className={classes.data}>
<span className={classes.description}>{t('Task ID')}:</span>
{ID || t('Unknown')}
</Typography>
<Typography variant="h6" className={classes.data}>
<span className={classes.description}>{t('Command')}:</span>
{command || t('Unknown')}
</Typography>
<Typography variant="h6" className={classes.data}>
<span className={classes.description}>{t('State')}:</span>
{this.getTaskState(state) || t('Unknown')}
</Typography>
<Typography variant="h6" className={classes.data}>
<span className={classes.description}>{t('Message')}:</span>
{message || t('Unknown')}
</Typography>
<Typography variant="h6" className={classes.data}>
<span className={classes.description}>{t('Created')}:</span>
{setDateTimeString(created) || t('Unknown')}
</Typography>
<Typography variant="h6" className={classes.data}>
<span className={classes.description}>{t('Updated')}:</span>
{setDateTimeString(updated) || t('Unknown')}
</Typography>
<Divider />
<Typography variant="h6" className={classes.params}>
{t('Params')}
</Typography>
{Object.entries(params).map(([param, value], key) => {
const displayValue = JSON.stringify(value);
return param !== 'result' ? <Typography className={classes.param} key={key}>
<span className={classes.description}>{param}:</span>
{displayValue || t('Unknown')}
</Typography> :
<div className={classes.flexRow} key={key}>
<div className={classes.description}>{param}</div>
<div>
{(value || []).map(({username, code, message}, idx) =>
<Tooltip key={idx} placement='right' title={message || ''}>
<Typography className={classes.resultParam}>
<span
style={{
marginRight: 8,
backgroundColor: code - 300 < 0 /* code 2xx */ ? green['500'] : red['500'],
borderRadius: 4,
padding: '2px 4px',
}}
>
{code}
</span>
{username}
</Typography>
</Tooltip>
)}
</div>
</div>;
})}
</Grid>
<Button
color="secondary"
onClick={this.handleNavigation('taskq')}
>
{t('Back')}
</Button>
</Paper>
<Feedback
snackbar={snackbar}
onClose={() => this.setState({ snackbar: '' })}
/>
</ViewWrapper>
);
}
Example #21
Source File: Chatbox.jsx From matx-react with MIT License | 4 votes |
Chatbox = ({ togglePopup }) => {
const [isAlive, setIsAlive] = useState(true);
const [message, setMessage] = useState('');
const [messageList, setMessageList] = useState([]);
const currentUserId = '7863a6802ez0e277a0f98534';
const chatBottomRef = document.querySelector('#chat-scroll');
const sendMessageOnEnter = (event) => {
if (event.key === 'Enter' && !event.shiftKey) {
let tempMessage = message.trim();
if (tempMessage !== '') {
let tempList = [...messageList];
let messageObject = {
text: tempMessage,
contactId: currentUserId,
};
tempList.push(messageObject);
globalMessageList.push(messageObject);
if (isAlive) setMessageList(tempList);
dummyReply();
}
setMessage('');
}
};
const dummyReply = async () => {
setTimeout(() => {
let tempList = [...messageList];
let messageObject = {
text: 'Good to hear from you. enjoy!!!',
contactId: 'opponents contact id',
avatar: '/assets/images/faces/13.jpg',
name: 'Frank Powell',
};
tempList.push(messageObject);
globalMessageList.push(messageObject);
if (isAlive) setMessageList(globalMessageList);
}, 2000);
};
const scrollToBottom = useCallback(() => {
if (chatBottomRef) {
chatBottomRef.scrollTo({
top: chatBottomRef.scrollHeight,
behavior: 'smooth',
});
}
}, [chatBottomRef]);
useEffect(() => {
if (isAlive) {
setMessageList([
{
contactId: '323sa680b3249760ea21rt47',
text: 'Do you ever find yourself falling into the “discount trap?”',
time: '2018-02-10T08:45:28.291Z',
id: '323sa680b3249760ea21rt47',
name: 'Frank Powell',
avatar: '/assets/images/faces/13.jpg',
status: 'online',
mood: '',
},
{
contactId: '7863a6802ez0e277a0f98534',
text: 'Giving away your knowledge or product just to gain clients?',
time: '2018-02-10T08:45:28.291Z',
id: '7863a6802ez0e277a0f98534',
name: 'John Doe',
avatar: '/assets/images/face-1.jpg',
status: 'online',
mood: '',
},
{
contactId: '323sa680b3249760ea21rt47',
text: 'Yes',
time: '2018-02-10T08:45:28.291Z',
id: '323sa680b3249760ea21rt47',
name: 'Frank Powell',
avatar: '/assets/images/faces/13.jpg',
status: 'online',
mood: '',
},
{
contactId: '7863a6802ez0e277a0f98534',
text: 'Don’t feel bad. It happens to a lot of us',
time: '2018-02-10T08:45:28.291Z',
id: '7863a6802ez0e277a0f98534',
name: 'John Doe',
avatar: '/assets/images/face-1.jpg',
status: 'online',
mood: '',
},
{
contactId: '323sa680b3249760ea21rt47',
text: 'Do you ever find yourself falling into the “discount trap?”',
time: '2018-02-10T08:45:28.291Z',
id: '323sa680b3249760ea21rt47',
name: 'Frank Powell',
avatar: '/assets/images/faces/13.jpg',
status: 'online',
mood: '',
},
{
contactId: '7863a6802ez0e277a0f98534',
text: 'Giving away your knowledge or product just to gain clients?',
time: '2018-02-10T08:45:28.291Z',
id: '7863a6802ez0e277a0f98534',
name: 'John Doe',
avatar: '/assets/images/face-1.jpg',
status: 'online',
mood: '',
},
{
contactId: '323sa680b3249760ea21rt47',
text: 'Yes',
time: '2018-02-10T08:45:28.291Z',
id: '323sa680b3249760ea21rt47',
name: 'Frank Powell',
avatar: '/assets/images/faces/13.jpg',
status: 'online',
mood: '',
},
{
contactId: '7863a6802ez0e277a0f98534',
text: 'Don’t feel bad. It happens to a lot of us',
time: '2018-02-10T08:45:28.291Z',
id: '7863a6802ez0e277a0f98534',
name: 'John Doe',
avatar: '/assets/images/face-1.jpg',
status: 'online',
mood: '',
},
]);
}
// getChatRoomByContactId(currentUserId, "323sa680b3249760ea21rt47").then(
// ({ data }) => {
// if (isAlive) {
// setMessageList(data?.messageList);
// }
// }
// );
}, [isAlive]);
useEffect(() => {
scrollToBottom();
return () => setIsAlive(false);
}, [messageList, scrollToBottom]);
const { palette } = useTheme();
const primary = palette.primary.main;
const textPrimary = palette.text.primary;
return (
<ChatContainer>
<ProfileBox>
<Box display="flex" alignItems="center">
<ChatAvatar src="/assets/images/face-2.jpg" status="online" />
<ChatStatus>
<H5>Ryan Todd</H5>
<Span>Active</Span>
</ChatStatus>
</Box>
<IconButton onClick={togglePopup}>
<Icon fontSize="small">clear</Icon>
</IconButton>
</ProfileBox>
<StyledScrollBar id="chat-scroll">
{messageList.map((item, ind) => (
<Box
key={ind}
p="20px"
display="flex"
sx={{
justifyContent: currentUserId === item.contactId && 'flex-end',
}}
>
{currentUserId !== item.contactId && <Avatar src={item.avatar} />}
<Box ml="12px">
{currentUserId !== item.contactId && (
<H5
sx={{
mb: '4px',
fontSize: '14px',
color: primary,
}}
>
{item.name}
</H5>
)}
<ChatMessage>{item.text}</ChatMessage>
<MessageTime>1 minute ago</MessageTime>
</Box>
</Box>
))}
{/* example of image sent by current user*/}
<ChatImgContainer>
<Box ml="12px">
<ChatImgBox>
<ChatImg alt="laptop" src="/assets/images/laptop-1.png" />
<Box ml="12px">
<H6 sx={{ mt: 0, mb: '4px' }}>Asus K555LA.png</H6>
<ChatImgSize>21.5KB</ChatImgSize>
</Box>
</ChatImgBox>
<MessageTime>1 minute ago</MessageTime>
</Box>
</ChatImgContainer>
</StyledScrollBar>
<div>
<Divider
sx={{
background: `rgba(${convertHexToRGB(textPrimary)}, 0.15)`,
}}
/>
<TextField
placeholder="Type here ..."
multiline
rowsMax={4}
fullWidth
sx={{ '& textarea': { color: primary } }}
InputProps={{
endAdornment: (
<Box display="flex">
<IconButton size="small">
<Icon>tag_faces</Icon>
</IconButton>
<IconButton size="small">
<Icon>attachment</Icon>
</IconButton>
</Box>
),
classes: { root: 'pl-5 pr-3 py-3 text-body' },
}}
value={message}
onChange={(e) => setMessage(e.target.value)}
onKeyUp={sendMessageOnEnter}
/>
</div>
</ChatContainer>
);
}
Example #22
Source File: Layout.jsx From CRM with Apache License 2.0 | 2 votes |
Layout = (props) => {
const { window } = props;
const [mobileOpen, setMobileOpen] = React.useState(false);
const handleDrawerToggle = () => {
setMobileOpen(!mobileOpen);
};
const sidebarContents = [
{
title: "Contacts",
link: "/admin_dashboard/contacts",
icon: <Phone strokeWidth={1} />,
},
{
title: "Tickets",
link: "/admin_dashboard/tickets",
icon: <Package strokeWidth={1} />,
},
{
title: "Todos",
link: "/admin_dashboard/todos",
icon: <FileText strokeWidth={1} />,
},
{
title: "Email",
link: "/admin_dashboard/emails",
icon: <Inbox strokeWidth={1} />,
},
{
title: "CDA",
link: "/admin_dashboard/cda",
icon: <Book strokeWidth={1} />,
},
];
const drawer = (
<div>
<Toolbar />
<Divider />
<List>
{sidebarContents.map((item, index) => (
<ListItem button key={index} component={NavLink} to={item.link}>
<ListItemIcon>{item.icon}</ListItemIcon>
<ListItemText primary={item.title} />
</ListItem>
))}
</List>
<Divider />
</div>
);
const container =
window !== undefined ? () => window().document.body : undefined;
const [anchorEl, setAnchorEl] = React.useState(null);
const open = Boolean(anchorEl);
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
const renderMenu = (
<Menu
id="long-menu"
MenuListProps={{
"aria-labelledby": "long-button",
}}
anchorEl={anchorEl}
open={open}
onClose={handleClose}
>
<MenuItem onClick={handleClose}>
<ListItemIcon>
<User width="18px" strokeWidth={1.5} />
</ListItemIcon>
<Typography variant="inherit">Profile</Typography>
</MenuItem>
<MenuItem onClick={handleClose}>
<ListItemIcon>
<LogOut width="18px" strokeWidth={1.5} />
</ListItemIcon>
<Typography variant="inherit">Logout</Typography>
</MenuItem>
</Menu>
);
return (
<section className="wrapper">
<Box sx={{ display: "flex" }}>
<CssBaseline />
<AppBar
position="fixed"
sx={{
// width: { sm: `calc(100% - ${drawerWidth}px)` },
// ml: { sm: `${drawerWidth}px` },
backgroundColor: "#1e1e2f",
backgroundImage: "none",
boxShadow: "none",
borderTop: "2px solid #1d8cf8",
}}
>
<Toolbar>
<IconButton
color="inherit"
aria-label="open drawer"
edge="start"
onClick={handleDrawerToggle}
sx={{ mr: 2, display: { sm: "none" } }}
>
<MenuIcon />
</IconButton>
<Typography variant="h6" noWrap component="div">
Easy CRM
</Typography>
<Box sx={{ flexGrow: 1 }} />
<IconButton
color="inherit"
aria-label="more"
id="long-button"
aria-controls={open ? "long-menu" : undefined}
aria-expanded={open ? "true" : undefined}
aria-haspopup="true"
onClick={handleClick}
>
<MoreVertical />
</IconButton>
{renderMenu}
</Toolbar>
</AppBar>
<Box
component="nav"
sx={{ width: { sm: drawerWidth }, flexShrink: { sm: 0 } }}
aria-label="sidebar"
className="sidebar"
>
{/* The implementation can be swapped with js to avoid SEO duplication of links. */}
<Drawer
container={container}
variant="temporary"
open={mobileOpen}
onClose={handleDrawerToggle}
ModalProps={{
keepMounted: true, // Better open performance on mobile.
}}
sx={{
display: { xs: "block", sm: "none" },
"& .MuiDrawer-paper": {
boxSizing: "border-box",
width: 230,
border: "none",
// backgroundColor: "transparent",
background: "linear-gradient(0deg, #3358f4, #1d8cf8)",
position: "relative",
},
}}
>
{drawer}
</Drawer>
<Drawer
variant="permanent"
sx={{
display: { xs: "none", sm: "block" },
"& .MuiDrawer-paper": {
boxSizing: "border-box",
width: 230,
border: "none",
backgroundColor: "transparent",
position: "relative",
},
}}
open
>
{drawer}
</Drawer>
</Box>
<Box
component="main"
sx={{
flexGrow: 1,
p: 3,
width: { sm: `calc(100% - ${drawerWidth}px)` },
overflowY: "scroll",
// height: "100vh - 64px",
}}
className="main-panel"
>
<Toolbar />
<Outlet />
</Box>
</Box>
</section>
);
}