Skip to content

Commit

Permalink
Merge branch 'merge_problems_fix' of https://github.com/SELab-2/UGent-4
Browse files Browse the repository at this point in the history
… into merge_problems_fix
  • Loading branch information
gusvanpoucke committed May 20, 2024
2 parents 9cb42df + ea950d4 commit 13760ea
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 53 deletions.
1 change: 1 addition & 0 deletions frontend/frontend/src/components/CourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function CourseCard({
const [course, setCourse] = useState<Course>({
vak_id: 0,
naam: '',
jaartal: 0,
studenten: [],
lesgevers: [],
gearchiveerd: false,
Expand Down
2 changes: 1 addition & 1 deletion frontend/frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const Header = ({ variant, title }: Props) => {
>
{variant === 'main' && (
<Box
id='logo'
id="logo"
component="img"
src={'assets/logo_duif_top_wit.png'}
alt="logo_app"
Expand Down
17 changes: 6 additions & 11 deletions frontend/frontend/src/components/RestrictionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { restriction } from '../pages/addChangeAssignmentPage/AddChangeAssignmen
import { Box, IconButton, Switch, Typography } from '@mui/material'
import CloseIcon from '@mui/icons-material/Close'
import React from 'react'
import {EvenlySpacedRow} from "./CustomComponents.tsx";

interface RestrictionCardProps {
restriction: restriction
Expand All @@ -28,26 +29,20 @@ export function RestrictionCard({

return (
<>
<Box
display={'flex'}
flexDirection={'row'}
width={'100%'}
justifyContent={'space-between'}
>
<EvenlySpacedRow items={[
<Typography id="script" variant={'body2'}>
{restriction.script.replace(/^.*[\\/]/, '')}
</Typography>
</Typography>,
<Switch
id="mustPassSwitch"
value={mustPass}
checked={mustPass}
onChange={() => handleMustPassChange()}
/>

/>,
<IconButton id="closeButton" onClick={handleRemove}>
<CloseIcon />
</IconButton>
</Box>
</IconButton>]}
/>
</>
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card } from '../../components/CustomComponents.tsx'
import {Card, Divider, EvenlySpacedRow} from '../../components/CustomComponents.tsx'
import {
Box,
CircularProgress,
Expand Down Expand Up @@ -539,7 +539,7 @@ export function AddChangeAssignmentPage() {
) : (
<TextField
type="text"
placeholder={'Title'}
placeholder={t('name')}
error={
assignmentErrors.title
}
Expand Down Expand Up @@ -809,37 +809,40 @@ export function AddChangeAssignmentPage() {
>
<Card
sx={{
padding: 1,
backgroundColor:
'background.default',
width: '70%',
height: '28svh',
}}
>
<Box
sx={{
backgroundColor: 'secondary.main',
height: 48,
padding: 1,
}}
>
<Typography
variant={'h5'}
fontWeight={'bold'}
>
{t('restrictions')}
</Typography>
<Box sx={{ padding: 1 }}>
<Box
display="flex"
flexDirection="row"
justifyContent="space-between"
sx={{ padding: 1 }}
>
<Typography variant="body1">
<EvenlySpacedRow items={[
<Typography variant="body1" fontWeight={'bold'}>
{t('name')}
</Typography>
<Typography variant="body1">
</Typography>,
<Typography variant="body1" fontWeight={'bold'}>
{t('must_pass')}
</Typography>
<Typography variant="body1">
</Typography>,
<Typography variant="body1" fontWeight={'bold'}>
{t('remove')}
</Typography>
</Box>
{/*This list will render the restrictions that are added to the assignment.*/}
</Typography>]}
/>
</Box>
<Divider/>
{/*This list will render the restrictions that are added to the assignment.*/}
<Box sx={{marginTop: -1.1}}>
<List
sx={{
maxHeight: '18vh',
Expand All @@ -858,23 +861,26 @@ export function AddChangeAssignmentPage() {
index
) => {
return (
<ListItem
key={
index
}
>
<RestrictionCard
restriction={
restriction
}
restrictions={
restrictions
}
setRestrictions={
setRestrictions
<>
<Divider/>
<ListItem sx={{ maxHeight: '45px'}}
key={
index
}
/>
</ListItem>
>
<RestrictionCard
restriction={
restriction
}
restrictions={
restrictions
}
setRestrictions={
setRestrictions
}
/>
</ListItem>
</>
)
}
)}
Expand Down
29 changes: 23 additions & 6 deletions frontend/frontend/src/pages/mainPage/MainPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Header } from '../../components/Header.tsx'
import { Button } from '../../components/CustomComponents.tsx'
import { Box, Stack } from '@mui/material'
import { Box, Stack, MenuItem, Select } from '@mui/material'
import TabSwitcher from '../../components/TabSwitcher.tsx'
import { ArchivedView } from './ArchivedView.tsx'
import { CoursesView } from './CoursesView.tsx'
Expand All @@ -17,6 +17,7 @@ import WarningPopup from '../../components/WarningPopup.tsx'
export interface Course {
vak_id: number
naam: string
jaartal: number
studenten: number[]
lesgevers: number[]
gearchiveerd: boolean
Expand Down Expand Up @@ -50,15 +51,13 @@ export default function MainPage() {
const [courseOrder, setCourseOrder] = useState<number[]>([])
const [deadlines, setDeadlines] = useState<Dayjs[]>([])
const [loading, setLoading] = useState<boolean>(true)
const [selectedYear, setSelectedYear] = useState<number>(dayjs().year())

//navigator for routing
const [assignments, setAssignments] = useState<project[]>([])
const navigator = useNavigate()

useEffect(() => {
console.log('requesting api')
//set loading to true every time the data is requested

// Get the courses, their projects, and their respective deadlines + the role of the user
async function fetchData() {
//set loading to true every time the data is requested
Expand Down Expand Up @@ -233,7 +232,7 @@ export default function MainPage() {
activecourses={courses
.filter(
(course) =>
!course.gearchiveerd
!course.gearchiveerd && course.jaartal === selectedYear
)
.sort((a: Course, b: Course) => {
if (
Expand Down Expand Up @@ -321,7 +320,25 @@ export default function MainPage() {
]
}
/>

<Box
display={'flex'}
justifyContent={'center'}
alignItems={'center'}
mb={2}
>
<Select
value={selectedYear}
onChange={(e) => setSelectedYear(e.target.value as number)}
label="Select Academic Year"
sx={{ minWidth: 150 }}
>
{[2022, 2023, 2024, 2025].map((year) => (
<MenuItem key={year} value={year}>
{year}
</MenuItem>
))}
</Select>
</Box>
{/* Add a calendar to the right of the mainpage. */}
<Box
aria-label={'calendarView'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ function UserList(
return (
<>
<Divider />
<ListItem>
<ListItem
disabled={
users.length == 1 &&
users[0].is_lesgever
}
>
<EvenlySpacedRow
items={[
<ListItemText
Expand Down Expand Up @@ -491,6 +496,9 @@ export function AddChangeSubjectPage() {
async function fetchUser() {
setUserLoading(true)
const userResponse = await instance.get('/gebruikers/me/')
if (vakID == undefined) {
setTeachers([userResponse.data])
}
setUser(userResponse.data)
setUserLoading(false)
}
Expand Down

0 comments on commit 13760ea

Please sign in to comment.