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

View File

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

View File

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