Add professor classroom people tab placeholder
This commit is contained in:
parent
7377defce8
commit
7a59fbc836
7 changed files with 67 additions and 12 deletions
|
@ -42,7 +42,7 @@ function Classroom() {
|
||||||
});
|
});
|
||||||
}, [userService, params.id]);
|
}, [userService, params.id]);
|
||||||
|
|
||||||
const fetchAndPopulatePoepleTabData = useCallback(async () => {
|
const fetchAndPopulatePeopleTabData = useCallback(async () => {
|
||||||
setTabData({ tab: 'people', state: 'loading' });
|
setTabData({ tab: 'people', state: 'loading' });
|
||||||
const people = await userService.fetchPeopleByClassId(params.id);
|
const people = await userService.fetchPeopleByClassId(params.id);
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ function Classroom() {
|
||||||
fetchAndPopulateAssignmentsTabData();
|
fetchAndPopulateAssignmentsTabData();
|
||||||
break;
|
break;
|
||||||
case TAB_OPTIONS.people.value:
|
case TAB_OPTIONS.people.value:
|
||||||
fetchAndPopulatePoepleTabData();
|
fetchAndPopulatePeopleTabData();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log('Invalid tab option');
|
console.log('Invalid tab option');
|
||||||
|
@ -75,7 +75,7 @@ function Classroom() {
|
||||||
params,
|
params,
|
||||||
fetchAndPopulateAnnouncementsTabData,
|
fetchAndPopulateAnnouncementsTabData,
|
||||||
fetchAndPopulateAssignmentsTabData,
|
fetchAndPopulateAssignmentsTabData,
|
||||||
fetchAndPopulatePoepleTabData,
|
fetchAndPopulatePeopleTabData,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
35
src/screens/professor/Classroom/PeopleTab/index.js
Normal file
35
src/screens/professor/Classroom/PeopleTab/index.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
function PeopleTab({ layoutType, peopleTabData }) {
|
||||||
|
const layoutResolver = (state, people, layoutType) => {
|
||||||
|
if (layoutType === 'desktop') {
|
||||||
|
switch (state) {
|
||||||
|
case 'loading':
|
||||||
|
return <h1>Loading...</h1>;
|
||||||
|
case 'idle':
|
||||||
|
return <h1>People Tab</h1>;
|
||||||
|
case 'gone':
|
||||||
|
return null;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else if (layoutType === 'mobile') {
|
||||||
|
switch (state) {
|
||||||
|
case 'loading':
|
||||||
|
return <h1>Loading...</h1>;
|
||||||
|
case 'idle':
|
||||||
|
return <h1>People Tab</h1>;
|
||||||
|
case 'gone':
|
||||||
|
return null;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return layoutResolver(
|
||||||
|
peopleTabData && peopleTabData.state,
|
||||||
|
peopleTabData && peopleTabData.people,
|
||||||
|
layoutType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PeopleTab;
|
0
src/screens/professor/Classroom/PeopleTab/styles.js
Normal file
0
src/screens/professor/Classroom/PeopleTab/styles.js
Normal file
|
@ -2,6 +2,7 @@ import { Container } from '@mui/system';
|
||||||
import AnnouncementsTab from './AnnouncementsTab';
|
import AnnouncementsTab from './AnnouncementsTab';
|
||||||
import AssignmentsTab from './AssignmentsTab';
|
import AssignmentsTab from './AssignmentsTab';
|
||||||
import Header from './Header';
|
import Header from './Header';
|
||||||
|
import PeopleTab from './PeopleTab';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
|
|
||||||
function View({
|
function View({
|
||||||
|
@ -11,6 +12,7 @@ function View({
|
||||||
onSelectTabOption,
|
onSelectTabOption,
|
||||||
announcementsTabData,
|
announcementsTabData,
|
||||||
assignmentsTabData,
|
assignmentsTabData,
|
||||||
|
peopleTabData,
|
||||||
isLoading,
|
isLoading,
|
||||||
}) {
|
}) {
|
||||||
const { container } = styles[layoutType];
|
const { container } = styles[layoutType];
|
||||||
|
@ -32,6 +34,7 @@ function View({
|
||||||
layoutType={layoutType}
|
layoutType={layoutType}
|
||||||
assignmentsTabData={assignmentsTabData}
|
assignmentsTabData={assignmentsTabData}
|
||||||
/>
|
/>
|
||||||
|
<PeopleTab layoutType={layoutType} peopleTabData={peopleTabData} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,17 @@ function Classroom() {
|
||||||
updateDocumentTitle();
|
updateDocumentTitle();
|
||||||
}, [userService, userService.fetchClassroomById, params, classroom]);
|
}, [userService, userService.fetchClassroomById, params, classroom]);
|
||||||
|
|
||||||
|
const fetchAndPopulatePeopleTabData = useCallback(async () => {
|
||||||
|
setTabData({ tab: 'people', state: 'loading' });
|
||||||
|
const people = await userService.fetchPeopleByClassId(params.id);
|
||||||
|
|
||||||
|
setTabData({
|
||||||
|
tab: 'people',
|
||||||
|
state: 'idle',
|
||||||
|
people: [...people.data],
|
||||||
|
});
|
||||||
|
}, [userService, params.id]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function getSelectedTabData() {
|
async function getSelectedTabData() {
|
||||||
switch (selectedTabOption) {
|
switch (selectedTabOption) {
|
||||||
|
@ -67,7 +78,7 @@ function Classroom() {
|
||||||
fetchAndPopulateAssignmentsTabData();
|
fetchAndPopulateAssignmentsTabData();
|
||||||
break;
|
break;
|
||||||
case TAB_OPTIONS.people.value:
|
case TAB_OPTIONS.people.value:
|
||||||
// TODO
|
fetchAndPopulatePeopleTabData();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log('Invalid tab option');
|
console.log('Invalid tab option');
|
||||||
|
@ -79,6 +90,7 @@ function Classroom() {
|
||||||
params,
|
params,
|
||||||
fetchAndPopulateAnnouncementsTabData,
|
fetchAndPopulateAnnouncementsTabData,
|
||||||
fetchAndPopulateAssignmentsTabData,
|
fetchAndPopulateAssignmentsTabData,
|
||||||
|
fetchAndPopulatePeopleTabData,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -93,6 +105,9 @@ function Classroom() {
|
||||||
assignmentsTabData={
|
assignmentsTabData={
|
||||||
tabData && tabData.tab === 'assignments' ? tabData : { state: 'gone' }
|
tabData && tabData.tab === 'assignments' ? tabData : { state: 'gone' }
|
||||||
}
|
}
|
||||||
|
peopleTabData={
|
||||||
|
tabData && tabData.tab === 'people' ? tabData : { state: 'gone' }
|
||||||
|
}
|
||||||
isLoading={tabData && tabData.state === 'loading'}
|
isLoading={tabData && tabData.state === 'loading'}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,4 +17,6 @@ export default class ProfessorService {
|
||||||
|
|
||||||
fetchClassroomAnnouncements = classId =>
|
fetchClassroomAnnouncements = classId =>
|
||||||
ProfessorApi.getClassroomAnnouncementsById(classId);
|
ProfessorApi.getClassroomAnnouncementsById(classId);
|
||||||
|
|
||||||
|
fetchPeopleByClassId = classId => ProfessorApi.getPeopleByClassId(classId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,14 @@ const CommonApi = {
|
||||||
data: allAssignments.filter(a => a.classrooms[0].id === classId),
|
data: allAssignments.filter(a => a.classrooms[0].id === classId),
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
getPeopleByClassId: classId =>
|
||||||
|
sleep(400).then(() => {
|
||||||
|
console.log('Getting people by class id ' + classId);
|
||||||
|
return {
|
||||||
|
data: allPeople.filter(p => p.classes[0].id === classId),
|
||||||
|
};
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
const StudentApi = {
|
const StudentApi = {
|
||||||
|
@ -101,14 +109,6 @@ const StudentApi = {
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
|
||||||
getPeopleByClassId: classId =>
|
|
||||||
sleep(400).then(() => {
|
|
||||||
console.log('Getting people by class id ' + classId);
|
|
||||||
return {
|
|
||||||
data: allPeople.filter(p => p.classes[0].id === classId),
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
|
|
||||||
getFaq: () =>
|
getFaq: () =>
|
||||||
sleep(300).then(() => {
|
sleep(300).then(() => {
|
||||||
console.log('Fetching FAQ...');
|
console.log('Fetching FAQ...');
|
||||||
|
|
Loading…
Reference in a new issue