Login screen improvements
This commit is contained in:
parent
3be0d04f28
commit
3d389b606f
@ -22,11 +22,9 @@ const TopBar = ({
|
||||
isActive ? 'underline font-bold' : ''
|
||||
|
||||
const [yearGroupId, setYearGroupId] = useLocalStorageState('yearGroupId', {
|
||||
defaultValue: -1,
|
||||
})
|
||||
const [userType, setUserType] = useLocalStorageState('userType', {
|
||||
defaultValue: 'coordinator',
|
||||
defaultValue: 0,
|
||||
})
|
||||
const [userType, setUserType] = useLocalStorageState('userType')
|
||||
const [yearGroupOptions, setYearGroupOptions] = useState<SelectValue[]>()
|
||||
|
||||
const onYearChange = (v: any) => {
|
||||
|
@ -17,10 +17,10 @@ const Login = () => {
|
||||
const navigate = useNavigate()
|
||||
|
||||
const [yearGroupId, setYearGroupId] = useLocalStorageState('yearGroupId', {
|
||||
defaultValue: -1,
|
||||
defaultValue: 0,
|
||||
})
|
||||
const [userId, setUserId] = useLocalStorageState('userId', {
|
||||
defaultValue: -1,
|
||||
defaultValue: 0,
|
||||
})
|
||||
const [studentId, setStudentId] = useLocalStorageState('studentId')
|
||||
|
||||
@ -42,11 +42,14 @@ const Login = () => {
|
||||
}
|
||||
}),
|
||||
)
|
||||
if (yearGroupId === 0 && data?.data.year_groups.length) {
|
||||
setYearGroupId(1)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
useQuery(
|
||||
'students',
|
||||
['students', yearGroupId],
|
||||
() => getStudents({ year_group_id: yearGroupId, per_page: 1000 }),
|
||||
{
|
||||
onSuccess: (data) => {
|
||||
@ -59,11 +62,12 @@ const Login = () => {
|
||||
}),
|
||||
)
|
||||
},
|
||||
enabled: yearGroupId > 0,
|
||||
},
|
||||
)
|
||||
|
||||
useQuery(
|
||||
'project_supervisors',
|
||||
['project_supervisors', yearGroupId],
|
||||
() => getLeaders({ year_group_id: yearGroupId, per_page: 1000 }),
|
||||
{
|
||||
onSuccess: (data) => {
|
||||
@ -78,6 +82,7 @@ const Login = () => {
|
||||
),
|
||||
)
|
||||
},
|
||||
enabled: yearGroupId > 0,
|
||||
},
|
||||
)
|
||||
|
||||
@ -116,6 +121,7 @@ const Login = () => {
|
||||
borderRadius: '0.5rem',
|
||||
}),
|
||||
}}
|
||||
value={yearGroupOptions?.find((year) => year.value === yearGroupId)}
|
||||
/>
|
||||
<label className="label">Student</label>
|
||||
<Select
|
||||
@ -161,7 +167,7 @@ const Login = () => {
|
||||
</div> */}
|
||||
<button
|
||||
className="btn mt-5 text-lg"
|
||||
disabled={userId < 0 || selectedYear < 0}
|
||||
disabled={userId === 0 || selectedYear === 0}
|
||||
onClick={() => navigate('/' + userType)}
|
||||
>
|
||||
Zaloguj
|
||||
|
Loading…
Reference in New Issue
Block a user