Update creating term of defences

This commit is contained in:
adam-skowronek 2023-01-08 19:18:45 +01:00
parent cd5b7d4dbd
commit 6e90840af5
6 changed files with 36 additions and 54 deletions

View File

@ -84,11 +84,14 @@ export const createEvent = ({
scheduleId: number scheduleId: number
project_supervisors: number[] project_supervisors: number[]
}) => { }) => {
return axiosInstance.post(`coordinator/enrollments/${scheduleId}/add`, { return axiosInstance.post(
`coordinator/enrollments/${scheduleId}/add-term-of-defences/`,
{
start_date, start_date,
end_date, end_date,
project_supervisors, project_supervisors,
}) },
)
} }
export const createSchedule = ( export const createSchedule = (

View File

@ -72,8 +72,8 @@ const EditSchedule = ({
<form className="w-full flex flex-col " onSubmit={handleSubmit(onSubmit)}> <form className="w-full flex flex-col " onSubmit={handleSubmit(onSubmit)}>
<h3> Termin </h3> <h3> Termin </h3>
<p className="mb-2"> <p className="mb-2">
{dayjs(eventData.start).format('YYYY-MM-DD HH:mm:ss')} -{' '} {dayjs(eventData.start).format('YYYY-MM-DD HH:mm')} -{' '}
{dayjs(eventData.end).format('YYYY-MM-DD HH:mm:ss')} {dayjs(eventData.end).format('HH:mm')}
</p> </p>
{eventData.resource?.members_of_committee?.length ? ( {eventData.resource?.members_of_committee?.length ? (
<> <>

View File

@ -27,6 +27,8 @@ const customStyles = {
bottom: 'auto', bottom: 'auto',
marginRight: '-50%', marginRight: '-50%',
transform: 'translate(-50%, -50%)', transform: 'translate(-50%, -50%)',
width: '400px',
height: '400px',
}, },
} }
type SelectValue = { type SelectValue = {
@ -164,20 +166,7 @@ const Schedule = () => {
const handleSelectSlot = async (event: any) => { const handleSelectSlot = async (event: any) => {
setSelectedDate(event) setSelectedDate(event)
if (view === Views.MONTH) {
setIsModalOpen(true) setIsModalOpen(true)
} else {
// await mutateCreateEvent({
// start_date: DateTime.fromJSDate(event.start).toFormat(
// 'YYYY-MM-DD HH:mm:ss',
// ),
// end_date: DateTime.fromJSDate(event.end).toFormat(
// 'YYYY-MM-DD HH:mm:ss',
// ),
// scheduleId: Number(id),
// })
// refetch()
}
} }
const handleSelectEvent = useCallback( const handleSelectEvent = useCallback(
@ -200,16 +189,16 @@ const Schedule = () => {
const onSubmit = async (data: any) => { const onSubmit = async (data: any) => {
// if (selectedDate && view === Views.MONTH) { // if (selectedDate && view === Views.MONTH) {
if (selectedDate) { if (selectedDate) {
const from = data.from.split(':') const from = dayjs(selectedDate.start).format('HH:mm').split(':')
const to = data.to.split(':') const to = dayjs(selectedDate.end).format('HH:mm').split(':')
await mutateCreateEvent({ await mutateCreateEvent({
start_date: dayjs(selectedDate.start) start_date: dayjs(selectedDate.start)
.set('hour', from[0]) .set('hour', Number(from[0]))
.set('minute', from[1]) .set('minute', Number(from[1]))
.format('YYYY-MM-DD HH:mm:ss'), .format('YYYY-MM-DD HH:mm:ss'),
end_date: dayjs(selectedDate.start) end_date: dayjs(selectedDate.end)
.set('hour', to[0]) .set('hour', Number(to[0]))
.set('minute', to[1]) .set('minute', Number(to[1]))
.format('YYYY-MM-DD HH:mm:ss'), .format('YYYY-MM-DD HH:mm:ss'),
scheduleId: Number(id), scheduleId: Number(id),
project_supervisors: data?.project_supervisors, project_supervisors: data?.project_supervisors,
@ -264,7 +253,10 @@ const Schedule = () => {
return ( return (
<div className="flex flex-col"> <div className="flex flex-col">
<div> <div>
Start zapisów dla studentów: <label htmlFor="end_date">Od </label> Start zapisów dla studentów:{' '}
<label className="ml-2" htmlFor="end_date">
Od{' '}
</label>
<DateTimePicker <DateTimePicker
onChange={setStartDate} onChange={setStartDate}
value={startDate} value={startDate}
@ -272,7 +264,9 @@ const Schedule = () => {
locale={'pl'} locale={'pl'}
disableClock disableClock
/> />
<label htmlFor="end_date">Do </label> <label className="ml-2" htmlFor="end_date">
Do{' '}
</label>
<DateTimePicker <DateTimePicker
onChange={setEndDate} onChange={setEndDate}
value={endDate} value={endDate}
@ -310,7 +304,7 @@ const Schedule = () => {
localizer={localizer} localizer={localizer}
startAccessor="start" startAccessor="start"
endAccessor="end" endAccessor="end"
style={{ height: '85vh' }} style={{ height: '85vh', fontSize: '14px' }}
selectable selectable
onSelectEvent={handleSelectEvent} onSelectEvent={handleSelectEvent}
onSelectSlot={handleSelectSlot} onSelectSlot={handleSelectSlot}
@ -335,24 +329,9 @@ const Schedule = () => {
> >
<h3>Dostępne godziny</h3> <h3>Dostępne godziny</h3>
<div className="form-control"> <div className="form-control">
<label className="label" htmlFor="from"> <strong>{dayjs(selectedDate?.start).format('YYYY-MM-DD')}</strong>
Od <p>Od {dayjs(selectedDate?.start).format('HH:mm')}</p>
</label> <p>Do {dayjs(selectedDate?.end).format('HH:mm')}</p>
<input
className="input input-bordered"
id="from"
type="text"
{...register('from', { required: true })}
/>
<label className="label" htmlFor="to">
Do
</label>
<input
className="input input-bordered"
id="to"
type="text"
{...register('to', { required: true })}
/>
<label className="label" htmlFor="project_supervisors"> <label className="label" htmlFor="project_supervisors">
Komisja Komisja
</label> </label>

View File

@ -25,7 +25,7 @@ const Enrollment = () => {
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<h2 className="text-xl font-bold">Opiekunowie:</h2> <h2 className="text-xl font-bold">Opiekunowie:</h2>
<div className="flex gap-3"> <div className="flex gap-3">
<label className="label justify-start gap-2"> {/* <label className="label justify-start gap-2">
<input <input
type="radio" type="radio"
className="radio radio-xs md:radio-md" className="radio radio-xs md:radio-md"
@ -42,7 +42,7 @@ const Enrollment = () => {
checked={!mode} checked={!mode}
/> />
<span className="text-xs md:text-base">Niestacjonarni</span> <span className="text-xs md:text-base">Niestacjonarni</span>
</label> </label> */}
<label className="label"> <label className="label">
<input <input
type="checkbox" type="checkbox"

View File

@ -51,8 +51,8 @@ const ScheduleAddGroup = ({
<div> <div>
<form className="w-full flex flex-col " onSubmit={handleSubmit(onSubmit)}> <form className="w-full flex flex-col " onSubmit={handleSubmit(onSubmit)}>
<h3> <h3>
Termin {dayjs(eventData.start).format('YYYY-MM-DD HH:mm:ss')} -{' '} Termin {dayjs(eventData.start).format('YYYY-MM-DD HH:mm')} -{' '}
{dayjs(eventData.end).format('YYYY-MM-DD HH:mm:ss')} {dayjs(eventData.end).format('HH:mm')}
</h3> </h3>
{eventData.resource?.members_of_committee?.length > 0 && ( {eventData.resource?.members_of_committee?.length > 0 && (
<> <>

View File

@ -116,7 +116,7 @@ const SupervisorSchedule = () => {
}, },
) )
const { mutateAsync: mutateAddAvailability } = useMutation( const { mutateAsync: mutateAddAvailability } = useMutation(
['createEvent'], ['addAvailability'],
(data: { (data: {
project_supervisor_id: number project_supervisor_id: number
start_date: string start_date: string