Skip to content

Commit a58020a

Browse files
Shaurya MagoShaurya Mago
authored andcommitted
create course
1 parent 9a5ab33 commit a58020a

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

src/Components/CreateCourseDialog/CreateCourseDialog.tsx

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ const LargeTextField = styled(TextField)`
1919
font-size: 20px;
2020
}
2121
`;
22+
const SmallTextField = styled(TextField)`
23+
input {
24+
height: 30px;
25+
font-size: 20px;
26+
}
27+
`;
28+
function refreshPage() {
29+
window.location.reload(false);
30+
}
2231

2332
function CreateCourseDialog() {
2433
const [open, setOpen] = useState(false);
@@ -56,7 +65,7 @@ function CreateCourseDialog() {
5665
initialValues={{
5766
courseTitle: '',
5867
courseDescription: '',
59-
instructor: 'currentUser',
68+
courseInstructor: '',
6069
}}
6170
onSubmit={(values, { setSubmitting }) => {
6271
setTimeout(() => {
@@ -65,10 +74,10 @@ function CreateCourseDialog() {
6574
addCourse({
6675
variables: {
6776
course: {
68-
name: values.courseTitle,
77+
course: values.courseTitle,
6978
description: values.courseDescription,
70-
instructor: 'Mr. Butcher',
71-
missions: [],
79+
instructor: values.courseInstructor,
80+
// missions: [],
7281
},
7382
},
7483
}).catch((error) => console.log(error));
@@ -77,7 +86,7 @@ function CreateCourseDialog() {
7786
>
7887
{({ values, handleChange, handleBlur, handleSubmit, isSubmitting }) => (
7988
<form onSubmit={handleSubmit}>
80-
<LargeTextField
89+
<SmallTextField
8190
id="courseTitle"
8291
label="Course Title"
8392
type="text"
@@ -100,12 +109,27 @@ function CreateCourseDialog() {
100109
onChange={handleChange}
101110
onBlur={handleBlur}
102111
/>
103-
112+
<SmallTextField
113+
id="instructor"
114+
label="Instructor"
115+
type="text"
116+
fullWidth
117+
variant="outlined"
118+
margin="dense"
119+
value={values.courseInstructor}
120+
onChange={handleChange}
121+
onBlur={handleBlur}
122+
/>
104123
<DialogActions>
105124
<Button onClick={handleClose} color="primary">
106125
Cancel
107126
</Button>
108-
<Button type="submit" disabled={isSubmitting} color="primary">
127+
<Button
128+
type="submit"
129+
onClick={refreshPage}
130+
disabled={isSubmitting}
131+
color="primary"
132+
>
109133
Create
110134
</Button>
111135
</DialogActions>

src/Components/Dashboard/Dashboard.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CourseInfoFieldsFragment, useGetCoursesQuery } from '../../__generated__/types';
22
import CourseCard from './CourseCard';
3+
import CreateCourseDialog from '../CreateCourseDialog/CreateCourseDialog';
34
import './DashBoard.css';
45

56
function Dashboard() {
@@ -17,7 +18,8 @@ function Dashboard() {
1718
const { courseInfos } = data;
1819

1920
return (
20-
<div className="dashboard-container">
21+
<div>
22+
<CreateCourseDialog />
2123
{courseInfos.map((courseInfo: CourseInfoFieldsFragment) => (
2224
<CourseCard key={courseInfo.courseId} courseInfo={courseInfo} />
2325
))}

src/queries/course-queries.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import { gql } from '@apollo/client';
22

33
export const SAVE_COURSE = gql`
44
mutation AddCourse($course: CourseInput!) {
5-
addCourse(course: $course) {
6-
id
7-
name
8-
}
5+
addCourse(course: $course)
96
}
107
`;

0 commit comments

Comments
 (0)