Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | import { Box } from "@mui/material";
import Grid from "@mui/material/Grid";
// components
import Stat from "@common/NewStats/Stat";
import { palette } from "@palette";
import { Customer, PurchaseProductType } from "@customTypes/customer.types";
import { getProductType } from "@components/Customers/Table/renderPurchasesStatistics";
import FadeUpWrapper from "@components/animation/FadeUpWrapper";
type BannerProps = {
data?: Customer;
};
const Banner = ({ data }: BannerProps) => {
const purchases = data?.purchases || [];
const totalPurchased = data?.totalPurchased
? (data?.totalPurchased / 100).toFixed(2)
: 0;
return (
<FadeUpWrapper delay={50}>
<Box sx={mainContent}>
<Grid container rowSpacing={1} columnSpacing={2}>
<Grid item md={4} xs={6}>
<FadeUpWrapper delay={100}>
<Stat value={totalPurchased} title="Sum Total" isAmount />
</FadeUpWrapper>
</Grid>
{[
"fundraiser",
"event",
"invoice",
"membership",
"sweepstake",
"standard",
].map((item, idx) => {
const current = purchases.filter(
(purchase) => purchase.name === item,
)[0];
const label = getProductType(item as PurchaseProductType, true);
return (
<Grid item md={4} xs={6} key={item}>
<FadeUpWrapper delay={100 + idx * 30}>
<Stat value={current?.totalCount || 0} title={label} />
</FadeUpWrapper>
</Grid>
);
})}
</Grid>
</Box>
</FadeUpWrapper>
);
};
const mainContent = {
gap: "16px",
display: "flex",
padding: "16px",
flexDirection: "column",
borderRadius: "8px",
backgroundColor: palette.neutral.white,
};
export default Banner;
|