Add studentId

This commit is contained in:
adam-skowronek 2023-01-03 22:51:07 +01:00
parent 5d999ea9c8
commit 7fe646a875
3 changed files with 24 additions and 14 deletions

View File

@ -22,6 +22,8 @@ const Login = () => {
const [userId, setUserId] = useLocalStorageState('userId', { const [userId, setUserId] = useLocalStorageState('userId', {
defaultValue: -1, defaultValue: -1,
}) })
const [studentId, setStudentId] = useLocalStorageState('studentId')
const [userType, setUserType] = useLocalStorageState('userType', { const [userType, setUserType] = useLocalStorageState('userType', {
defaultValue: 'coordinator', defaultValue: 'coordinator',
}) })
@ -66,19 +68,22 @@ const Login = () => {
{ {
onSuccess: (data) => { onSuccess: (data) => {
setLeaderOptions( setLeaderOptions(
data?.data.project_supervisors.map(({ first_name, last_name, id }) => { data?.data.project_supervisors.map(
return { ({ first_name, last_name, id }) => {
value: id, return {
label: `${first_name} ${last_name}`, value: id,
} label: `${first_name} ${last_name}`,
}), }
},
),
) )
}, },
}, },
) )
const onStudentChange = (v: any) => { const onStudentChange = (v: any) => {
setUserId(v.value) setStudentId(v.value)
// setUserId(v.value)
setUserType('student') setUserType('student')
} }
@ -131,7 +136,7 @@ const Login = () => {
<Select <Select
closeMenuOnSelect={true} closeMenuOnSelect={true}
options={leaderOptions} options={leaderOptions}
placeholder="Wybierz studenta" placeholder="Wybierz opiekuna"
onChange={onLeaderChange} onChange={onLeaderChange}
styles={{ styles={{
control: (styles: any) => ({ control: (styles: any) => ({
@ -162,10 +167,15 @@ const Login = () => {
Zaloguj Zaloguj
</button> </button>
<div className="flex flex-col mt-3"> <div className="flex flex-col mt-3">
<span onClick={() => { <span
setUserType('coordinator') onClick={() => {
navigate("/coordinator") setUserType('coordinator')
}} className="cursor-pointer">Koordynator</span> navigate('/coordinator')
}}
className="cursor-pointer"
>
Koordynator
</span>
{/* <NavLink to="/student">Student</NavLink> */} {/* <NavLink to="/student">Student</NavLink> */}
{/* <NavLink to="/supervisor">Opiekun</NavLink> */} {/* <NavLink to="/supervisor">Opiekun</NavLink> */}
</div> </div>

View File

@ -23,7 +23,7 @@ const ScheduleAddGroup = ({
const { register, handleSubmit, reset, control } = useForm<{ const { register, handleSubmit, reset, control } = useForm<{
student_index: number student_index: number
}>({ mode: 'onBlur' }) }>({ mode: 'onBlur' })
const [studentId] = useLocalStorageState('userId') const [studentId] = useLocalStorageState('studentId')
const { mutate: mutateAssignGroup } = useMutation( const { mutate: mutateAssignGroup } = useMutation(
['assignGroup'], ['assignGroup'],

View File

@ -24,7 +24,7 @@ const customStyles = {
const localizer = dayjsLocalizer(dayjs) const localizer = dayjsLocalizer(dayjs)
const StudentSchedule = () => { const StudentSchedule = () => {
const [studentId] = useLocalStorageState('userId') const [studentId] = useLocalStorageState('studentId')
const { id } = useParams<{ id: string }>() const { id } = useParams<{ id: string }>()
const [events, setEvents] = useState< const [events, setEvents] = useState<
{ {