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.commit()
|
||||
|
||||
return {"message": "Project Supervisor was created!"}
|
||||
return {"message": "Project Supervisor was created!", "id": project_supervisor.id}
|
||||
|
||||
|
||||
@bp.get("/<int:id>/detail")
|
||||
|
@ -52,7 +52,7 @@ class StudentEditSchema(ma.Schema):
|
||||
|
||||
class MessageSchema(ma.Schema):
|
||||
message = fields.Str(required=True)
|
||||
|
||||
id = fields.Str(required=False)
|
||||
|
||||
class FileSchema(ma.Schema):
|
||||
file = fields.Raw(type='file', required=True)
|
||||
|
@ -71,8 +71,11 @@ function App() {
|
||||
<Route path="supervisor" element={<Supervisor />}>
|
||||
<Route index element={<Navigate to="groups" />} />
|
||||
<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/:id" element={<SupervisorSchedule />} />
|
||||
<Route path="add-group" element={<AddGroup />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</QueryClientProvider>
|
||||
|
@ -12,7 +12,7 @@ export interface Leader {
|
||||
first_name: string
|
||||
last_name: string
|
||||
email: string
|
||||
limit_group: number
|
||||
limit_group?: number
|
||||
count_groups: number
|
||||
}
|
||||
|
||||
@ -36,3 +36,13 @@ export const createLeader = (payload: Partial<Leader>) =>
|
||||
|
||||
export const deleteLeader = (id: number) =>
|
||||
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 { useForm } from 'react-hook-form'
|
||||
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'
|
||||
|
||||
const AddLeader = () => {
|
||||
@ -11,18 +12,35 @@ const AddLeader = () => {
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
reset,
|
||||
getValues,
|
||||
} = useForm<Leader>()
|
||||
const [yearGroupId] = useLocalStorageState('yearGroupId')
|
||||
|
||||
const { mutate: mutateCreateLeader } = useMutation(
|
||||
'createLeader',
|
||||
(payload: Leader) => createLeader(payload),
|
||||
(payload: Leader) => {
|
||||
delete payload.limit_group
|
||||
return createLeader(payload)
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
reset()
|
||||
onSuccess: (data) => {
|
||||
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) => {
|
||||
mutateCreateLeader(data)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import classNames from 'classnames'
|
||||
import { useEffect, useState } from 'react'
|
||||
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 { deleteGroup, getGroups } from '../../api/groups'
|
||||
import { ReactComponent as IconRemove } from '../../assets/svg/icon-remove.svg'
|
||||
@ -9,6 +9,8 @@ import { Link } from 'react-router-dom'
|
||||
|
||||
const Groups = () => {
|
||||
let navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
|
||||
const [page, setPage] = useState(1)
|
||||
const [perPage, setPerPage] = useState(10)
|
||||
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">
|
||||
<button
|
||||
className="btn btn-success"
|
||||
onClick={() => navigate('/coordinator/add-group')}
|
||||
onClick={() =>
|
||||
navigate(
|
||||
`/${
|
||||
location.pathname.includes('coordinator')
|
||||
? 'coordinator'
|
||||
: 'supervisor'
|
||||
}/add-group`,
|
||||
)
|
||||
}
|
||||
>
|
||||
Dodaj nową grupę
|
||||
</button>
|
||||
@ -97,7 +107,11 @@ const Groups = () => {
|
||||
<tr key={id}>
|
||||
<td>
|
||||
<Link
|
||||
to={`/coordinator/groups/${id}`}
|
||||
to={`/${
|
||||
location.pathname.includes('coordinator')
|
||||
? 'coordinator'
|
||||
: 'supervisor'
|
||||
}/groups/${id}`}
|
||||
className="underline font-bold"
|
||||
>
|
||||
{name}
|
||||
|
@ -1,9 +1,10 @@
|
||||
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'
|
||||
|
||||
const Group = () => {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const location = useLocation()
|
||||
|
||||
const { data: groups } = useQuery(['getGroup'], () => getGroup(Number(id)))
|
||||
const { name, project_supervisor } = groups?.data || {}
|
||||
@ -15,7 +16,13 @@ const Group = () => {
|
||||
Opiekun: {project_supervisor?.first_name}{' '}
|
||||
{project_supervisor?.last_name}
|
||||
</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>
|
||||
</Link>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user