@mui/material#Card JavaScript Examples
The following examples show how to use
@mui/material#Card.
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: Analytics.jsx From matx-react with MIT License | 6 votes |
Analytics = () => {
const { palette } = useTheme();
return (
<Fragment>
<ContentBox className="analytics">
<Grid container spacing={3}>
<Grid item lg={8} md={8} sm={12} xs={12}>
<StatCards />
<TopSellingTable />
<StatCards2 />
<H4>Ongoing Projects</H4>
<RowCards />
</Grid>
<Grid item lg={4} md={4} sm={12} xs={12}>
<Card sx={{ px: 3, py: 2, mb: 3 }}>
<Title>Traffic Sources</Title>
<SubTitle>Last 30 days</SubTitle>
<DoughnutChart
height="300px"
color={[palette.primary.dark, palette.primary.main, palette.primary.light]}
/>
</Card>
<UpgradeCard />
<Campaigns />
</Grid>
</Grid>
</ContentBox>
</Fragment>
);
}
Example #2
Source File: StatCards.jsx From matx-react with MIT License | 6 votes |
StyledCard = styled(Card)(({ theme }) => ({
display: 'flex',
flexWrap: 'wrap',
alignItems: 'center',
justifyContent: 'space-between',
padding: '24px !important',
background: theme.palette.background.paper,
[theme.breakpoints.down('sm')]: { padding: '16px !important' },
}))
Example #3
Source File: BlogCard.js From react-saas-template with MIT License | 6 votes |
function BlogCard(props) {
const { classes, url, src, date, title, snippet } = props;
return (
<Card className={classes.card}>
{src && (
<Link to={url} tabIndex={-1}>
<img src={src} className={classes.img} alt="" />
</Link>
)}
<Box p={2}>
<Typography variant="body2" color="textSecondary">
{format(new Date(date * 1000), "PPP", {
awareOfUnicodeTokens: true,
})}
</Typography>
<Link
to={url}
className={classNames(classes.noDecoration, classes.showFocus)}
>
<Typography variant="h6">
<span className={classes.title}>{title}</span>
</Typography>
</Link>
<Typography variant="body1" color="textSecondary">
{snippet}
<Link to={url} className={classes.noDecoration} tabIndex={-1}>
<span className={classes.link}> read more...</span>
</Link>
</Typography>
</Box>
</Card>
);
}
Example #4
Source File: Signup.jsx From CRM with Apache License 2.0 | 6 votes |
Login = () => {
return (
<section className="wrapper">
<div className="d-flex justify-content-center align-items-center h-100">
<Card className="auth-card">
<h1 className="auth-title">register</h1>
<img src={TopImg} alt="" />
<CardContent>
<CustomAuthInput
label="Name"
size="small"
placeholder="ex: John Doe"
/>
<CustomAuthInput
label="Email"
size="small"
placeholder="ex: [email protected]"
/>
<CustomAuthInput
label="Password"
size="small"
type="password"
placeholder="enter password"
/>
<Button variant="contained" fullWidth className="mt-3">
Register as Admin
</Button>
<div className="mt-3">
<Link to="/login">Have account already? then Signin</Link>
</div>
</CardContent>
</Card>
</div>
</section>
);
}
Example #5
Source File: Login.jsx From CRM with Apache License 2.0 | 6 votes |
Login = () => {
return (
<section className="wrapper">
<div className="d-flex justify-content-center align-items-center h-100">
<Card className="auth-card">
<h1 className="auth-title">log in</h1>
<img src={TopImg} alt="" />
<CardContent>
<CustomAuthInput
label="Email"
size="small"
placeholder="ex: [email protected]"
/>
<CustomAuthInput
label="Password"
size="small"
type="password"
placeholder="enter password"
/>
<Button variant="contained" fullWidth className="mt-3">
Login
</Button>
<div className="mt-3">
<Link to="/signup">No account created? then Signup</Link>
</div>
</CardContent>
</Card>
</div>
</section>
);
}
Example #6
Source File: CDA.jsx From CRM with Apache License 2.0 | 6 votes |
CDA = () => { return ( // <section className="wrapper"> <div className="row"> <div className="col-md-3"> <Card elevation={15}> <CardContent>Project</CardContent> </Card> </div> </div> // </section> ); }
Example #7
Source File: CustomModal.jsx From CRM with Apache License 2.0 | 6 votes |
CustomModal = ({ open = false, onClose, title, children }) => {
return (
<Modal open={open} onClose={onClose}>
<StyledModalCard>
<h2 className="mb-2">{title}</h2>
<Card className="p-3" elevation={0}>
{children}
</Card>
</StyledModalCard>
</Modal>
);
}
Example #8
Source File: CustomModal.jsx From CRM with Apache License 2.0 | 6 votes |
StyledModalCard = styled(Card)(({ theme }) => ({
top: "50%",
left: "50%",
maxWidth: 700,
minWidth: 300,
maxHeight: "80vh",
overflowY: "scroll",
position: "absolute",
padding: "1.5rem",
boxShadow: theme.shadows[2],
transform: "translate(-50%, -50%)",
width: "100%",
outline: "none",
backgroundColor: "#27293d",
// backgroundColor: "#f3f4f9",
}))
Example #9
Source File: Register.js From Django-REST-Framework-React-BoilerPlate with MIT License | 5 votes |
SectionStyle = styled(Card)(({ theme }) => ({
width: '100%',
maxWidth: 464,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
margin: theme.spacing(2, 0, 2, 2),
}))
Example #10
Source File: RowCards.jsx From matx-react with MIT License | 5 votes |
RowCards = () => {
const { palette } = useTheme();
const textMuted = palette.text.secondary;
return [1, 2, 3, 4].map((id) => (
<Fragment key={id}>
<Card sx={{ py: 1, px: 2 }} className="project-card">
<Grid container alignItems="center">
<Grid item md={5} xs={7}>
<Box display="flex" alignItems="center">
<Checkbox />
<Hidden smDown>
{id % 2 === 1 ? (
<StarOutline size="small">
<Icon>star_outline</Icon>
</StarOutline>
) : (
<DateRange size="small">
<Icon>date_range</Icon>
</DateRange>
)}
</Hidden>
<ProjectName>Project {id}</ProjectName>
</Box>
</Grid>
<Grid item md={3} xs={4}>
<Box color={textMuted}>{format(new Date().getTime(), 'MM/dd/yyyy hh:mma')}</Box>
</Grid>
<Hidden smDown>
<Grid item xs={3}>
<Box display="flex" position="relative" marginLeft="-0.875rem !important">
<StyledAvatar src="/assets/images/face-4.jpg" />
<StyledAvatar src="/assets/images/face-4.jpg" />
<StyledAvatar src="/assets/images/face-4.jpg" />
<StyledAvatar sx={{ fontSize: '14px' }}>+3</StyledAvatar>
</Box>
</Grid>
</Hidden>
<Grid item xs={1}>
<Box display="flex" justifyContent="flex-end">
<IconButton>
<Icon>more_vert</Icon>
</IconButton>
</Box>
</Grid>
</Grid>
</Card>
<Box py={1} />
</Fragment>
));
}
Example #11
Source File: SimpleCard.jsx From matx-react with MIT License | 5 votes |
CardRoot = styled(Card)(() => ({
height: '100%',
padding: '20px 24px',
}))
Example #12
Source File: StatCards2.jsx From matx-react with MIT License | 5 votes |
StatCards2 = () => {
const { palette } = useTheme();
const textError = palette.error.main;
const bgError = lighten(palette.error.main, 0.85);
return (
<Grid container spacing={3} sx={{ mb: 3 }}>
<Grid item xs={12} md={6}>
<Card elevation={3} sx={{ p: 2 }}>
<ContentBox>
<FabIcon size="medium" sx={{ background: 'rgba(9, 182, 109, 0.15)' }}>
<Icon sx={{ color: '#08ad6c' }}>trending_up</Icon>
</FabIcon>
<H3 textcolor={'#08ad6c'}>Active Users</H3>
</ContentBox>
<ContentBox sx={{ pt: 2 }}>
<H1>10.8k</H1>
<IconBox sx={{ background: 'rgba(9, 182, 109, 0.15)' }}>
<Icon className="icon">expand_less</Icon>
</IconBox>
<Span textcolor={'#08ad6c'}>(+21%)</Span>
</ContentBox>
</Card>
</Grid>
<Grid item xs={12} md={6}>
<Card elevation={3} sx={{ p: 2 }}>
<ContentBox>
<FabIcon size="medium" sx={{ background: bgError, overflow: 'hidden' }}>
<Icon sx={{ color: textError }}>star_outline</Icon>
</FabIcon>
<H3 textcolor={textError}>Transactions</H3>
</ContentBox>
<ContentBox sx={{ pt: 2 }}>
<H1>$2.8M</H1>
<IconBox sx={{ background: bgError }}>
<Icon className="icon">expand_less</Icon>
</IconBox>
<Span textcolor={textError}>(+21%)</Span>
</ContentBox>
</Card>
</Grid>
</Grid>
);
}
Example #13
Source File: TopSellingTable.jsx From matx-react with MIT License | 5 votes |
TopSellingTable = () => {
const { palette } = useTheme();
const bgError = palette.error.main;
const bgPrimary = palette.primary.main;
const bgSecondary = palette.secondary.main;
return (
<Card elevation={3} sx={{ pt: '20px', mb: 3 }}>
<CardHeader>
<Title>top selling products</Title>
<Select size="small" defaultValue="this_month">
<MenuItem value="this_month">This Month</MenuItem>
<MenuItem value="last_month">Last Month</MenuItem>
</Select>
</CardHeader>
<Box overflow="auto">
<ProductTable>
<TableHead>
<TableRow>
<TableCell sx={{ px: 3 }} colSpan={4}>
Name
</TableCell>
<TableCell sx={{ px: 0 }} colSpan={2}>
Revenue
</TableCell>
<TableCell sx={{ px: 0 }} colSpan={2}>
Stock Status
</TableCell>
<TableCell sx={{ px: 0 }} colSpan={1}>
Action
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{productList.map((product, index) => (
<TableRow key={index} hover>
<TableCell colSpan={4} align="left" sx={{ px: 0, textTransform: 'capitalize' }}>
<Box display="flex" alignItems="center">
<Avatar src={product.imgUrl} />
<Paragraph sx={{ m: 0, ml: 4 }}>{product.name}</Paragraph>
</Box>
</TableCell>
<TableCell align="left" colSpan={2} sx={{ px: 0, textTransform: 'capitalize' }}>
${product.price > 999 ? (product.price / 1000).toFixed(1) + 'k' : product.price}
</TableCell>
<TableCell sx={{ px: 0 }} align="left" colSpan={2}>
{product.available ? (
product.available < 20 ? (
<Small bgcolor={bgSecondary}>{product.available} available</Small>
) : (
<Small bgcolor={bgPrimary}>in stock</Small>
)
) : (
<Small bgcolor={bgError}>out of stock</Small>
)}
</TableCell>
<TableCell sx={{ px: 0 }} colSpan={1}>
<IconButton>
<Icon color="primary">edit</Icon>
</IconButton>
</TableCell>
</TableRow>
))}
</TableBody>
</ProductTable>
</Box>
</Card>
);
}
Example #14
Source File: Login.js From Django-REST-Framework-React-BoilerPlate with MIT License | 5 votes |
SectionStyle = styled(Card)(({ theme }) => ({
width: '100%',
maxWidth: 464,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
margin: theme.spacing(2, 0, 2, 2),
}))
Example #15
Source File: DashboardApp.js From Django-REST-Framework-React-BoilerPlate with MIT License | 5 votes |
// ----------------------------------------------------------------------
export default function DashboardApp() {
return (
<Page title="Dashboard">
<Container maxWidth="xl">
<Typography variant="h4" sx={{ mb: 5 }}>
Hi, Welcome ?
</Typography>
<Grid container spacing={3}>
<Grid item xs={12} md={6} lg={8}>
<Card>
<Box sx={{ p: 3, pb: 1 }} dir="ltr">
<Typography variant="p" sx={{ mb: 5 }}>
Kick start your project ?
</Typography>
All the best for your new project
<Typography>
Please make sure to{' '}
<Link
href="https://github.com/faisalnazik/Django-REST-Framework-React-BoilerPlate/blob/master/README.md"
target="_blank"
>
README
</Link>
to understand where to go from here to use this BoilerPlate
</Typography>
<Box m={2} pt={3}>
<Button
href="https://github.com/faisalnazik/Django-REST-Framework-React-BoilerPlate"
target="_blank"
variant="outlined"
>
Get more information
</Button>
</Box>
</Box>
</Card>
</Grid>
<Grid item xs={12} md={6} lg={4}>
<Card>
{' '}
<CardContent>
<Typography sx={{ fontSize: 14 }} color="text.secondary" gutterBottom>
@faisalnazik
</Typography>
<Typography variant="h5" component="div">
Give a ⭐️ if this project helped you!
</Typography>
<Typography variant="body2">
If you have find any type of Bug, Raise an Issue So we can fix it
</Typography>
</CardContent>
<CardActions>
<Box m={2} pt={2}>
<Button
href="https://github.com/faisalnazik/Django-REST-Framework-React-BoilerPlate"
target="_blank"
variant="outlined"
>
Github
</Button>
</Box>
</CardActions>
</Card>
</Grid>
</Grid>
</Container>
</Page>
);
}
Example #16
Source File: UpgradeCard.jsx From matx-react with MIT License | 5 votes |
CardRoot = styled(Card)(({ theme }) => ({
marginBottom: '24px',
padding: '24px !important',
[theme.breakpoints.down('sm')]: { paddingLeft: '16px !important' },
}))
Example #17
Source File: HeadSection.js From react-saas-template with MIT License | 5 votes |
function HeadSection(props) {
const { classes, theme } = props;
const isWidthUpLg = useMediaQuery(theme.breakpoints.up("lg"));
return (
<Fragment>
<div className={classNames("lg-p-top", classes.wrapper)}>
<div className={classNames("container-fluid", classes.container)}>
<Box display="flex" justifyContent="center" className="row">
<Card
className={classes.card}
data-aos-delay="200"
data-aos="zoom-in"
>
<div className={classNames(classes.containerFix, "container")}>
<Box justifyContent="space-between" className="row">
<Grid item xs={12} md={5}>
<Box
display="flex"
flexDirection="column"
justifyContent="space-between"
height="100%"
>
<Box mb={4}>
<Typography variant={isWidthUpLg ? "h3" : "h4"}>
Free Template for building a SaaS app using
Material-UI
</Typography>
</Box>
<div>
<Box mb={2}>
<Typography
variant={isWidthUpLg ? "h6" : "body1"}
color="textSecondary"
>
Lorem ipsum dolor sit amet, consetetur sadipscing
elitr, sed diam nonumy eirmod tempor invidunt
</Typography>
</Box>
<Button
variant="contained"
color="secondary"
fullWidth
className={classes.extraLargeButton}
classes={{ label: classes.extraLargeButtonLabel }}
href="https://github.com/dunky11/react-saas-template"
>
Download from GitHub
</Button>
</div>
</Box>
</Grid>
<Hidden mdDown>
<Grid item md={6}>
<ZoomImage
src={`${process.env.PUBLIC_URL}/images/logged_out/headerImage.jpg`}
className={classes.image}
alt="header example"
/>
</Grid>
</Hidden>
</Box>
</div>
</Card>
</Box>
</div>
</div>
<WaveBorder
upperColor={theme.palette.secondary.main}
lowerColor="#FFFFFF"
className={classes.waveBorder}
animationNegativeDelay={2}
/>
</Fragment>
);
}
Example #18
Source File: BlogPost.js From react-saas-template with MIT License | 5 votes |
function BlogPost(props) {
const { classes, date, title, src, content, otherArticles } = props;
useEffect(() => {
document.title = `WaVer - ${title}`;
smoothScrollTop();
}, [title]);
return (
<Box
className={classNames("lg-p-top", classes.wrapper)}
display="flex"
justifyContent="center"
>
<div className={classes.blogContentWrapper}>
<Grid container spacing={5}>
<Grid item md={9}>
<Card className={classes.card}>
<Box pt={3} pr={3} pl={3} pb={2}>
<Typography variant="h4">
<b>{title}</b>
</Typography>
<Typography variant="body1" color="textSecondary">
{format(new Date(date * 1000), "PPP", {
awareOfUnicodeTokens: true,
})}
</Typography>
</Box>
<ZoomImage className={classes.img} src={src} alt="" />
<Box p={3}>
{content}
<Box pt={2}>
<Grid spacing={1} container>
{["Facebook", "Twitter", "Reddit", "Tumblr"].map(
(type, index) => (
<Grid item key={index}>
<ShareButton
type={type}
title="React SaaS Template"
description="I found an awesome template for an webapp using React!"
disableElevation
variant="contained"
className="text-white"
classes={{
label: "text-white",
}}
/>
</Grid>
)
)}
</Grid>
</Box>
</Box>
</Card>
</Grid>
<Grid item md={3}>
<Typography variant="h6" paragraph>
Other articles
</Typography>
{otherArticles.map((blogPost) => (
<Box key={blogPost.id} mb={3}>
<BlogCard
title={blogPost.title}
snippet={blogPost.snippet}
date={blogPost.date}
url={`${blogPost.url}${blogPost.params}`}
/>
</Box>
))}
</Grid>
</Grid>
</div>
</Box>
);
}
Example #19
Source File: UpgradeCard.jsx From matx-react with MIT License | 5 votes |
StyledCard = styled(Card)(({ theme }) => ({
boxShadow: 'none',
textAlign: 'center',
position: 'relative',
padding: '24px !important',
background: `rgb(${convertHexToRGB(theme.palette.primary.main)}, 0.15) !important`,
[theme.breakpoints.down('sm')]: { padding: '16px !important' },
}))
Example #20
Source File: ForgotPassword.jsx From matx-react with MIT License | 5 votes |
ForgotPassword = () => {
const navigate = useNavigate();
const [email, setEmail] = useState('[email protected]');
const handleFormSubmit = () => {
console.log(email);
};
return (
<ForgotPasswordRoot>
<Card className="card">
<Grid container>
<Grid item xs={12}>
<JustifyBox p={4}>
<img width="300" src="/assets/images/illustrations/dreamer.svg" alt="" />
</JustifyBox>
<ContentBox>
<form onSubmit={handleFormSubmit}>
<TextField
type="email"
name="email"
size="small"
label="Email"
value={email}
variant="outlined"
onChange={(e) => setEmail(e.target.value)}
sx={{ mb: 3, width: '100%' }}
/>
<Button fullWidth variant="contained" color="primary" type="submit">
Reset Password
</Button>
<Button
fullWidth
color="primary"
variant="outlined"
onClick={() => navigate(-1)}
sx={{ mt: 2 }}
>
Go Back
</Button>
</form>
</ContentBox>
</Grid>
</Grid>
</Card>
</ForgotPasswordRoot>
);
}
Example #21
Source File: AddToOutfit.jsx From hr-atx58-fec-havarti with Mozilla Public License 2.0 | 5 votes |
export default function AddToOutfitCard({ updateWardrobe }) {
//useContext
const { overviewProduct, selectedStyleState, clickTracker } =
useContext(ProductsContext);
const [overviewProductState, setOverviewProductState] = overviewProduct;
const [selectedStyle, setSelectedStyle] = selectedStyleState;
const [clickTrackerFunc] = clickTracker;
const addToOutfitList = (selectedStyleObj) => {
let copyOfSelectedStyleObj = selectedStyleObj;
selectedStyleObj.selectedStyleObj = copyOfSelectedStyleObj;
selectedStyleObj.slogan = overviewProduct.slogan;
selectedStyleObj.overviewProduct = overviewProductState;
selectedStyleObj.description = overviewProductState.description;
selectedStyleObj.category = overviewProductState.category;
selectedStyleObj.features = overviewProductState.features;
updateWardrobe(selectedStyleObj);
};
return (
<Card
onClick={() =>
clickTrackerFunc.clickTrackerFunc(
"Add to Outfit List Card",
event.target
)
}
className={"maxWidth: 300"}
>
<CardContent>
<Typography gutterBottom variant="h5" component="h2">
Like the above outift?
</Typography>
<CardActionArea>
<DoneOutlineIcon
style={{ fontSize: 250 }}
onClick={() => {
addToOutfitList(selectedStyle);
}}
/>
</CardActionArea>
<Typography variant="body2" color="textSecondary" component="p">
Click the Icon add to your wardrobe
</Typography>
</CardContent>
</Card>
);
}
Example #22
Source File: JwtRegister.jsx From matx-react with MIT License | 4 votes |
JwtRegister = () => {
const theme = useTheme();
const { register } = useAuth();
const navigate = useNavigate();
const [loading, setLoading] = useState(false);
const handleFormSubmit = (values) => {
setLoading(true);
try {
register(values.email, values.username, values.password);
navigate('/');
setLoading(false);
} catch (e) {
console.log(e);
setLoading(false);
}
};
return (
<JWTRegister>
<Card className="card">
<Grid container>
<Grid item sm={6} xs={12}>
<ContentBox>
<img
width="100%"
alt="Register"
src="/assets/images/illustrations/posting_photo.svg"
/>
</ContentBox>
</Grid>
<Grid item sm={6} xs={12}>
<Box p={4} height="100%">
<Formik
onSubmit={handleFormSubmit}
initialValues={initialValues}
validationSchema={validationSchema}
>
{({ values, errors, touched, handleChange, handleBlur, handleSubmit }) => (
<form onSubmit={handleSubmit}>
<TextField
fullWidth
size="small"
type="text"
name="username"
label="Username"
variant="outlined"
onBlur={handleBlur}
value={values.username}
onChange={handleChange}
helperText={touched.username && errors.username}
error={Boolean(errors.username && touched.username)}
sx={{ mb: 3 }}
/>
<TextField
fullWidth
size="small"
type="email"
name="email"
label="Email"
variant="outlined"
onBlur={handleBlur}
value={values.email}
onChange={handleChange}
helperText={touched.email && errors.email}
error={Boolean(errors.email && touched.email)}
sx={{ mb: 3 }}
/>
<TextField
fullWidth
size="small"
name="password"
type="password"
label="Password"
variant="outlined"
onBlur={handleBlur}
value={values.password}
onChange={handleChange}
helperText={touched.password && errors.password}
error={Boolean(errors.password && touched.password)}
sx={{ mb: 2 }}
/>
<FlexBox gap={1} alignItems="center">
<Checkbox
size="small"
name="remember"
onChange={handleChange}
checked={values.remember}
sx={{ padding: 0 }}
/>
<Paragraph fontSize={13}>
I have read and agree to the terms of service.
</Paragraph>
</FlexBox>
<LoadingButton
type="submit"
color="primary"
loading={loading}
variant="contained"
sx={{ mb: 2, mt: 3 }}
>
Regiser
</LoadingButton>
<Paragraph>
Already have an account?
<NavLink
to="/session/signin"
style={{ color: theme.palette.primary.main, marginLeft: 5 }}
>
Login
</NavLink>
</Paragraph>
</form>
)}
</Formik>
</Box>
</Grid>
</Grid>
</Card>
</JWTRegister>
);
}
Example #23
Source File: JwtLogin.jsx From matx-react with MIT License | 4 votes |
JwtLogin = () => {
const theme = useTheme();
const navigate = useNavigate();
const [loading, setLoading] = useState(false);
const { login } = useAuth();
const handleFormSubmit = async (values) => {
setLoading(true);
try {
await login(values.email, values.password);
navigate('/');
} catch (e) {
setLoading(false);
}
};
return (
<JWTRoot>
<Card className="card">
<Grid container>
<Grid item sm={6} xs={12}>
<JustifyBox p={4} height="100%" sx={{ minWidth: 320 }}>
<img src="/assets/images/illustrations/dreamer.svg" width="100%" alt="" />
</JustifyBox>
</Grid>
<Grid item sm={6} xs={12}>
<ContentBox>
<Formik
onSubmit={handleFormSubmit}
initialValues={initialValues}
validationSchema={validationSchema}
>
{({ values, errors, touched, handleChange, handleBlur, handleSubmit }) => (
<form onSubmit={handleSubmit}>
<TextField
fullWidth
size="small"
type="email"
name="email"
label="Email"
variant="outlined"
onBlur={handleBlur}
value={values.email}
onChange={handleChange}
helperText={touched.email && errors.email}
error={Boolean(errors.email && touched.email)}
sx={{ mb: 3 }}
/>
<TextField
fullWidth
size="small"
name="password"
type="password"
label="Password"
variant="outlined"
onBlur={handleBlur}
value={values.password}
onChange={handleChange}
helperText={touched.password && errors.password}
error={Boolean(errors.password && touched.password)}
sx={{ mb: 1.5 }}
/>
<FlexBox justifyContent="space-between">
<FlexBox gap={1}>
<Checkbox
size="small"
name="remember"
onChange={handleChange}
checked={values.remember}
sx={{ padding: 0 }}
/>
<Paragraph>Remember Me</Paragraph>
</FlexBox>
<NavLink
to="/session/forgot-password"
style={{ color: theme.palette.primary.main }}
>
Forgot password?
</NavLink>
</FlexBox>
<LoadingButton
type="submit"
color="primary"
loading={loading}
variant="contained"
sx={{ my: 2 }}
>
Login
</LoadingButton>
<Paragraph>
Don't have an account?
<NavLink
to="/session/signup"
style={{ color: theme.palette.primary.main, marginLeft: 5 }}
>
Register
</NavLink>
</Paragraph>
</form>
)}
</Formik>
</ContentBox>
</Grid>
</Grid>
</Card>
</JWTRoot>
);
}
Example #24
Source File: NotificationBar.jsx From matx-react with MIT License | 4 votes |
NotificationBar = ({ container }) => {
const { settings } = useSettings();
const theme = useTheme();
const secondary = theme.palette.text.secondary;
const [panelOpen, setPanelOpen] = React.useState(false);
const { deleteNotification, clearNotifications, notifications } = useNotification();
const handleDrawerToggle = () => {
setPanelOpen(!panelOpen);
};
const { palette } = useTheme();
const textColor = palette.text.primary;
return (
<Fragment>
<IconButton onClick={handleDrawerToggle}>
<Badge color="secondary" badgeContent={notifications?.length}>
<Icon sx={{ color: textColor }}>notifications</Icon>
</Badge>
</IconButton>
<ThemeProvider theme={settings.themes[settings.activeTheme]}>
<Drawer
width={'100px'}
container={container}
variant="temporary"
anchor={'right'}
open={panelOpen}
onClose={handleDrawerToggle}
ModalProps={{
keepMounted: true,
}}
>
<Box sx={{ width: sideNavWidth }}>
<Notification>
<Icon color="primary">notifications</Icon>
<h5>Notifications</h5>
</Notification>
{notifications?.map((notification) => (
<NotificationCard key={notification.id}>
<DeleteButton
size="small"
className="deleteButton"
onClick={() => deleteNotification(notification.id)}
>
<Icon className="icon">clear</Icon>
</DeleteButton>
<Link
to={`/${notification.path}`}
onClick={handleDrawerToggle}
style={{ textDecoration: 'none' }}
>
<Card sx={{ mx: 2, mb: 3 }} elevation={3}>
<CardLeftContent>
<Box display="flex">
<Icon className="icon" color={notification.icon.color}>
{notification.icon.name}
</Icon>
<Heading>{notification.heading}</Heading>
</Box>
<Small className="messageTime">
{getTimeDifference(new Date(notification.timestamp))}
ago
</Small>
</CardLeftContent>
<Box sx={{ px: 2, pt: 1, pb: 2 }}>
<Paragraph sx={{ m: 0 }}>{notification.title}</Paragraph>
<Small sx={{ color: secondary }}>{notification.subtitle}</Small>
</Box>
</Card>
</Link>
</NotificationCard>
))}
{!!notifications?.length && (
<Box sx={{ color: secondary }}>
<Button onClick={clearNotifications}>Clear Notifications</Button>
</Box>
)}
</Box>
</Drawer>
</ThemeProvider>
</Fragment>
);
}
Example #25
Source File: MatxCustomizer.jsx From matx-react with MIT License | 4 votes |
MatxCustomizer = () => {
const theme = useTheme();
const [open, setOpen] = useState(false);
const [tabIndex, setTabIndex] = useState(0);
const { settings, updateSettings } = useSettings();
const secondary = theme.palette.text.secondary;
const tooglePanel = () => setOpen(!open);
const handleTabChange = (index) => setTabIndex(index);
let activeTheme = { ...settings.themes[settings.activeTheme] };
return (
<Fragment>
<Tooltip title="Theme Settings" placement="left">
<Label className="open" onClick={tooglePanel}>
DEMOS
</Label>
</Tooltip>
<ThemeProvider theme={activeTheme}>
<Drawer
open={open}
anchor="right"
variant="temporary"
onClose={tooglePanel}
ModalProps={{ keepMounted: true }}
>
<MaxCustomaizer>
<Controller>
<Box display="flex">
<Icon className="icon" color="primary">
settings
</Icon>
<H5 sx={{ ml: 1, fontSize: '1rem' }}>Theme Settings</H5>
</Box>
<IconButton onClick={tooglePanel}>
<Icon className="icon">close</Icon>
</IconButton>
</Controller>
<Box px={3} mb={2} display="flex">
<Button
variant="outlined"
onClick={() => handleTabChange(0)}
color={tabIndex === 0 ? 'secondary' : 'primary'}
sx={{ mr: 2 }}
>
Demos
</Button>
<Button
variant="outlined"
onClick={() => handleTabChange(1)}
color={tabIndex === 1 ? 'secondary' : 'primary'}
>
Settings
</Button>
</Box>
<StyledScrollBar options={{ suppressScrollX: true }}>
{tabIndex === 0 && (
<Box sx={{ mb: 4, mx: 3 }}>
<Box sx={{ color: secondary }}>Layouts</Box>
<Box display="flex" flexDirection="column">
{demoLayouts.map((layout) => (
<LayoutBox
key={layout.name}
color="secondary"
badgeContent={'Pro'}
invisible={!layout.isPro}
>
<Card
elevation={4}
sx={{ position: 'relative' }}
onClick={() => updateSettings(layout.options)}
>
<Box sx={{ overflow: 'hidden' }} className="layout-name">
<Button variant="contained" color="secondary">
{layout.name}
</Button>
</Box>
<IMG src={layout.thumbnail} alt={layout.name} />
</Card>
</LayoutBox>
))}
</Box>
</Box>
)}
{/* END LAYOUT */}
{tabIndex === 1 && (
<div>
<div className="helpText">
We used React context API to control layout. Check out the{' '}
<Link href="http://demos.ui-lib.com/matx-react-doc/layout.html" target="_blank">
Documentation
</Link>
</div>
</div>
)}
</StyledScrollBar>
</MaxCustomaizer>
</Drawer>
</ThemeProvider>
</Fragment>
);
}
Example #26
Source File: User.js From Django-REST-Framework-React-BoilerPlate with MIT License | 4 votes |
export default function User() {
const userLogin = useSelector((state) => state.userLogin);
const { userInfo } = userLogin;
const listUser = useSelector((state) => state.listUser);
const { loading, error, USERLIST } = listUser;
const [page, setPage] = useState(0);
const [order, setOrder] = useState('asc');
const [selected, setSelected] = useState([]);
const [orderBy, setOrderBy] = useState('name');
const [filterName, setFilterName] = useState('');
const [rowsPerPage, setRowsPerPage] = useState(5);
const handleRequestSort = (event, property) => {
const isAsc = orderBy === property && order === 'asc';
setOrder(isAsc ? 'desc' : 'asc');
setOrderBy(property);
};
const handleSelectAllClick = (event) => {
if (event.target.checked) {
const newSelecteds = USERLIST.map((n) => n.name);
setSelected(newSelecteds);
return;
}
setSelected([]);
};
const handleClick = (event, name) => {
const selectedIndex = selected.indexOf(name);
let newSelected = [];
if (selectedIndex === -1) {
newSelected = newSelected.concat(selected, name);
} else if (selectedIndex === 0) {
newSelected = newSelected.concat(selected.slice(1));
} else if (selectedIndex === selected.length - 1) {
newSelected = newSelected.concat(selected.slice(0, -1));
} else if (selectedIndex > 0) {
newSelected = newSelected.concat(selected.slice(0, selectedIndex), selected.slice(selectedIndex + 1));
}
setSelected(newSelected);
};
const handleChangePage = (event, newPage) => {
setPage(newPage);
};
const handleChangeRowsPerPage = (event) => {
setRowsPerPage(parseInt(event.target.value, 10));
setPage(0);
};
const handleFilterByName = (event) => {
setFilterName(event.target.value);
};
const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - USERLIST.length) : 0;
const filteredUsers = applySortFilter(USERLIST, getComparator(order, orderBy), filterName);
const isUserNotFound = filteredUsers.length === 0;
return (
<Page title="User">
<Container>
{userInfo ? <UsersListCall /> : null}
<Stack direction="row" alignItems="center" justifyContent="space-between" mb={5}>
<Typography variant="h4" gutterBottom>
User
</Typography>
<Button variant="contained" component={RouterLink} to="#" startIcon={<Iconify icon="eva:plus-fill" />}>
New User
</Button>
</Stack>
<Card>
<UserListToolbar numSelected={selected.length} filterName={filterName} onFilterName={handleFilterByName} />
{error ? (
<Alert severity="error">
<AlertTitle>List Loading Error</AlertTitle>
{error}
</Alert>
) : null}
{loading ? (
<Box sx={{ width: '100%' }}>
<LinearProgress />
</Box>
) : null}
<Scrollbar>
<TableContainer sx={{ minWidth: 800 }}>
<Table>
<UserListHead
order={order}
orderBy={orderBy}
headLabel={TABLE_HEAD}
rowCount={USERLIST.length}
numSelected={selected.length}
onRequestSort={handleRequestSort}
onSelectAllClick={handleSelectAllClick}
/>
<TableBody>
{filteredUsers.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map((row) => {
const { id, name, role, status, company, avatarUrl, isVerified } = row;
const isItemSelected = selected.indexOf(name) !== -1;
return (
<TableRow
hover
key={id}
tabIndex={-1}
role="checkbox"
selected={isItemSelected}
aria-checked={isItemSelected}
>
<TableCell padding="checkbox">
<Checkbox checked={isItemSelected} onChange={(event) => handleClick(event, name)} />
</TableCell>
<TableCell component="th" scope="row" padding="none">
<Stack direction="row" alignItems="center" spacing={2}>
<Avatar alt={name} src={avatarUrl} />
<Typography variant="subtitle2" noWrap>
{name}
</Typography>
</Stack>
</TableCell>
<TableCell align="left">{company}</TableCell>
<TableCell align="left">{role}</TableCell>
<TableCell align="left">{isVerified ? 'Yes' : 'No'}</TableCell>
<TableCell align="left">
<Label variant="ghost" color={(status === 'banned' && 'error') || 'success'}>
{sentenceCase(status)}
</Label>
</TableCell>
<TableCell align="right">
<UserMoreMenu />
</TableCell>
</TableRow>
);
})}
{emptyRows > 0 && (
<TableRow style={{ height: 53 * emptyRows }}>
<TableCell colSpan={6} />
</TableRow>
)}
</TableBody>
{isUserNotFound && (
<TableBody>
<TableRow>
<TableCell align="center" colSpan={6} sx={{ py: 3 }}>
<SearchNotFound searchQuery={filterName} />
</TableCell>
</TableRow>
</TableBody>
)}
</Table>
</TableContainer>
</Scrollbar>
<TablePagination
rowsPerPageOptions={[5, 10, 25]}
component="div"
count={USERLIST.length}
rowsPerPage={rowsPerPage}
page={page}
onPageChange={handleChangePage}
onRowsPerPageChange={handleChangeRowsPerPage}
/>
</Card>
</Container>
</Page>
);
}
Example #27
Source File: CardChart.js From react-saas-template with MIT License | 4 votes |
function CardChart(props) {
const { color, data, title, classes, theme, height } = props;
const [anchorEl, setAnchorEl] = useState(null);
const [selectedOption, setSelectedOption] = useState("1 Month");
const handleClick = useCallback(
(event) => {
setAnchorEl(event.currentTarget);
},
[setAnchorEl]
);
const formatter = useCallback(
(value) => {
return [value, title];
},
[title]
);
const getSubtitle = useCallback(() => {
switch (selectedOption) {
case "1 Week":
return "Last week";
case "1 Month":
return "Last month";
case "6 Months":
return "Last 6 months";
default:
throw new Error("No branch selected in switch-statement");
}
}, [selectedOption]);
const processData = useCallback(() => {
let seconds;
switch (selectedOption) {
case "1 Week":
seconds = 60 * 60 * 24 * 7;
break;
case "1 Month":
seconds = 60 * 60 * 24 * 31;
break;
case "6 Months":
seconds = 60 * 60 * 24 * 31 * 6;
break;
default:
throw new Error("No branch selected in switch-statement");
}
const minSeconds = new Date() / 1000 - seconds;
const arr = [];
for (let i = 0; i < data.length; i += 1) {
if (minSeconds < data[i].timestamp) {
arr.unshift(data[i]);
}
}
return arr;
}, [data, selectedOption]);
const handleClose = useCallback(() => {
setAnchorEl(null);
}, [setAnchorEl]);
const selectOption = useCallback(
(selectedOption) => {
setSelectedOption(selectedOption);
handleClose();
},
[setSelectedOption, handleClose]
);
const isOpen = Boolean(anchorEl);
return (
<Card>
<Box pt={2} px={2} pb={4}>
<Box display="flex" justifyContent="space-between">
<div>
<Typography variant="subtitle1">{title}</Typography>
<Typography variant="body2" color="textSecondary">
{getSubtitle()}
</Typography>
</div>
<div>
<IconButton
aria-label="More"
aria-owns={isOpen ? "long-menu" : undefined}
aria-haspopup="true"
onClick={handleClick}
size="large">
<MoreVertIcon />
</IconButton>
<Menu
id="long-menu"
anchorEl={anchorEl}
open={isOpen}
onClose={handleClose}
PaperProps={{
style: {
maxHeight: itemHeight,
width: 200,
},
}}
disableScrollLock
>
{options.map((option) => (
<MenuItem
key={option}
selected={option === selectedOption}
onClick={() => {
selectOption(option);
}}
name={option}
>
{option}
</MenuItem>
))}
</Menu>
</div>
</Box>
</Box>
<CardContent>
<Box className={classes.cardContentInner} height={height}>
<ResponsiveContainer width="100%" height="100%">
<AreaChart data={processData()} type="number">
<XAxis
dataKey="timestamp"
type="number"
domain={["dataMin", "dataMax"]}
hide
/>
<YAxis
domain={[calculateMin(data, "value", 0.05), "dataMax"]}
hide
/>
<Area
type="monotone"
dataKey="value"
stroke={color}
fill={color}
/>
<Tooltip
labelFormatter={labelFormatter}
formatter={formatter}
cursor={false}
contentStyle={{
border: "none",
padding: theme.spacing(1),
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shadows[1],
}}
labelStyle={theme.typography.body1}
itemStyle={{
fontSize: theme.typography.body1.fontSize,
letterSpacing: theme.typography.body1.letterSpacing,
fontFamily: theme.typography.body1.fontFamily,
lineHeight: theme.typography.body1.lineHeight,
fontWeight: theme.typography.body1.fontWeight,
}}
/>
</AreaChart>
</ResponsiveContainer>
</Box>
</CardContent>
</Card>
);
}
Example #28
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 #29
Source File: index.js From fireact with MIT License | 4 votes |
Home = () => {
const title = 'My Accounts';
const history = useHistory();
const { setBreadcrumb } = useContext(BreadcrumbContext);
const [loading, setLoading] = useState(true);
const [accounts, setAccounts] = useState([]);
const mountedRef = useRef(true);
const getAccounts = () => {
setLoading(true);
let records = [];
const accountsRef = FirebaseAuth.firestore().collection('accounts');
let query = accountsRef.where('access', 'array-contains', FirebaseAuth.auth().currentUser.uid);
query.get().then(accountSnapshots => {
if (!mountedRef.current) return null
accountSnapshots.forEach(account => {
records.push({
'id': account.id,
'name': account.data().name,
'subscriptionStatus': account.data().subscriptionStatus
});
});
setAccounts(records);
setLoading(false);
});
}
useEffect(() => {
setBreadcrumb([
{
to: "/",
text: "Home",
active: false
},
{
to: null,
text: title,
active: true
}
]);
getAccounts();
},[setBreadcrumb]);
useEffect(() => {
return () => {
mountedRef.current = false
}
},[]);
return (
<>
{accounts.length > 0 ? (
<>
<div style={{marginTop: '20px', marginBottom: '20px', textAlign: 'right'}}>
<Button onClick={() => history.push('/new-account')} color="primary" variant="contained"><i className="fa fa-plus"></i> Add Account</Button>
</div>
<Grid container spacing={3}>
{accounts.map((account, i) =>
<Grid container item xs={12} md={3} key={i}>
<Card key={account.id} style={{width: '100%'}}>
<CardHeader title={account.name}/>
<CardActions>
{account.subscriptionStatus?(
<Button size="small" color="primary" onClick={() => history.push('/account/'+account.id+'/')}>Account Overview</Button>
):(
<Button size="small" color="warning" onClick={() => history.push('/account/'+account.id+'/billing/plan')}>Activate the account</Button>
)}
</CardActions>
</Card>
</Grid>
)}
</Grid>
</>
) : (
<>
{(loading) ? (
<Loader text="loading accounts..."></Loader>
):(
<Redirect to="/new-account"></Redirect>
)}
</>
)}
</>
)
}