Skip to content

Commit 40b5e68

Browse files
committed
Merge branch 'bubblegum' of https://github.com/usingbrain/QRcheckd into bubblegum
2 parents 59978fb + 4cf7b3d commit 40b5e68

5 files changed

Lines changed: 29 additions & 49 deletions

File tree

client/src/Components/ClassView/ClassView.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { setSelected, setHistory } from '../../store/actions';
55
import Course from '../../Types/course';
66
import { ReactComponent as CloseBtn } from '../../Assets/window-close-regular.svg';
77
import ClassDashboard from './ClassDashboard';
8-
import Overview from '../Calendar/Overview';
98
import User from '../../Types/user';
10-
import DeleteBtn from './DeleteBtn';
119

1210
const headerStyle =
1311
'bg-black text-white flex flex-row justify-between items-center content-center p-8 h-20 mb-4 text-3xl';

client/src/Components/ClassView/DeleteBtn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from 'react';
1+
import React, { useState } from 'react';
22
import { useSelector, useDispatch } from 'react-redux';
33
import { useNavigate } from 'react-router';
44
import { useDeleteCourseMutation } from '../../generated/graphql';
Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,31 @@
1-
import React, { useState, useEffect } from 'react';
2-
import { useSelector, useDispatch } from 'react-redux';
3-
import { setCourses } from '../../store/actions';
1+
import React from 'react';
2+
import { useSelector } from 'react-redux';
43
import { Link } from 'react-router-dom';
54
import Course from './Course';
6-
import { useCoursesQuery } from '../../generated/graphql';
75
import CourseType from '../../Types/course';
86

97
const listStyle = 'w-full text-left';
108

119
const CourseList: React.FC = () => {
12-
const dispatch = useDispatch();
13-
const [{ fetching, data, error }] = useCoursesQuery({ variables: {} });
14-
const courses = data?.getCourses?.data;
15-
1610
const coursesState = useSelector(
17-
(state: { courses: CourseType[] | null }) => state.courses // initialze with empty array instead of null
11+
(state: { courses: CourseType[] | null }) => state.courses // TODO: initialze with empty array instead of null
1812
);
19-
// const [state, setState] = useState(coursesState);
20-
21-
// useEffect(() => {
22-
// setState(coursesState);
23-
// }, [coursesState]);
24-
25-
useEffect(() => {
26-
if (courses) {
27-
// @ts-ignore
28-
dispatch(setCourses(courses));
29-
}
30-
}, []);
31-
32-
if (fetching) {
33-
} // TODO handle fetching
34-
if (error) {
35-
} // TODO handle error
36-
37-
// if (courses) {
38-
// // @ts-ignore
39-
// dispatch(setCourses(courses));
4013

4114
return (
4215
<div className={listStyle}>
43-
{
16+
{!!coursesState &&
4417
// useredux state here instead of DB response
45-
coursesState!.map((course) => {
18+
coursesState.map((course) => {
4619
return (
4720
<article key={course?.id}>
4821
<Link to={`/homepage/classes/${course?.id}`}>
4922
{!!course && <Course course={course} />}
5023
</Link>
5124
</article>
5225
);
53-
})
54-
}
26+
})}
5527
</div>
5628
);
5729
};
5830

59-
// return <article></article>;
60-
// };
61-
6231
export default CourseList;

client/src/Components/TeacherHomepage/Homepage.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
import React from 'react';
2-
import { useSelector } from 'react-redux';
2+
import { useSelector, useDispatch } from 'react-redux';
33
import { Outlet } from 'react-router-dom';
44
import Sidemenu from '../TeacherDashboard/Sidemenu';
55
import Navbar from './Navbar';
6-
import User from '../../Types/user';
76
import Course from '../../Types/course';
87
import Instruction from './Instruction';
8+
import { useCoursesQuery } from '../../generated/graphql';
9+
import { setCourses } from '../../store/actions';
910

1011
const Homepage: React.FC = () => {
12+
const dispatch = useDispatch();
13+
const [{ fetching, data, error }] = useCoursesQuery({ variables: {} });
14+
const courses = data?.getCourses?.data;
15+
16+
if (fetching) {
17+
} // TODO handle fetching
18+
if (error) {
19+
} // TODO handle error
20+
if (courses) {
21+
// @ts-ignore
22+
dispatch(setCourses(courses));
23+
}
24+
1125
const selectedCourse = useSelector(
1226
(state: { selectedCourse: Course | null }) => state.selectedCourse
1327
);
1428

1529
return (
1630
<div>
1731
<Navbar />
18-
<main className='flex flex-row justify-start w-full h-screen'>
32+
<main className="flex flex-row justify-start w-full">
1933
<Sidemenu />
2034
{selectedCourse ? <Outlet /> : <Instruction />}
2135
</main>

client/src/Components/TeacherHomepage/Navbar.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import { Link } from 'react-router-dom';
3-
import User from '../../Types/user';
43
import { useNavigate } from 'react-router';
54
import { useLogoutMutation, useMeQuery } from '../../generated/graphql';
65
import { ReactComponent as QRLogo } from '../../Assets/thePerfectestLogo2.svg';
@@ -20,14 +19,14 @@ const Navbar: React.FC = () => {
2019
};
2120
return (
2221
<nav className={navStyle}>
23-
<Link to='/'>
24-
<QRLogo className='w-48 flex' />
22+
<Link to="/">
23+
<QRLogo className="w-48 flex" />
2524
</Link>
26-
<section className='flex flex-row items-center'>
27-
<h3 className='pr-8 font-lato font-bold text-lg'>
25+
<section className="flex flex-row items-center">
26+
<h3 className="pr-8 font-lato font-bold text-lg">
2827
{data?.me?.name} {data?.me?.lastname}
2928
</h3>
30-
<button onClick={handleLogout} className='font-normal hover:text-green'>
29+
<button onClick={handleLogout} className="font-normal hover:text-green">
3130
Logout
3231
</button>
3332
</section>

0 commit comments

Comments
 (0)