Add empty state

This commit is contained in:
Leonardo Murça 2022-08-28 17:57:42 -03:00
parent 936d04114b
commit 6fb5af6ea5
6 changed files with 175 additions and 63 deletions

View file

@ -15,7 +15,7 @@ import styles from './styles';
import jitsiLogo from '../../../assets/jitsi.svg'; import jitsiLogo from '../../../assets/jitsi.svg';
function AnnouncementsTab({ layoutType, announcementsTabData, classroom }) { function AnnouncementsTab({ layoutType, announcementsTabData, classroom }) {
const { container } = styles[layoutType]; const { container, emptyStateContainer } = styles[layoutType];
const layoutResolver = (state, layoutType) => { const layoutResolver = (state, layoutType) => {
if (layoutType === 'desktop') { if (layoutType === 'desktop') {
@ -83,15 +83,21 @@ function AnnouncementsTab({ layoutType, announcementsTabData, classroom }) {
> >
<Stack justifyContent="flex-start" spacing={1}> <Stack justifyContent="flex-start" spacing={1}>
<h3 style={{ fontWeight: 500 }}>Próximas Atividades</h3> <h3 style={{ fontWeight: 500 }}>Próximas Atividades</h3>
{announcementsTabData.upcomingAssignments.map(ua => ( {announcementsTabData.upcomingAssignments.length !== 0 ? (
<Link announcementsTabData.upcomingAssignments.map(ua => (
href={`/assignment/${ua.id}`} <Link
sx={{ fontSize: '15px' }} href={`/assignment/${ua.id}`}
key={ua.id} sx={{ fontSize: '15px' }}
> key={ua.id}
{ua.title} >
</Link> {ua.title}
))} </Link>
))
) : (
<Container disableGutters>
<p>Nenhuma atividade encontrada!</p>
</Container>
)}
</Stack> </Stack>
</Card> </Card>
<Card <Card
@ -121,12 +127,18 @@ function AnnouncementsTab({ layoutType, announcementsTabData, classroom }) {
direction="row" direction="row"
gap="30px" gap="30px"
> >
{announcementsTabData.announcements.map(announcement => ( {announcementsTabData.announcements.length !== 0 ? (
<AnnouncementCard announcementsTabData.announcements.map(announcement => (
key={announcement.id} <AnnouncementCard
announcement={announcement} key={announcement.id}
/> announcement={announcement}
))} />
))
) : (
<Container sx={emptyStateContainer} disableGutters>
<p>Nenhum comunicado encontrado!</p>
</Container>
)}
</Stack> </Stack>
</Grid> </Grid>
</Grid> </Grid>
@ -212,15 +224,21 @@ function AnnouncementsTab({ layoutType, announcementsTabData, classroom }) {
> >
<Stack justifyContent="flex-start" spacing={1}> <Stack justifyContent="flex-start" spacing={1}>
<h3 style={{ fontWeight: 500 }}>Próximas Atividades</h3> <h3 style={{ fontWeight: 500 }}>Próximas Atividades</h3>
{announcementsTabData.upcomingAssignments.map(ua => ( {announcementsTabData.upcomingAssignments.length !== 0 ? (
<Link announcementsTabData.upcomingAssignments.map(ua => (
href={`/assignment/${ua.id}`} <Link
sx={{ fontSize: '15px' }} href={`/assignment/${ua.id}`}
key={ua.id} sx={{ fontSize: '15px' }}
> key={ua.id}
{ua.title} >
</Link> {ua.title}
))} </Link>
))
) : (
<Container disableGutters>
<p>Nenhuma atividade encontrada!</p>
</Container>
)}
</Stack> </Stack>
</Card> </Card>
<Card <Card
@ -246,12 +264,18 @@ function AnnouncementsTab({ layoutType, announcementsTabData, classroom }) {
direction="row" direction="row"
gap="30px" gap="30px"
> >
{announcementsTabData.announcements.map(announcement => ( {announcementsTabData.announcements.length !== 0 ? (
<AnnouncementCard announcementsTabData.announcements.map(announcement => (
key={announcement.id} <AnnouncementCard
announcement={announcement} key={announcement.id}
/> announcement={announcement}
))} />
))
) : (
<Container sx={emptyStateContainer} disableGutters>
<p>Nenhum comunicado encontrado!</p>
</Container>
)}
</Stack> </Stack>
</Stack> </Stack>
); );

View file

@ -8,8 +8,15 @@ const desktopContainer = {
marginTop: '50px', marginTop: '50px',
}; };
const desktopEmptyStateContainer = {
display: 'flex',
justifyContent: 'center',
marginTop: '30px',
};
const desktop = { const desktop = {
container: desktopContainer, container: desktopContainer,
emptyStateContainer: desktopEmptyStateContainer,
}; };
// ========== Mobile ========== // ========== Mobile ==========
@ -21,8 +28,15 @@ const mobileContainer = {
paddingBottom: '100px', paddingBottom: '100px',
}; };
const mobileEmptyStateContainer = {
display: 'flex',
justifyContent: 'center',
marginTop: '30px',
};
const mobile = { const mobile = {
container: mobileContainer, container: mobileContainer,
emptyStateContainer: mobileEmptyStateContainer,
}; };
// ========== Unset ========== // ========== Unset ==========

View file

@ -14,6 +14,7 @@ function AssignmentsTab({ assignmentsTabData, layoutType }) {
assignmentLink, assignmentLink,
assignmentDueDate, assignmentDueDate,
assignmentScores, assignmentScores,
emptyStateContainer,
} = styles[layoutType]; } = styles[layoutType];
if (layoutType === 'desktop') { if (layoutType === 'desktop') {
switch (state) { switch (state) {
@ -89,6 +90,9 @@ function AssignmentsTab({ assignmentsTabData, layoutType }) {
); );
case 'idle': case 'idle':
const assesments = assignments.filter(a => a.type === 'assessment');
const projects = assignments.filter(a => a.type === 'project');
return ( return (
<Container sx={externalContainer} disableGutters> <Container sx={externalContainer} disableGutters>
<Container sx={innerContainer} disableGutters> <Container sx={innerContainer} disableGutters>
@ -96,9 +100,8 @@ function AssignmentsTab({ assignmentsTabData, layoutType }) {
Provas Provas
</Typography> </Typography>
<Stack alignItems="center"> <Stack alignItems="center">
{assignments {assesments.length !== 0 ? (
.filter(a => a.type === 'assessment') assesments.map(a => (
.map(a => (
<Container <Container
key={a.id} key={a.id}
sx={assignmentContainer} sx={assignmentContainer}
@ -131,7 +134,12 @@ function AssignmentsTab({ assignmentsTabData, layoutType }) {
{a.scores.map(s => s.value).join(', ')} pts {a.scores.map(s => s.value).join(', ')} pts
</Typography> </Typography>
</Container> </Container>
))} ))
) : (
<Container sx={emptyStateContainer} disableGutters>
<p>Nenhuma prova encontrada!</p>
</Container>
)}
</Stack> </Stack>
</Container> </Container>
@ -140,9 +148,8 @@ function AssignmentsTab({ assignmentsTabData, layoutType }) {
Trabalhos Trabalhos
</Typography> </Typography>
<Stack alignItems="center"> <Stack alignItems="center">
{assignments {projects.length !== 0 ? (
.filter(a => a.type === 'project') projects.map(a => (
.map(a => (
<Container <Container
key={a.id} key={a.id}
sx={assignmentContainer} sx={assignmentContainer}
@ -175,7 +182,12 @@ function AssignmentsTab({ assignmentsTabData, layoutType }) {
{a.scores.map(s => s.value).join(', ')} pts {a.scores.map(s => s.value).join(', ')} pts
</Typography> </Typography>
</Container> </Container>
))} ))
) : (
<Container sx={emptyStateContainer} disableGutters>
<p>Nenhum trabalho encontrado!</p>
</Container>
)}
</Stack> </Stack>
</Container> </Container>
</Container> </Container>
@ -250,6 +262,9 @@ function AssignmentsTab({ assignmentsTabData, layoutType }) {
); );
case 'idle': case 'idle':
const assesments = assignments.filter(a => a.type === 'assessment');
const projects = assignments.filter(a => a.type === 'project');
return ( return (
<Container sx={externalContainer} disableGutters> <Container sx={externalContainer} disableGutters>
<Container sx={innerContainer} disableGutters> <Container sx={innerContainer} disableGutters>
@ -257,9 +272,8 @@ function AssignmentsTab({ assignmentsTabData, layoutType }) {
Provas Provas
</Typography> </Typography>
<Stack alignItems="center"> <Stack alignItems="center">
{assignments {assesments.length !== 0 ? (
.filter(a => a.type === 'assessment') assesments.map(a => (
.map(a => (
<Container <Container
key={a.id} key={a.id}
sx={assignmentContainer} sx={assignmentContainer}
@ -292,7 +306,12 @@ function AssignmentsTab({ assignmentsTabData, layoutType }) {
{a.scores.map(s => s.value).join(', ')} pts {a.scores.map(s => s.value).join(', ')} pts
</Typography> </Typography>
</Container> </Container>
))} ))
) : (
<Container sx={emptyStateContainer} disableGutters>
<p>Nenhuma prova encontrada!</p>
</Container>
)}
</Stack> </Stack>
</Container> </Container>
@ -301,9 +320,8 @@ function AssignmentsTab({ assignmentsTabData, layoutType }) {
Trabalhos Trabalhos
</Typography> </Typography>
<Stack alignItems="center"> <Stack alignItems="center">
{assignments {projects.length !== 0 ? (
.filter(a => a.type === 'project') projects.map(a => (
.map(a => (
<Container <Container
key={a.id} key={a.id}
sx={assignmentContainer} sx={assignmentContainer}
@ -336,7 +354,12 @@ function AssignmentsTab({ assignmentsTabData, layoutType }) {
{a.scores.map(s => s.value).join(', ')} pts {a.scores.map(s => s.value).join(', ')} pts
</Typography> </Typography>
</Container> </Container>
))} ))
) : (
<Container sx={emptyStateContainer} disableGutters>
<p>Nenhum trabalho encontrado!</p>
</Container>
)}
</Stack> </Stack>
</Container> </Container>
</Container> </Container>

View file

@ -37,6 +37,12 @@ const desktopAssignmentScores = {
fontSize: '15px', fontSize: '15px',
}; };
const desktopEmptyStateContainer = {
display: 'flex',
justifyContent: 'center',
marginTop: '30px',
};
const desktop = { const desktop = {
externalContainer: desktopExternalContainer, externalContainer: desktopExternalContainer,
innerContainer: desktopInnerContainer, innerContainer: desktopInnerContainer,
@ -46,6 +52,7 @@ const desktop = {
assignmentLink: desktopAssignmentLink, assignmentLink: desktopAssignmentLink,
assignmentDueDate: desktopAssignmentDueDate, assignmentDueDate: desktopAssignmentDueDate,
assignmentScores: desktopAssignmentScores, assignmentScores: desktopAssignmentScores,
emptyStateContainer: desktopEmptyStateContainer,
}; };
// ========== Mobile ========== // ========== Mobile ==========
@ -93,6 +100,12 @@ const mobileAssignmentScores = {
fontSize: '12px', fontSize: '12px',
}; };
const mobileEmptyStateContainer = {
display: 'flex',
justifyContent: 'center',
marginTop: '30px',
};
const mobile = { const mobile = {
externalContainer: mobileExternalContainer, externalContainer: mobileExternalContainer,
innerContainer: mobileInnerContainer, innerContainer: mobileInnerContainer,
@ -102,6 +115,7 @@ const mobile = {
assignmentLink: mobileAssignmentLink, assignmentLink: mobileAssignmentLink,
assignmentDueDate: mobileAssignmentDueDate, assignmentDueDate: mobileAssignmentDueDate,
assignmentScores: mobileAssignmentScores, assignmentScores: mobileAssignmentScores,
emptyStateContainer: mobileEmptyStateContainer,
}; };
// ========== Unset ========== // ========== Unset ==========

View file

@ -11,6 +11,7 @@ function PeopleTab({ layoutType, peopleTabData }) {
personContainer, personContainer,
personAvatar, personAvatar,
personName, personName,
emptyStateContainer,
} = styles[layoutType]; } = styles[layoutType];
if (layoutType === 'desktop') { if (layoutType === 'desktop') {
switch (state) { switch (state) {
@ -66,6 +67,9 @@ function PeopleTab({ layoutType, peopleTabData }) {
</Container> </Container>
); );
case 'idle': case 'idle':
const professors = people.filter(p => p.role === 'PROFESSOR');
const students = people.filter(p => p.role === 'STUDENT');
return ( return (
<Container sx={externalContainer} disableGutters> <Container sx={externalContainer} disableGutters>
<Container sx={sectionContainer} disableGutters> <Container sx={sectionContainer} disableGutters>
@ -73,16 +77,20 @@ function PeopleTab({ layoutType, peopleTabData }) {
Docentes Docentes
</Typography> </Typography>
<Stack alignItems="center"> <Stack alignItems="center">
{people {professors.length !== 0 ? (
.filter(p => p.role === 'PROFESSOR') professors.map(p => (
.map(p => (
<Container key={p.id} sx={personContainer} disableGutters> <Container key={p.id} sx={personContainer} disableGutters>
<Avatar alt={p.name} src={p.avatar} sx={personAvatar} /> <Avatar alt={p.name} src={p.avatar} sx={personAvatar} />
<Typography sx={personName} variant="h5"> <Typography sx={personName} variant="h5">
{p.name} {p.name}
</Typography> </Typography>
</Container> </Container>
))} ))
) : (
<Container sx={emptyStateContainer} disableGutters>
<p>Nenhum professor encontrado!</p>
</Container>
)}
</Stack> </Stack>
</Container> </Container>
@ -91,16 +99,20 @@ function PeopleTab({ layoutType, peopleTabData }) {
Discentes Discentes
</Typography> </Typography>
<Stack alignItems="center"> <Stack alignItems="center">
{people {students.length !== 0 ? (
.filter(p => p.role === 'STUDENT') students.map(p => (
.map(p => (
<Container key={p.id} sx={personContainer} disableGutters> <Container key={p.id} sx={personContainer} disableGutters>
<Avatar alt={p.name} src={p.avatar} sx={personAvatar} /> <Avatar alt={p.name} src={p.avatar} sx={personAvatar} />
<Typography sx={personName} variant="h5"> <Typography sx={personName} variant="h5">
{p.name} {p.name}
</Typography> </Typography>
</Container> </Container>
))} ))
) : (
<Container sx={emptyStateContainer} disableGutters>
<p>Nenhum estudante encontrado!</p>
</Container>
)}
</Stack> </Stack>
</Container> </Container>
</Container> </Container>
@ -164,6 +176,9 @@ function PeopleTab({ layoutType, peopleTabData }) {
</Container> </Container>
); );
case 'idle': case 'idle':
const professors = people.filter(p => p.role === 'PROFESSOR');
const students = people.filter(p => p.role === 'STUDENT');
return ( return (
<Container sx={externalContainer} disableGutters> <Container sx={externalContainer} disableGutters>
<Container sx={sectionContainer} disableGutters> <Container sx={sectionContainer} disableGutters>
@ -171,16 +186,20 @@ function PeopleTab({ layoutType, peopleTabData }) {
Docentes Docentes
</Typography> </Typography>
<Stack alignItems="center"> <Stack alignItems="center">
{people {professors.length !== 0 ? (
.filter(p => p.role === 'PROFESSOR') professors.map(p => (
.map(p => (
<Container key={p.id} sx={personContainer} disableGutters> <Container key={p.id} sx={personContainer} disableGutters>
<Avatar alt={p.name} src={p.avatar} sx={personAvatar} /> <Avatar alt={p.name} src={p.avatar} sx={personAvatar} />
<Typography sx={personName} variant="body1"> <Typography sx={personName} variant="body1">
{p.name} {p.name}
</Typography> </Typography>
</Container> </Container>
))} ))
) : (
<Container sx={emptyStateContainer} disableGutters>
<p>Nenhum professor encontrado!</p>
</Container>
)}
</Stack> </Stack>
</Container> </Container>
@ -189,16 +208,20 @@ function PeopleTab({ layoutType, peopleTabData }) {
Discentes Discentes
</Typography> </Typography>
<Stack alignItems="center"> <Stack alignItems="center">
{people {students.length !== 0 ? (
.filter(p => p.role === 'STUDENT') students.map(p => (
.map(p => (
<Container key={p.id} sx={personContainer} disableGutters> <Container key={p.id} sx={personContainer} disableGutters>
<Avatar alt={p.name} src={p.avatar} sx={personAvatar} /> <Avatar alt={p.name} src={p.avatar} sx={personAvatar} />
<Typography sx={personName} variant="body1"> <Typography sx={personName} variant="body1">
{p.name} {p.name}
</Typography> </Typography>
</Container> </Container>
))} ))
) : (
<Container sx={emptyStateContainer} disableGutters>
<p>Nenhum estudante encontrado!</p>
</Container>
)}
</Stack> </Stack>
</Container> </Container>
</Container> </Container>

View file

@ -31,6 +31,12 @@ const desktopPersonAvatar = {
const desktopPersonName = {}; const desktopPersonName = {};
const desktopEmptyStateContainer = {
display: 'flex',
justifyContent: 'center',
marginTop: '30px',
};
const desktop = { const desktop = {
externalContainer: desktopExternalContainer, externalContainer: desktopExternalContainer,
sectionContainer: desktopSectionContainer, sectionContainer: desktopSectionContainer,
@ -38,6 +44,7 @@ const desktop = {
personContainer: desktopPersonContainer, personContainer: desktopPersonContainer,
personAvatar: desktopPersonAvatar, personAvatar: desktopPersonAvatar,
personName: desktopPersonName, personName: desktopPersonName,
emptyStateContainer: desktopEmptyStateContainer,
}; };
// ========== Mobile ========== // ========== Mobile ==========
@ -79,6 +86,12 @@ const mobilePersonName = {
WebkitBoxOrient: 'vertical', WebkitBoxOrient: 'vertical',
}; };
const mobileEmptyStateContainer = {
display: 'flex',
justifyContent: 'center',
marginTop: '30px',
};
const mobile = { const mobile = {
externalContainer: mobileExternalContainer, externalContainer: mobileExternalContainer,
sectionContainer: mobileSectionContainer, sectionContainer: mobileSectionContainer,
@ -86,6 +99,7 @@ const mobile = {
personContainer: mobilePersonContainer, personContainer: mobilePersonContainer,
personAvatar: mobilePersonAvatar, personAvatar: mobilePersonAvatar,
personName: mobilePersonName, personName: mobilePersonName,
emptyStateContainer: mobileEmptyStateContainer,
}; };
// ========== Unset ========== // ========== Unset ==========