@material-ui/core#List JavaScript Examples
The following examples show how to use
@material-ui/core#List.
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: CreatePost.js From social-media-strategy-fe with MIT License | 6 votes |
CreatePost = () => {
const [isOpen, setIsOpen] = useState(false);
const handleOpen = () => {
setIsOpen(true);
};
const handleClose = () => {
setIsOpen(false);
};
return (
<>
<List>
<ListItem button onClick={handleOpen}>
<ListItemIcon>
<AddCircleIcon color="primary" />
</ListItemIcon>
<ListItemText primary="Add post" />
</ListItem>
</List>
<CreatePostModal open={isOpen} handleClose={handleClose} />
</>
);
}
Example #2
Source File: NavSection.js From course-manager with MIT License | 6 votes |
export default function NavSection({ navConfig, ...other }) {
const { pathname } = useLocation();
const match = (path) => (path ? !!matchPath({ path, end: false }, pathname) : false);
return (
<Box {...other}>
<List disablePadding>
{navConfig.map((item) => (
<NavItem key={item.title} item={item} active={match} />
))}
</List>
</Box>
);
}
Example #3
Source File: Navbar.js From wiki with GNU General Public License v3.0 | 6 votes |
export default function SimpleAccordion() {
const classes = useStyles();
return (
<div className={classes.root}>
<Accordion>
<AccordionSummary
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1a-content"
id="panel1a-header"
>
<Typography className={classes.heading}>Accordion 1</Typography>
</AccordionSummary>
<AccordionDetails>
<List>
<ListItem button key={1}>
<ListItemIcon>
<NotificationsActiveIcon />
</ListItemIcon>
<ListItemText primary="Hello" />
</ListItem>
</List>
</AccordionDetails>
</Accordion>
</div>
);
}
Example #4
Source File: SidebarNav.js From telar-cli with MIT License | 6 votes |
SidebarNav = props => {
const { pages, className, ...rest } = props;
const classes = useStyles();
return (
<List
{...rest}
className={clsx(classes.root, className)}
>
{pages.map(page => (
<ListItem
className={classes.item}
disableGutters
key={page.title}
>
<Button
activeClassName={classes.active}
className={classes.button}
component={CustomRouterLink}
to={page.href}
>
<div className={classes.icon}>{page.icon}</div>
{page.title}
</Button>
</ListItem>
))}
</List>
);
}
Example #5
Source File: leaderboard.js From dscbppimt-official-website with MIT License | 6 votes |
Leaderboard = () => {
return(
<Layout>
<Container>
<Typography variant="h4" style={{marginTop: '2em'}}>Challenges</Typography>
<Grid container style={{ margin : '1em 0' }} justifyContent="center" alignContent="stretch">
<Grid item>
<ChallengeCard />
</Grid>
<Grid item>
<ChallengeCard />
</Grid>
<Grid item>
<ChallengeCard />
</Grid>
</Grid>
<Typography variant="h4" style={{marginTop: '2em'}}>Leaderboard</Typography>
<List>
<RankCard></RankCard>
<ListItem>Second</ListItem>
</List>
</Container>
</Layout>
)
}
Example #6
Source File: SideBar.js From surveillance-forms with MIT License | 6 votes |
SideBarCard = ({ user, onLanguageSelect, lang, langCode }) => {
const classes = useStyles();
//TODO: this could be done better
const fields = {
label: lang.t("note.lable"),
notes: [
lang.t("note.note1"),
lang.t("note.note2"),
lang.t("note.note3"),
lang.t("note.note4"),
],
};
return (
<Card className={classes.card}>
<CardContent>
<Typography variant="h6" component="h2">
{fields.label}
</Typography>
<List>
{fields.notes.map((el, index) => {
return (
<ListItem key={index} disableGutters>
<ListItemAvatar style={{ flexShrink: 1 }}>
<Avatar style={{ background: '#fff', margin: 0 }}>
<CheckIcon style={{ fill: 'green', width: 20 }}/>
</Avatar>
</ListItemAvatar>
<ListItemText className="sidebarText">{el}</ListItemText>
</ListItem>
);
})}
</List>
</CardContent>
</Card>
);
}
Example #7
Source File: LanguageSelector.js From covid-trials-dashboard with MIT License | 6 votes |
LanguageSelector = ({ languages, onSelect }) => {
const { t } = useTranslation('languages')
const [open, setOpen] = useState(false)
const classes = useStyles()
console.log({ languages })
return (
<>
<ListItem button onClick={() => setOpen(!open)}>
<ListItemIcon>
<LanguageOutlined />
</ListItemIcon>
<ListItemText primary={t('selectorTitle')} />
{open ? <ExpandLess /> : <ExpandMore />}
</ListItem>
<Collapse in={open} timeout={300} unmountOnExit>
<List component='div' disablePadding>
{languages.map(lan => (
<ListItem
key={lan}
button
className={classes.nested}
onClick={() => onSelect(lan)}
>
<ListItemText primary={t(lan)} />
</ListItem>
))}
</List>
</Collapse>
</>
)
}
Example #8
Source File: AlertBox.js From Edlib with GNU General Public License v3.0 | 6 votes |
AlertBox = () => {
const {
state: {
messages = [],
messageTitle,
},
dispatch,
} = useForm();
if (!messages || messages.length === 0) {
return null;
}
return (
<div className="editorAlertBox">
<Alert
color="danger"
onClose={() => dispatch({ type: FormActions.resetError })}
elevation={2}
>
<div className="editorAlertBoxHeader">
<WarningIcon />
<strong>{messageTitle}</strong>
</div>
<List>
{messages.map((message, index) => (
<ListItemText
primaryTypographyProps={{ style: { fontSize: '1.4rem' } }}
key={message + index}
>
{message}
</ListItemText>))}
</List>
</Alert>
</div>
);
}
Example #9
Source File: StopDialog.js From hk-independent-bus-eta with GNU General Public License v3.0 | 6 votes |
StopDialog = ({open, stops, handleClose}) => {
const { routeList, stopList } = useContext ( AppContext )
const { i18n } = useTranslation()
const [ routes, setRoutes ] = useState([])
const classes = useStyles()
useEffect(() => {
if (stops === undefined) {
setRoutes([])
return
}
let _routes = [];
Object.entries(routeList).forEach(([key, route]) => {
stops.some( ([co, stopId]) => {
if ( route.stops[co] && route.stops[co].includes(stopId) ) {
_routes.push(key+'/'+route.stops[co].indexOf(stopId))
return true
}
return false
})
})
setRoutes(_routes)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [stops])
return (
<Dialog open={open} onClose={handleClose} className={classes.dialog}>
<DialogTitle className={classes.title}>{stopList[stops[0][1]].name[i18n.language]}</DialogTitle>
<DialogContent>
<List>
{routes.map(route => (
<SuccinctTimeReport key={route} routeId={route} />
))}
</List>
</DialogContent>
</Dialog>
)
}
Example #10
Source File: metrics.js From graphql-sample-apps with Apache License 2.0 | 6 votes |
Metrics = () => {
const {loading, error, data} = useQuery(query);
const [newMetricName, setNewMetricName] = useState("");
const [addMetric, { loading: mutationLoading }] = useMutation(addMetricMutation, {
awaitRefetchQueries: true,
refetchQueries: [{query}],
});
const metrics = data?.queryMetric || []
return <>
<Navbar title="Metrics" color="primary" />
<Content>
{loading && <Backdrop open={loading || mutationLoading} >
<CircularProgress />
</Backdrop>}
{error && <Alert severity="error">Something Went Horribly Wrong</Alert>}
<Card style={{ padding: 30 }}>
<Typography>Here are the metrics currently configured:</Typography>
<List>
{metrics.map(({ name }, index) => <ListItem item key={index} sm={12} md={6} lg={3}>
<Typography>{name}</Typography>
</ListItem>)}
</List>
<TextField
label="Add Metric"
defaultValue={newMetricName}
onChange={e => setNewMetricName(e.target.value)}
/>
<UglyButton onClick={() => addMetric({ variables: { newMetricName } })} disabled={newMetricName === ""}>
Add Metric
</UglyButton>
</Card>
</Content>
</>
}
Example #11
Source File: ToolbarExtension.js From eSim-Cloud with GNU General Public License v3.0 | 6 votes |
export function ImageExportDialog (props) {
const classes = useStyles()
const { onClose, open } = props
const handleClose = () => {
onClose('')
}
const handleListItemClick = (value) => {
onClose(value)
}
return (
<Dialog onClose={handleClose} aria-labelledby="image-export-dialog-title" open={open}>
<DialogTitle id="image-export-dialog-title">Select Image type</DialogTitle>
<List>
{ImgTypes.map((img) => (
<ListItem button onClick={() => handleListItemClick(img)} key={img}>
<ListItemAvatar>
<Avatar className={classes.avatar}>
{img.charAt(0).toUpperCase()}
</Avatar>
</ListItemAvatar>
<ListItemText primary={img} />
</ListItem>
))}
</List>
<DialogActions>
<Button onClick={handleClose} color="primary" autoFocus>
Close
</Button>
</DialogActions>
</Dialog>
)
}
Example #12
Source File: Sidebar.js From paper-and-ink with MIT License | 6 votes |
function Sidebar(props) {
const { open, variant, onClose } = props;
const classes = useStyles();
return (
<Drawer
anchor="left"
classes={{ paper: classes.drawer }}
open={open}
onClose={onClose}
variant={variant}
>
<section className={classes.root}>
<Hidden mdUp>
<IconButton className={classes.menuButton} aria-label="Menu" onClick={onClose}>
<CloseIcon />
</IconButton>
</Hidden>
<Profile className={classes.profile} />
<List component="div" disablePadding>
{pages.map(page => (
<ListItem
key={page.title}
activeClassName={classes.activeListItem}
className={classes.listItem}
component={NavLink}
to={page.href}
>
<ListItemIcon className={classes.listItemIcon}>{page.icon}</ListItemIcon>
<ListItemText classes={{ primary: classes.listItemText }} primary={page.title} />
</ListItem>
))}
</List>
</section>
</Drawer>
);
}
Example #13
Source File: Rule.js From gitlab-lint-react with BSD 3-Clause "New" or "Revised" License | 6 votes |
RuleProjects = ({ projects }) => {
if (projects.length <= 0) {
return <p>Found no projects matching the criteria.</p>;
}
return (
<React.Fragment>
<Typography variant="h6" paragraph>
These {projects.length} repositories in the gitlab trigger this rule:
</Typography>
<List>
{projects.map((row) => {
return (
<ListItem
key={row.projectId}
button
component={RouterLink}
to={`/projects/${row.projectId}`}
>
<ListItemText primary={row.pathWithNamespace} />
</ListItem>
);
})}
</List>
</React.Fragment>
);
}
Example #14
Source File: ChatList.jsx From react-03.03 with MIT License | 6 votes |
ChatList = ({ chats, createChat }) => {
const classes = useStyles();
const [name, setName, setNameState] = useInput('');
const handleAddChat = (event) => {
event.preventDefault();
createChat(name);
setNameState('');
}
return (
<List className={classes.root}>
{ chats.map(({id, name}) => {
return (
<Link key={id} to={`/chats/${id}`}>
<ListItem className={classes.listItem}>
<ListItemAvatar>
<Avatar />
</ListItemAvatar>
<ListItemText
primary={name}
/>
</ListItem>
</Link>
)
})
}
<ListItem className={classes.listItem}>
<form onSubmit={handleAddChat}>
<input type="text" placeholder="Chat name" value={name} onChange={setName} />
<button>Create chat</button>
</form>
</ListItem>
</List>
)
}
Example #15
Source File: ChatList.jsx From react-14.01 with MIT License | 6 votes |
ChatList = ({chats, addChat}) => {
const [chatName, setChatName] = useState('');
const chatsKeysArr = Object.keys(chats); //Определяю количество чатов
let id = chatsKeysArr.length + 1; //В зависимости от количества чатов присваиваю очередной порядковый номер создаваемому чату.
return (
<List className="ChatList">
<ListItem>
<AccountCircleIcon className="avatar"/>
<Link to="/profile">My Profile</Link>
</ListItem>
{chats.map(({id, name, chatNumber, unread}) =>
<ChatListElement name={name} number={chatNumber} unread={unread} key={id}
/>)}
<ListItem>
<TextField
type="text"
value={chatName}
onChange={({currentTarget: {value}}) => setChatName(value)}
/>
<Fab onClick={() => addChat(chatName, id)}>
<AddIcon/>
</Fab>
</ListItem>
</List>
);
}
Example #16
Source File: sidebar-item.js From horondi_client_fe with MIT License | 6 votes |
SideBarItem = ({ category, handlerItem, models, translationsKey, mainItemStyles }) => {
const { sort, page, countPerPage, categoryFilter, modelsFilter, defaultPage } = URL_QUERIES_NAME;
const { t } = useTranslation();
const styles = useStyles();
const [isListOpen, setIsListOpen] = useState(false);
const handleClick = () => {
setIsListOpen((prevValue) => setIsListOpen(!prevValue));
};
const countPerPageValue = ITEMS_PER_PAGE[0].value;
return (
<>
<li className={mainItemStyles}>
<ListItemText button='true' onClick={handleClick} primary={t(`${translationsKey}.name`)} />
{isListOpen ? <RemoveIcon onClick={handleClick} /> : <AddIcon onClick={handleClick} />}
</li>
<Collapse in={isListOpen} timeout='auto' unmountOnExit>
<List className={styles.list}>
{models.map((model) => (
<ListItem button className={styles.nested} key={model._id} onClick={handlerItem}>
<Link
to={`/catalog/products?${page}=${defaultPage}&${sort}=${POPULARITY}&${countPerPage}=${countPerPageValue}&${categoryFilter}=${category}&${modelsFilter}=${model._id}`}
>
<ListItemText primary={t(`${model.translationsKey}.name`)} />
</Link>
</ListItem>
))}
</List>
</Collapse>
<div className={styles.itemHighlighting} />
</>
);
}
Example #17
Source File: AppDrawer.js From module-federation-examples with MIT License | 6 votes |
function Menu() {
return (
<List>
<ListItemLink to="dashboard" icon={<DashboardIcon />} text="Dashboard" />
<ListItemLink to="orders" icon={<ShoppingCartIcon />} text="Orders" />
<ListItemLink to="profile" icon={<UserIcon />} text="Profile" />
</List>
);
}
Example #18
Source File: Footer.jsx From Personal-Website with MIT License | 6 votes |
function Footer() {
const classes = useStyles();
return (
<footer className={classes.footer}>
<List className={classes.drawerList}>
{data["drawerButtons"].map((drawerBtn, index) => (
<ListItem button key={drawerBtn.iconName} component="a" target="_blank" href={drawerBtn.link}>
{/*<svg width="27" height="25" viewBox="0 0 27 25" fill="none" xmlns="http://www.w3.org/2000/svg">*/}
{/* <path d="M22.7189 20.9902H18.77V15.2747C18.77 13.9117 18.74 12.1577 16.7122 12.1577C14.6533 12.1577 14.3389 13.6408 14.3389 15.1741V20.9902H10.39V9.23684H14.1833V10.8389H14.2344C14.7644 9.91524 16.0533 8.94024 17.9789 8.94024C21.98 8.94024 22.72 11.3726 22.72 14.5388V20.9902H22.7189ZM5.93 7.62861C4.65889 7.62861 3.63778 6.67824 3.63778 5.50926C3.63778 4.34132 4.66 3.39197 5.93 3.39197C7.19667 3.39197 8.22333 4.34132 8.22333 5.50926C8.22333 6.67824 7.19556 7.62861 5.93 7.62861ZM7.91 20.9902H3.95V9.23684H7.91V20.9902ZM24.6944 0H1.96778C0.88 0 0 0.794368 0 1.7745V22.8571C0 23.8382 0.88 24.6316 1.96778 24.6316H24.6911C25.7778 24.6316 26.6667 23.8382 26.6667 22.8571V1.7745C26.6667 0.794368 25.7778 0 24.6911 0H24.6944Z" fill="#E6F1FF"/>*/}
{/*</svg>*/}
{drawerBtn.iconName === 'instagram' ?
<InstagramIcon style={{color: "#ffffff"}} fontSize="large"/> :
<SvgIcon>
<path d={drawerBtn.svgPath} fill="#ffffff"/>
</SvgIcon>}
</ListItem>
))}
<ListItem button key={"emial"} component="a" href={`mailto:${data.email}?Subject=Hello`} target="_top">
<EmailIcon style={{color: "#ffffff"}} fontSize="large"/>
</ListItem>
</List>
<Link href="https://github.com/nimit95/Personal-Website" target="_blank"
rel="nofollow noopener noreferrer" style={{textAlign: "center"}}>
<div>Designed & Built with ❤️ by Nimit</div>
</Link>
</footer>)
}
Example #19
Source File: CollapsibleMenuItem.js From generator-webapp-rocket with MIT License | 6 votes |
CollapsibleMenuItem = ({ menu, ...rest }) => {
const [open, setOpen] = useState(false)
const toggleSubMenu = useCallback(() => setOpen(current => !current), [])
return (
<>
<MenuItem menu={menu} subMenuOpen={open} onToggleSubMenu={toggleSubMenu} {...rest} />
<Collapse in={open} timeout="auto" unmountOnExit>
<List disablePadding>
{menu?.children?.map((subMenu, key) => (
<MenuItem key={key} menu={subMenu} isSubMenuItem={true} {...rest} />
))}
</List>
</Collapse>
</>
)
}
Example #20
Source File: ConnectionsList.js From spl-token-wallet with Apache License 2.0 | 6 votes |
export default function ConnectionsList() {
const isExtensionWidth = useIsExtensionWidth();
const connectedWallets = useConnectedWallets();
return (
<Paper>
<AppBar position="static" color="default" elevation={1}>
<Toolbar>
<Typography
variant="h6"
style={{ flexGrow: 1, fontSize: isExtensionWidth && '1rem' }}
component="h2"
>
Connected Dapps
</Typography>
</Toolbar>
</AppBar>
<List disablePadding>
{Object.entries(connectedWallets).map(([origin, connectedWallet]) => (
<ConnectionsListItem
origin={origin}
connectedWallet={connectedWallet}
key={origin}
/>
))}
</List>
</Paper>
);
}
Example #21
Source File: NavMenuItem.js From DMS_React with GNU Affero General Public License v3.0 | 6 votes |
NavMenuItem = props => {
const {name, icon, link} = props;
return (
<List component="div" className='nav-menu-item'>
<NavLink className="prepend-icon nav-menu-link" to={link} data-test="linkComp">
{/* Display an icon if any */}
{!!icon && (
<i className={'zmdi zmdi-hc-fw zmdi-' + icon}/>
)}
<span className="nav-text"><IntlMessages id={name} data-test="nameComp"/></span>
</NavLink>
</List>
)
}
Example #22
Source File: SidebarView.js From react-code-splitting-2021-04-26 with MIT License | 6 votes |
SidebarView = ({ classes, theme, toggleSidebar, isSidebarOpened, isPermanent, location }) => {
return (
<Drawer
variant={isPermanent ? 'permanent' : 'temporary'}
className={classNames(classes.drawer, {
[classes.drawerOpen]: isSidebarOpened,
[classes.drawerClose]: !isSidebarOpened,
})}
classes={{
paper: classNames(classes.drawer, {
[classes.drawerOpen]: isSidebarOpened,
[classes.drawerClose]: !isSidebarOpened,
}),
}}
open={isSidebarOpened}
>
<div className={classes.mobileBackButton}>
<IconButton
onClick={toggleSidebar}
>
<ArrowBackIcon classes={{ root: classNames(classes.headerIcon, classes.headerIconCollapse) }} />
</IconButton>
</div>
<List className={classes.sidebarList}>
{structure.map(link => <SidebarLink key={link.id} location={location} isSidebarOpened={isSidebarOpened} {...link} />)}
</List>
</Drawer>
);
}
Example #23
Source File: NavList.js From A2 with GNU General Public License v3.0 | 6 votes |
export default function NavList() {
return (
<div>
<List component="nav" aria-label="main mailbox folders">
<Divider />
<ListItem button className={styles.navButton}>
<PaymentIcon className={styles.navIcon} />
<ListItemLink href="#/home/transactions" className={styles.navButton}>
<ListItemText
primary="Transactions"
className={styles.unselectedNavText}
/>
</ListItemLink>
</ListItem>
<Divider />
<ListItem button>
<PeopleOutlineIcon className={styles.navIcon} />
<ListItemLink href="#/home/split">
<ListItemText
primary="Split a Bill"
className={styles.unselectedNavText}
/>
</ListItemLink>
</ListItem>
<Divider />
</List>
</div>
);
}
Example #24
Source File: CategoryMenus.js From youtube-clone with MIT License | 6 votes |
SideCategoryMenu = () => {
const classes = useStyles();
return (
<List>
<ListItem>
<ListItemText
primary="BEST OF YOUTUBE"
classes={{ primary: classes.title }}
/>
</ListItem>
{categoryIcons.map((item, index) => {
return (
<NavItem
key={index}
to={`/trending?category=${index}`}
title={item.title}
icon={() => (
<img
className={classes.bestOfYoutubeIcon}
src={item.icon}
alt={item.title + " logo"}
/>
)}
/>
);
})}
</List>
);
}
Example #25
Source File: AccountsModal.js From akashlytics-deploy with GNU General Public License v3.0 | 5 votes |
AccountsModal = ({ onClose }) => {
const classes = useStyles();
const { address, setSelectedWallet, wallets, setWallets } = useWallet();
const { localCerts, setLocalCert, setValidCertificates, setSelectedCertificate } = useCertificate();
const { wallets: storageWallets } = useStorageWallets();
const history = useHistory();
const handleSelectAccount = (wallet) => {
if (wallet.address !== address) {
const newWallet = wallets.find((w) => w.address === wallet.address);
// Update memory wallets
for (let i = 0; i < wallets.length; i++) {
wallets[i].selected = wallets[i].address === wallet.address;
}
// Update storage wallets
const newStorageWallets = storageWallets.map((w) => ({ ...w, selected: w.address === wallet.address }));
const localCert = localCerts.find((c) => c.address === wallet.address);
updateStorageWallets(newStorageWallets);
setWallets(wallets);
setSelectedWallet(newWallet);
setValidCertificates([]);
setSelectedCertificate(null);
if (localCert) {
setLocalCert(localCert);
}
onClose();
history.replace(UrlService.dashboard());
}
};
const handleAddAccount = () => {
history.push(UrlService.register(true));
onClose();
};
return (
<Dialog open={true} onClose={onClose} maxWidth="xs" fullWidth>
<DialogTitle>
<span className={classes.dialogTitle}>
Accounts
<Button variant="contained" size="small" color="primary" onClick={handleAddAccount}>
Add account
</Button>
</span>
</DialogTitle>
<DialogContent dividers className={classes.dialogContent}>
<List className={classes.list}>
{storageWallets.map((wallet) => {
return (
<ListItem key={wallet.address} dense button onClick={() => handleSelectAccount(wallet)}>
<ListItemIcon>{wallet.address === address && <CheckIcon color="primary" />}</ListItemIcon>
<ListItemText
classes={{ secondary: classes.secondaryText }}
primary={
<Box display="flex" alignItems="center" justifyContent="space-between" fontSize="1rem">
{wallet.name}
</Box>
}
secondary={wallet.address}
/>
</ListItem>
);
})}
</List>
</DialogContent>
<DialogActions>
<Button onClick={onClose} type="button" autoFocus variant="contained" color="primary">
Close
</Button>
</DialogActions>
</Dialog>
);
}
Example #26
Source File: ArchivedCards.js From TrelloClone with MIT License | 5 votes |
ArchivedCards = () => {
const cards = useSelector((state) => state.board.board.cardObjects);
const lists = useSelector((state) => state.board.board.listObjects);
const dispatch = useDispatch();
const onDelete = async (listId, cardId) => {
dispatch(deleteCard(listId, cardId));
};
const onSendBack = async (cardId) => {
dispatch(archiveCard(cardId, false));
};
return (
<div>
<List>
{cards
.filter((card) => card.archived)
.map((card, index) => (
<ListItem key={index} className='archived-card'>
<Card>
<CardContent>{card.title}</CardContent>
</Card>
<div>
<Button
color='secondary'
onClick={() =>
onDelete(
lists.find((list) => list.cards.includes(card._id))._id,
card._id
)
}
>
Delete Card
</Button>
<Button onClick={() => onSendBack(card._id)}>Send to List</Button>
</div>
</ListItem>
))}
</List>
</div>
);
}
Example #27
Source File: MenuList.js From social-media-strategy-fe with MIT License | 5 votes |
MenuList = () => {
const classes = useStyles();
const location = useLocation();
const { push } = useHistory();
const { authService } = useOktaAuth();
const logout = async () => {
await authService.logout("/");
};
return (
<>
<Hidden xsDown>
<Button className={classes.logoButton} onClick={() => push("/home")}>
<img className={classes.logo} src={logo} alt="SoMe logo" />
</Button>
</Hidden>
<CreatePost />
<List aria-label="Menu">
<ListItem button onClick={() => push("/home")}>
<ListItemIcon>
<DashboardIcon
className={
location.pathname.includes("/home")
? classes.selectedIcon
: classes.icon
}
/>
</ListItemIcon>
<ListItemText primary="Media Manager" />
</ListItem>
<ListItem button onClick={() => push("/analytics")}>
<ListItemIcon>
<TrendingUpIcon
className={
location.pathname.includes("/analytics")
? classes.selectedIcon
: classes.icon
}
/>
</ListItemIcon>
<ListItemText primary="Analytics" />
</ListItem>
<ListItem button onClick={() => push("/connect/twitter")}>
<ListItemIcon>
<AccountBoxIcon
className={
location.pathname.includes("/connect")
? classes.selectedIcon
: classes.icon
}
/>
</ListItemIcon>
<ListItemText primary="Accounts" />
</ListItem>
</List>
<List>
<ListItem button onClick={logout}>
<ListItemIcon>
<ExitToAppIcon color="primary" />
</ListItemIcon>
<ListItemText primary="Logout" />
</ListItem>
</List>
</>
);
}
Example #28
Source File: PublicComments.js From app with MIT License | 5 votes |
function CommentList({ requestId }) {
const classes = useStyles();
const firestore = useFirestore();
const querySnapshot = useFirestoreCollection(
firestore
.collection(`${REQUESTS_COMMENTS_PUBLIC_COLLECTION}`)
.where('requestId', '==', requestId)
.orderBy('createdAt', 'asc'),
);
if (querySnapshot.empty) {
return (
<Box color="text.disabled">
<Typography
variant="body2"
className={classes.noComments}
data-test="no-comments">
No public comments.
</Typography>
</Box>
);
}
return (
<List>
{querySnapshot.docs.map(
(docSnap) =>
// When new comment is added locally, the createdAt can be the serverTimestamp() value.
// So, we wait on rendering until any new snapshot has finished writing.
!docSnap.metadata.hasPendingWrites && (
<ListItem
key={docSnap.id}
divider
alignItems="flex-start"
data-test="public-comment">
<ListItemAvatar>
<Avatar>{docSnap.get('author.firstName').slice(0, 1)}</Avatar>
</ListItemAvatar>
<ListItemText
disableTypography
primary={
<Typography variant="subtitle2" data-test="comment-author">
{docSnap.get('author.firstName')} –{' '}
<Typography
variant="body2"
display="inline"
color="textSecondary">
{format(docSnap.get('createdAt').toDate(), 'p - PPPP')}
</Typography>
</Typography>
}
secondary={docSnap
.get('content')
.split('\n')
.map((content, key) => (
<Typography
variant="body1"
/* eslint-disable react/no-array-index-key */
key={key}
/* eslint-enable react/no-array-index-key */
gutterBottom
data-test="comment-content">
{content}
</Typography>
))}
/>
</ListItem>
),
)}
</List>
);
}
Example #29
Source File: OwnerOrganizers.js From Quizzie with MIT License | 5 votes |
function OwnerUsers() {
const [organizers, setOrganizers] = useState([]);
const getUsers = async () => {
let token = localStorage.getItem("authToken");
let url = `https://quizzie-api.herokuapp.com/owner/allAdmins`;
try {
await axios.get(url, {
headers: {
"auth-token": token
}
}).then(res => {
setOrganizers(res.data.result);
})
} catch(error) {
console.log(error);
}
}
useEffect(() => {
getUsers();
}, [])
return (
<div className="owner-quizzes">
<List aria-label="users-display" className="owner-quiz-list">
{organizers.map((user) => (
<ListItem button key={user._id}>
<ListItemText primary={user.email} secondary={user.name} />
<ListItemSecondaryAction>
<IconButton edge="end" aria-label="details">
<ArrowForwardIos />
</IconButton>
</ListItemSecondaryAction>
</ListItem>
))}
</List>
</div>
)
}