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 | 2x 2x 2x 2x 2x 17x 17x 17x | import { Card, CircularProgress, styled, Typography } from "@mui/material";
import Alert from "components/Alert";
import TextBody from "components/TextBody";
import React from "react";
import { theme } from "theme";
interface FriendTileProps {
children: React.ReactNode;
errorMessage: string | null;
hasData: boolean;
isLoading: boolean;
noDataMessage: string;
title: string;
}
const StyledContainer = styled("div")(({ theme }) => ({
margin: theme.spacing(2),
"& > *": {
marginBottom: theme.spacing(2),
},
}));
const StyledHeader = styled(Typography)(({ theme }) => ({
fontWeight: theme.typography.fontWeightBold,
marginBottom: theme.spacing(2),
marginLeft: theme.spacing(1),
}));
function FriendTile({
children,
errorMessage,
hasData,
isLoading,
noDataMessage,
title,
}: FriendTileProps) {
return (
<Card>
<StyledContainer>
<StyledHeader variant="h2">{title}</StyledHeader>
{errorMessage ? (
<Alert severity="error" sx={{ borderRadius: 0 }}>
{errorMessage}
</Alert>
) : null}
{isLoading ? (
<CircularProgress
sx={{ display: "block", margin: `0 auto ${theme.spacing(1)}` }}
/>
) : hasData ? (
children
) : (
<TextBody sx={{ marginLeft: theme.spacing(1) }}>
{noDataMessage}
</TextBody>
)}
</StyledContainer>
</Card>
);
}
export default FriendTile;
|