Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge problems fix #303

Merged
merged 5 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions frontend/frontend/src/pages/groupsPage/GroupsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from '@mui/material'
import Switch from '@mui/material/Switch'
import { t } from 'i18next'
import { FormEvent, useEffect, useState } from 'react'
import { FormEvent, useEffect, useState, ChangeEvent } from 'react'
import { useNavigate, useParams } from 'react-router-dom'
import instance from '../../axiosConfig.ts'
import CancelIcon from '@mui/icons-material/Cancel'
Expand Down Expand Up @@ -65,6 +65,7 @@ export function GroupsPage() {
const [projectName, setProjectName] = useState('')
const [user, setUser] = useState<User>()
const [max_group_size, setMaxGroupSize] = useState(0)
const [studentsCanChoose, setStudentsCanChoose] = useState(false)

// confirmation dialog state
const [confirmOpen, setConfirmOpen] = useState(false)
Expand All @@ -78,6 +79,10 @@ export function GroupsPage() {

// handle confirmation dialog
const confirmSave = async () => {
await instance.patch('/projecten/' + assignmentId + '/', {
student_groep: studentsCanChoose,
})

if (newGroups[0].groep_id === undefined) {
// delete the old groups and replace them with the new groups
await instance
Expand Down Expand Up @@ -176,13 +181,15 @@ export function GroupsPage() {
console.error(error)
})

// Get the max group size and project name
// Get the max group size, project name and students can choose
await instance
.get('/projecten/' + assignmentId)
.then((response) => {
setProjectName(response.data.titel)
setStudentsCanChoose(response.data.student_groep)

setMaxGroupSize(response.data.max_groep_grootte)
setStudentChoose(response.data.student_groep)
})
.catch((error) => {
console.log(error)
Expand Down Expand Up @@ -470,7 +477,19 @@ export function GroupsPage() {
}}
/>
) : (
<Switch />
<Switch
checked={
studentsCanChoose
}
value={
studentsCanChoose
}
onChange={() =>
setStudentsCanChoose(
!studentsCanChoose
)
}
/>
)}
</Box>
</Stack>
Expand Down
30 changes: 21 additions & 9 deletions frontend/frontend/src/pages/subjectsPage/SubjectsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,21 +322,33 @@ export function SubjectsPage() {
)}
</Box>
<Box
paddingLeft={'10px'}
paddingLeft="10px"
display="flex"
flexDirection="row"
justifyContent="space-between"
alignItems="center"
sx={{ width: '100%', height: '30%' }}
>
<CopyToClipboard
invitationLink={
window.location.href +
'/accept_invitation'
}
/>
<Tooltip
<Box sx={{ paddingLeft: '20px', display: 'flex', alignItems: 'center', gap: 2 }}>
<StudentPopUp
students={studentsLoading ? [] : students}
text="students"
noGroup={false}
/>
<CopyToClipboard
invitationLink={`${window.location.href}/accept_invitation`}
/>
</Box>
<Box>
</Box>
<Tooltip
title={t('add_project')}
placement={'top'}
placement={'top'}>
<IconButton
onClick={addProject}
color="primary"
edge="end"
aria-label="add-project"
>
<IconButton
onClick={addProject}
Expand Down
Loading