-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* teacher detailed course base project list * basic * scrollers * doc * backtick strings * base all courses page * changed height * first finished version of teacher course views * teacher all course page reviewed * display time until deadline * more searchbars and translations * changed file structure for maintainability * titles and absolute create button * searchbars update url and remain on reload * user and admin listing * reworked form and gave unique ids to all list items * whoops linter ssst * added .env to gitignore * placeholder for loading courses * debounce seachbars * better debouncing more hooks * setup for loader but doesnt work yet bc bad router * loaders * course detail teacher course join codes menu * join code link points to app host now * accident * fixed empty filters, placeholders and teacher in admin list * delete * removed wannabe popup errorer * unuserud * package * fix * uhh * u
- Loading branch information
Showing
23 changed files
with
1,011 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ dist | |
dist-ssr | ||
*.local | ||
|
||
.env | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { Button, Dialog, DialogActions, DialogTitle, FormControl, FormHelperText, Grid, Input, InputLabel } from "@mui/material"; | ||
import { useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { SideScrollableCourses } from "./CourseUtilComponents"; | ||
import { Course, callToApiToCreateCourse } from "./CourseUtils"; | ||
import { Title } from "../Header/Title"; | ||
import { useLoaderData } from "react-router-dom"; | ||
|
||
/** | ||
* @returns A jsx component representing all courses for a teacher | ||
*/ | ||
export function AllCoursesTeacher(): JSX.Element { | ||
const [open, setOpen] = useState(false); | ||
const courses = (useLoaderData() as Course[]); | ||
|
||
const [courseName, setCourseName] = useState(''); | ||
const [error, setError] = useState(''); | ||
|
||
const navigate = useNavigate(); | ||
|
||
const { t } = useTranslation('translation', { keyPrefix: 'allCoursesTeacher' }); | ||
|
||
const handleClickOpen = () => { | ||
setOpen(true); | ||
}; | ||
|
||
const handleClose = () => { | ||
setOpen(false); | ||
}; | ||
|
||
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
setCourseName(event.target.value); | ||
setError(''); // Clearing error message when user starts typing | ||
}; | ||
|
||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault(); // Prevents the default form submission behaviour | ||
|
||
if (!courseName.trim()) { | ||
setError(t('emptyCourseNameError')); | ||
return; | ||
} | ||
|
||
const data = { name: courseName }; | ||
callToApiToCreateCourse(JSON.stringify(data), navigate); | ||
}; | ||
return ( | ||
<> | ||
<Title title={t('title')}></Title> | ||
<Grid container direction={'column'} style={{marginTop: '1rem', width:'100vw', height: '80vh'}}> | ||
<SideScrollableCourses courses={courses}></SideScrollableCourses> | ||
<Dialog open={open} onClose={handleClose}> | ||
<DialogTitle>{t('courseForm')}</DialogTitle> | ||
<form style={{ margin: "2rem" }} onSubmit={handleSubmit}> | ||
<FormControl> | ||
<InputLabel htmlFor="course-name">{t('courseName')}</InputLabel> | ||
<Input | ||
id="course-name" | ||
value={courseName} | ||
onChange={handleInputChange} | ||
error={!!error} | ||
aria-describedby="my-helper-text" | ||
/> | ||
{error && <FormHelperText id="my-helper-text">{error}</FormHelperText>} | ||
</FormControl> | ||
<DialogActions> | ||
<Button onClick={handleClose}>{t('cancel')}</Button> | ||
<Button type="submit">{t('submit')}</Button> | ||
</DialogActions> | ||
</form> | ||
</Dialog> | ||
<Grid item style={{position: "absolute", left: "2rem", bottom: "5rem"}}> | ||
<Button onClick={handleClickOpen} >{t('create')}</Button> | ||
</Grid> | ||
</Grid> | ||
</> | ||
); | ||
} |
Oops, something went wrong.