2024-03-01 12:16:13 +03:00
|
|
|
|
import React from 'react'
|
|
|
|
|
import { useParams } from 'react-router-dom'
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
ErrorSpan,
|
|
|
|
|
LessonItem,
|
|
|
|
|
Lessonname,
|
|
|
|
|
MainWrapper,
|
|
|
|
|
StartWrapper,
|
|
|
|
|
} from './style'
|
|
|
|
|
import { api } from '../__data__/api/api'
|
|
|
|
|
import dayjs from 'dayjs'
|
2023-04-16 12:18:29 +03:00
|
|
|
|
|
2024-03-01 12:49:55 +03:00
|
|
|
|
const UserPage = () => {
|
2024-03-01 12:16:13 +03:00
|
|
|
|
const { lessonId, accessId } = useParams()
|
2024-03-01 11:43:31 +03:00
|
|
|
|
const acc = api.useGetAccessQuery({ accessCode: accessId })
|
|
|
|
|
|
|
|
|
|
const ls = api.useLessonByIdQuery(lessonId, {
|
|
|
|
|
pollingInterval: 1000,
|
2024-03-01 12:16:13 +03:00
|
|
|
|
skipPollingIfUnfocused: true,
|
|
|
|
|
})
|
2023-04-16 12:30:42 +03:00
|
|
|
|
|
2023-04-16 12:18:29 +03:00
|
|
|
|
return (
|
|
|
|
|
<MainWrapper>
|
|
|
|
|
<StartWrapper>
|
2024-03-01 11:43:31 +03:00
|
|
|
|
{acc.isLoading && <h1>Отправляем запрос</h1>}
|
|
|
|
|
{acc.isSuccess && <h1>Успешно</h1>}
|
|
|
|
|
|
2024-03-01 12:35:17 +03:00
|
|
|
|
{acc.error && (
|
|
|
|
|
<div style={{ padding: 12, marginTop: 24, fontSize: 36 }}>
|
|
|
|
|
<ErrorSpan>
|
|
|
|
|
{(acc as any).error?.data?.body?.errorMessage ===
|
|
|
|
|
'Code is expired' ? (
|
2024-03-01 12:49:55 +03:00
|
|
|
|
'Не удалось активировать код доступа. Попробуйте отсканировать код ещё раз'
|
2024-03-01 12:35:17 +03:00
|
|
|
|
) : (
|
|
|
|
|
<pre>{JSON.stringify(acc.error, null, 4)}</pre>
|
|
|
|
|
)}
|
|
|
|
|
</ErrorSpan>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2024-03-01 11:43:31 +03:00
|
|
|
|
<h1>Тема занятия - {ls.data?.body?.name}</h1>
|
|
|
|
|
<span>{dayjs(ls.data?.body?.date).format('DD MMMM YYYYг.')}</span>
|
|
|
|
|
|
|
|
|
|
<ul style={{ paddingLeft: 0 }}>
|
|
|
|
|
{ls.data?.body?.students?.map((student, index) => (
|
|
|
|
|
<LessonItem key={index}>
|
2024-03-01 12:16:13 +03:00
|
|
|
|
<Lessonname>
|
|
|
|
|
{student.name || student.preferred_username}
|
|
|
|
|
</Lessonname>
|
2024-03-01 11:43:31 +03:00
|
|
|
|
</LessonItem>
|
|
|
|
|
))}
|
|
|
|
|
</ul>
|
2023-04-16 12:18:29 +03:00
|
|
|
|
</StartWrapper>
|
|
|
|
|
</MainWrapper>
|
|
|
|
|
)
|
|
|
|
|
}
|
2024-03-01 12:49:55 +03:00
|
|
|
|
|
|
|
|
|
export default UserPage
|