Merge from develop into new commit
This commit is contained in:
parent
6ae0854fb9
commit
df7e2a02d1
@ -69,7 +69,7 @@ def create_project_supervisor(data: dict) -> dict:
|
|||||||
db.session.add(project_supervisor)
|
db.session.add(project_supervisor)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
return {"message": "Project Supervisor was created!"}
|
return {"message": "Project Supervisor was created!", "id": project_supervisor.id}
|
||||||
|
|
||||||
|
|
||||||
@bp.get("/<int:id>/detail")
|
@bp.get("/<int:id>/detail")
|
||||||
|
@ -52,7 +52,7 @@ class StudentEditSchema(ma.Schema):
|
|||||||
|
|
||||||
class MessageSchema(ma.Schema):
|
class MessageSchema(ma.Schema):
|
||||||
message = fields.Str(required=True)
|
message = fields.Str(required=True)
|
||||||
|
id = fields.Str(required=False)
|
||||||
|
|
||||||
class FileSchema(ma.Schema):
|
class FileSchema(ma.Schema):
|
||||||
file = fields.Raw(type='file', required=True)
|
file = fields.Raw(type='file', required=True)
|
||||||
|
@ -71,8 +71,11 @@ function App() {
|
|||||||
<Route path="supervisor" element={<Supervisor />}>
|
<Route path="supervisor" element={<Supervisor />}>
|
||||||
<Route index element={<Navigate to="groups" />} />
|
<Route index element={<Navigate to="groups" />} />
|
||||||
<Route path="groups" element={<SupervisorGroups />} />
|
<Route path="groups" element={<SupervisorGroups />} />
|
||||||
|
<Route path="groups/:id" element={<Group />} />
|
||||||
|
<Route path="groups/:id/grade-card" element={<GradeCard />} />
|
||||||
<Route path="schedule" element={<SupervisorSchedules />} />
|
<Route path="schedule" element={<SupervisorSchedules />} />
|
||||||
<Route path="schedule/:id" element={<SupervisorSchedule />} />
|
<Route path="schedule/:id" element={<SupervisorSchedule />} />
|
||||||
|
<Route path="add-group" element={<AddGroup />} />
|
||||||
</Route>
|
</Route>
|
||||||
</Routes>
|
</Routes>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
|
@ -12,7 +12,7 @@ export interface Leader {
|
|||||||
first_name: string
|
first_name: string
|
||||||
last_name: string
|
last_name: string
|
||||||
email: string
|
email: string
|
||||||
limit_group: number
|
limit_group?: number
|
||||||
count_groups: number
|
count_groups: number
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,3 +36,13 @@ export const createLeader = (payload: Partial<Leader>) =>
|
|||||||
|
|
||||||
export const deleteLeader = (id: number) =>
|
export const deleteLeader = (id: number) =>
|
||||||
axiosInstance.delete(`coordinator/project_supervisor/${id}/`)
|
axiosInstance.delete(`coordinator/project_supervisor/${id}/`)
|
||||||
|
|
||||||
|
export const addLeaderToGroup = (
|
||||||
|
id: number,
|
||||||
|
year_group_id: number,
|
||||||
|
payload: { limit_group: number },
|
||||||
|
) =>
|
||||||
|
axiosInstance.post(
|
||||||
|
`coordinator/project_supervisor/${id}/year-group/${year_group_id}`,
|
||||||
|
payload,
|
||||||
|
)
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { useForm } from 'react-hook-form'
|
import { useForm } from 'react-hook-form'
|
||||||
import { useMutation } from 'react-query'
|
import { useMutation } from 'react-query'
|
||||||
import { createLeader, Leader } from '../../api/leaders'
|
import useLocalStorageState from 'use-local-storage-state'
|
||||||
|
import { addLeaderToGroup, createLeader, Leader } from '../../api/leaders'
|
||||||
import InputError from '../../components/InputError'
|
import InputError from '../../components/InputError'
|
||||||
|
|
||||||
const AddLeader = () => {
|
const AddLeader = () => {
|
||||||
@ -11,18 +12,35 @@ const AddLeader = () => {
|
|||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { errors },
|
formState: { errors },
|
||||||
reset,
|
reset,
|
||||||
|
getValues,
|
||||||
} = useForm<Leader>()
|
} = useForm<Leader>()
|
||||||
|
const [yearGroupId] = useLocalStorageState('yearGroupId')
|
||||||
|
|
||||||
const { mutate: mutateCreateLeader } = useMutation(
|
const { mutate: mutateCreateLeader } = useMutation(
|
||||||
'createLeader',
|
'createLeader',
|
||||||
(payload: Leader) => createLeader(payload),
|
(payload: Leader) => {
|
||||||
|
delete payload.limit_group
|
||||||
|
return createLeader(payload)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
onSuccess: () => {
|
onSuccess: (data) => {
|
||||||
reset()
|
|
||||||
setIsAlertVisible(true)
|
setIsAlertVisible(true)
|
||||||
|
mutateAddToYearGroup({
|
||||||
|
id: data?.data?.id,
|
||||||
|
year_group_id: Number(yearGroupId),
|
||||||
|
limit_group: getValues('limit_group') ?? 0,
|
||||||
|
})
|
||||||
|
reset()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
const { mutate: mutateAddToYearGroup } = useMutation(
|
||||||
|
'addLeaderToGroup',
|
||||||
|
(payload: { id: any; year_group_id: number; limit_group: number }) =>
|
||||||
|
addLeaderToGroup(payload.id, payload.year_group_id, {
|
||||||
|
limit_group: payload.limit_group,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
const onSubmit = (data: Leader) => {
|
const onSubmit = (data: Leader) => {
|
||||||
mutateCreateLeader(data)
|
mutateCreateLeader(data)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { useMutation, useQuery } from 'react-query'
|
import { useMutation, useQuery } from 'react-query'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useLocation, useNavigate } from 'react-router-dom'
|
||||||
import useLocalStorageState from 'use-local-storage-state'
|
import useLocalStorageState from 'use-local-storage-state'
|
||||||
import { deleteGroup, getGroups } from '../../api/groups'
|
import { deleteGroup, getGroups } from '../../api/groups'
|
||||||
import { ReactComponent as IconRemove } from '../../assets/svg/icon-remove.svg'
|
import { ReactComponent as IconRemove } from '../../assets/svg/icon-remove.svg'
|
||||||
@ -9,6 +9,8 @@ import { Link } from 'react-router-dom'
|
|||||||
|
|
||||||
const Groups = () => {
|
const Groups = () => {
|
||||||
let navigate = useNavigate()
|
let navigate = useNavigate()
|
||||||
|
const location = useLocation()
|
||||||
|
|
||||||
const [page, setPage] = useState(1)
|
const [page, setPage] = useState(1)
|
||||||
const [perPage, setPerPage] = useState(10)
|
const [perPage, setPerPage] = useState(10)
|
||||||
const [yearGroupId] = useLocalStorageState('yearGroupId')
|
const [yearGroupId] = useLocalStorageState('yearGroupId')
|
||||||
@ -60,7 +62,15 @@ const Groups = () => {
|
|||||||
<div className="flex items-center justify-between flex-col gap-3 md:flex-row md:gap-0">
|
<div className="flex items-center justify-between flex-col gap-3 md:flex-row md:gap-0">
|
||||||
<button
|
<button
|
||||||
className="btn btn-success"
|
className="btn btn-success"
|
||||||
onClick={() => navigate('/coordinator/add-group')}
|
onClick={() =>
|
||||||
|
navigate(
|
||||||
|
`/${
|
||||||
|
location.pathname.includes('coordinator')
|
||||||
|
? 'coordinator'
|
||||||
|
: 'supervisor'
|
||||||
|
}/add-group`,
|
||||||
|
)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Dodaj nową grupę
|
Dodaj nową grupę
|
||||||
</button>
|
</button>
|
||||||
@ -97,7 +107,11 @@ const Groups = () => {
|
|||||||
<tr key={id}>
|
<tr key={id}>
|
||||||
<td>
|
<td>
|
||||||
<Link
|
<Link
|
||||||
to={`/coordinator/groups/${id}`}
|
to={`/${
|
||||||
|
location.pathname.includes('coordinator')
|
||||||
|
? 'coordinator'
|
||||||
|
: 'supervisor'
|
||||||
|
}/groups/${id}`}
|
||||||
className="underline font-bold"
|
className="underline font-bold"
|
||||||
>
|
>
|
||||||
{name}
|
{name}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { useQuery } from 'react-query'
|
import { useQuery } from 'react-query'
|
||||||
import { Link, useParams } from 'react-router-dom'
|
import { Link, useLocation, useParams } from 'react-router-dom'
|
||||||
import { getGroup } from '../../api/groups'
|
import { getGroup } from '../../api/groups'
|
||||||
|
|
||||||
const Group = () => {
|
const Group = () => {
|
||||||
const { id } = useParams<{ id: string }>()
|
const { id } = useParams<{ id: string }>()
|
||||||
|
const location = useLocation()
|
||||||
|
|
||||||
const { data: groups } = useQuery(['getGroup'], () => getGroup(Number(id)))
|
const { data: groups } = useQuery(['getGroup'], () => getGroup(Number(id)))
|
||||||
const { name, project_supervisor } = groups?.data || {}
|
const { name, project_supervisor } = groups?.data || {}
|
||||||
@ -15,7 +16,13 @@ const Group = () => {
|
|||||||
Opiekun: {project_supervisor?.first_name}{' '}
|
Opiekun: {project_supervisor?.first_name}{' '}
|
||||||
{project_supervisor?.last_name}
|
{project_supervisor?.last_name}
|
||||||
</h2>
|
</h2>
|
||||||
<Link to={`/coordinator/groups/${id}/grade-card`}>
|
<Link
|
||||||
|
to={`/${
|
||||||
|
location.pathname.includes('coordinator')
|
||||||
|
? 'coordinator'
|
||||||
|
: 'supervisor'
|
||||||
|
}/groups/${id}/grade-card`}
|
||||||
|
>
|
||||||
<button className="btn btn-success mt-2">KARTA OCENY</button>
|
<button className="btn btn-success mt-2">KARTA OCENY</button>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user