From c59f03305e4dca7839d254fc0436704464a32982 Mon Sep 17 00:00:00 2001 From: Semyon Okulov Date: Wed, 13 Sep 2023 02:38:38 +0700 Subject: [PATCH] move shared to other package --- frontend/package.json | 1 + frontend/src/components/LessonCard.tsx | 5 +- frontend/src/components/MarksByGroup.tsx | 5 +- frontend/src/components/ScheduleGroup.tsx | 2 +- frontend/src/components/UI/Mark/index.tsx | 3 +- .../src/components/UI/MarksByDay/index.tsx | 18 +- frontend/src/components/UI/SubjectsList.tsx | 2 +- frontend/src/components/UserInfo.tsx | 2 +- frontend/src/methods/server/getAds.ts | 2 +- frontend/src/methods/server/getAttestation.ts | 2 +- frontend/src/methods/server/getCollegeInfo.ts | 2 +- frontend/src/methods/server/getLessons.ts | 2 +- frontend/src/methods/server/getPerformance.ts | 2 +- frontend/src/modals/LessonModal.tsx | 5 +- frontend/src/modals/ModalContext.tsx | 2 +- frontend/src/modals/data.ts | 2 +- frontend/src/types/index.ts | 23 ++ frontend/src/utils/calculateAverageMark.ts | 3 +- frontend/src/utils/setDefaultMark.ts | 3 +- frontend/src/views/Attestation.tsx | 6 +- frontend/src/views/LoginForm.tsx | 9 +- frontend/src/views/Notifications.tsx | 2 +- frontend/src/views/Schedule.tsx | 2 +- frontend/vite.config.ts | 2 +- frontend/vk-hosting-config.json | 2 +- frontend/yarn.lock | 5 + shared/index.ts | 297 ------------------ 27 files changed, 73 insertions(+), 338 deletions(-) delete mode 100644 shared/index.ts diff --git a/frontend/package.json b/frontend/package.json index 6acfe4c3..d3ed4513 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -32,6 +32,7 @@ "@vitejs/plugin-basic-ssl": "^1.0.1", "@vitejs/plugin-react-swc": "^3.3.2", "@vkontakte/vk-miniapps-deploy": "^0.1.6", + "diary-shared": "^1.6.2", "eslint": "^8.45.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb-typescript": "^17.1.0", diff --git a/frontend/src/components/LessonCard.tsx b/frontend/src/components/LessonCard.tsx index a13fc8e4..de198c30 100644 --- a/frontend/src/components/LessonCard.tsx +++ b/frontend/src/components/LessonCard.tsx @@ -4,8 +4,8 @@ import { } from '@vkontakte/vkui'; import { useRouteNavigator } from '@vkontakte/vk-mini-apps-router'; import { - Day, EAbsenceTypes, Grade, Gradebook, LessonWorkType, Timetable, -} from '../../../shared'; + Day, EAbsenceTypes, Gradebook, LessonWorkType, Timetable, +} from '/diary-shared'; import { formatLessonDate, getDayOfWeek } from '../utils/formatLessonDate'; import setDefaultMark from '../utils/setDefaultMark'; import { isToday } from '../utils/isToday'; @@ -14,6 +14,7 @@ import { useModal } from '../modals/ModalContext'; import SubtitleWithBorder from './SubtitleWithBorder'; import TimeRemaining from './TimeRemaining'; import Mark from './UI/Mark'; +import {Grade} from "../types"; interface ILessonCard { lesson: Day; diff --git a/frontend/src/components/MarksByGroup.tsx b/frontend/src/components/MarksByGroup.tsx index 0a88e52a..f77afcb8 100644 --- a/frontend/src/components/MarksByGroup.tsx +++ b/frontend/src/components/MarksByGroup.tsx @@ -19,13 +19,14 @@ import { Icon28InfoCircle, } from '@vkontakte/icons'; import { - AbsenceType, EAbsenceTypes, Grade, PerformanceCurrent, TextMark, -} from '../../../shared'; + AbsenceType, EAbsenceTypes, PerformanceCurrent, TextMark, +} from '/diary-shared'; import { getPerformance } from '../methods'; import calculateAverageMark from '../utils/calculateAverageMark'; import { useSnackbar } from '../hooks'; import Mark from './UI/Mark'; import { handleResponse } from '../utils/handleResponse'; +import {Grade} from "../types"; const THIRD_SEC = 30 * 1000; diff --git a/frontend/src/components/ScheduleGroup.tsx b/frontend/src/components/ScheduleGroup.tsx index 5d1a4513..05f1191e 100644 --- a/frontend/src/components/ScheduleGroup.tsx +++ b/frontend/src/components/ScheduleGroup.tsx @@ -1,7 +1,7 @@ import { FC } from 'react'; // TODO: Сделать переключатель для расписания import { CardGrid } from '@vkontakte/vkui'; -import { Day } from '../../../shared'; +import { Day } from 'diary-shared'; import LessonCard from './LessonCard'; interface IScheduleGroup { diff --git a/frontend/src/components/UI/Mark/index.tsx b/frontend/src/components/UI/Mark/index.tsx index 690a6562..6f88ea79 100644 --- a/frontend/src/components/UI/Mark/index.tsx +++ b/frontend/src/components/UI/Mark/index.tsx @@ -1,6 +1,7 @@ import { CSSProperties, FC } from 'react'; import { Footnote } from '@vkontakte/vkui'; -import { EAbsenceTypes, TMark } from '../../../../../shared'; +import { EAbsenceTypes } from 'diary-shared'; +import { TMark } from '../../../../../shared'; type Sizes = 'l' | 's'; diff --git a/frontend/src/components/UI/MarksByDay/index.tsx b/frontend/src/components/UI/MarksByDay/index.tsx index 42effef5..10821868 100644 --- a/frontend/src/components/UI/MarksByDay/index.tsx +++ b/frontend/src/components/UI/MarksByDay/index.tsx @@ -2,11 +2,9 @@ import React, { FC } from 'react'; import { Group, Header, HorizontalCell, HorizontalScroll, } from '@vkontakte/vkui'; - -import { Grade, PerformanceCurrent } from '../../../../../shared'; - +import { PerformanceCurrent } from 'diary-shared'; import Mark from '../Mark'; - +import {Grade} from "../../../types"; import './index.css'; interface IPerformanceCurrent { @@ -28,29 +26,29 @@ interface IMarksByDay { const MarksByDay: FC = ({ performanceData }) => { const marksByDay: IMarksByDay = {}; - + performanceData?.daysWithMarksForSubject?.forEach((subject) => { subject?.daysWithMarks?.forEach((dayWithMarks) => { const day = new Date(dayWithMarks.day).toLocaleDateString(); const grades = dayWithMarks.markValues.map((gradeText) => Grade[gradeText]); const lessonName = subject.subjectName; - + if (grades.length > 0 && grades.every((grade) => !Number.isNaN(parseFloat(grade as string)))) { if (!marksByDay[day]) { marksByDay[day] = {}; } - + if (!marksByDay[day][lessonName]) { marksByDay[day][lessonName] = []; } - + marksByDay[day][lessonName] = [...marksByDay[day][lessonName], ...grades]; } }); }); - + const sortedDates = Object.keys(marksByDay).sort((a, b) => new Date(b).getTime() - new Date(a).getTime()); - + return ( ; diff --git a/frontend/src/components/UserInfo.tsx b/frontend/src/components/UserInfo.tsx index 18a8f541..fb97dc43 100644 --- a/frontend/src/components/UserInfo.tsx +++ b/frontend/src/components/UserInfo.tsx @@ -5,11 +5,11 @@ import { import { Icon28SchoolOutline, Icon32PrometeyCircleFillRed } from '@vkontakte/icons'; import bridge from '@vkontakte/vk-bridge'; import { useRouteNavigator } from '@vkontakte/vk-mini-apps-router'; +import { Organization } from 'diary-shared'; import { getVkStorageData, getVkStorageKeys } from '../methods'; import { useModal } from '../modals/ModalContext'; import { useRateLimitExceeded } from '../hooks'; import { MODAL_COLLEGE_INFO } from '../modals/ModalRoot'; -import { Organization } from '../../../shared'; import getCollegeInfo from '../methods/server/getCollegeInfo'; import useSnackbar from '../hooks/useSnackbar'; import logOut from '../utils/logOut'; diff --git a/frontend/src/methods/server/getAds.ts b/frontend/src/methods/server/getAds.ts index a26a12f4..0496d27a 100644 --- a/frontend/src/methods/server/getAds.ts +++ b/frontend/src/methods/server/getAds.ts @@ -1,5 +1,5 @@ +import { NotificationsResponse } from 'diary-shared'; import { getCookie } from '../bridge/getCookie'; -import { NotificationsResponse } from '../../../../shared'; const getAds = async (): Promise => { const cookie = await getCookie(); diff --git a/frontend/src/methods/server/getAttestation.ts b/frontend/src/methods/server/getAttestation.ts index 276c6010..75fc38ac 100644 --- a/frontend/src/methods/server/getAttestation.ts +++ b/frontend/src/methods/server/getAttestation.ts @@ -1,5 +1,5 @@ +import { AttestationResponse } from 'diary-shared'; import { getCookie } from '../bridge/getCookie'; -import { AttestationResponse } from '../../../../shared'; import { getUserId } from '../bridge/getUserId'; const getAttestation = async (): Promise => { diff --git a/frontend/src/methods/server/getCollegeInfo.ts b/frontend/src/methods/server/getCollegeInfo.ts index d6b8162e..241021bd 100644 --- a/frontend/src/methods/server/getCollegeInfo.ts +++ b/frontend/src/methods/server/getCollegeInfo.ts @@ -1,4 +1,4 @@ -import { Organization } from '../../../../shared'; +import { Organization } from 'diary-shared'; import { getCookie } from '../bridge/getCookie'; const getCollegeInfo = async (): Promise => { diff --git a/frontend/src/methods/server/getLessons.ts b/frontend/src/methods/server/getLessons.ts index 39909bad..8f297584 100644 --- a/frontend/src/methods/server/getLessons.ts +++ b/frontend/src/methods/server/getLessons.ts @@ -1,4 +1,4 @@ -import { Day } from '../../../../shared'; +import { Day } from 'diary-shared'; import formatDateForRequest from '../../utils/formatDateForRequest'; import { getUserId } from '../bridge/getUserId'; import { getCookie } from '../bridge/getCookie'; diff --git a/frontend/src/methods/server/getPerformance.ts b/frontend/src/methods/server/getPerformance.ts index 257f62dd..80c18a89 100644 --- a/frontend/src/methods/server/getPerformance.ts +++ b/frontend/src/methods/server/getPerformance.ts @@ -1,4 +1,4 @@ -import { PerformanceCurrent } from '../../../../shared'; +import { PerformanceCurrent } from 'diary-shared'; import { getCookie } from '../bridge/getCookie'; import { getUserId } from '../bridge/getUserId'; diff --git a/frontend/src/modals/LessonModal.tsx b/frontend/src/modals/LessonModal.tsx index 146159ae..9ed2158e 100644 --- a/frontend/src/modals/LessonModal.tsx +++ b/frontend/src/modals/LessonModal.tsx @@ -3,13 +3,14 @@ import { Group, Header, InfoRow, ModalPage, ModalPageHeader, Separator, SimpleCell, Spacing, Text, } from '@vkontakte/vkui'; import { - EAbsenceTypes, EAbsenceTypesDescription, Grade, Lesson, LessonType, LessonWorkType, TLesson, -} from '../../../shared'; + EAbsenceTypes, EAbsenceTypesDescription, Lesson, LessonType, LessonWorkType, TLesson, +} from '/diary-shared'; import setDefaultMark from '../utils/setDefaultMark'; import textToLink from '../utils/textToLink'; import { cleanData } from './data'; import Mark from '../components/UI/Mark'; import { useModal } from './ModalContext'; +import {Grade} from "../types"; interface ILessonModal { id: string; diff --git a/frontend/src/modals/ModalContext.tsx b/frontend/src/modals/ModalContext.tsx index cb59f71d..36358c9c 100644 --- a/frontend/src/modals/ModalContext.tsx +++ b/frontend/src/modals/ModalContext.tsx @@ -1,7 +1,7 @@ import React, { ReactNode, createContext, useContext, useState, useMemo, } from 'react'; -import { Lesson, Organization } from '../../../shared'; +import { Lesson, Organization } from 'diary-shared'; const ModalContext = createContext<{ lessonModalData: Lesson | null; diff --git a/frontend/src/modals/data.ts b/frontend/src/modals/data.ts index 9a1d8677..45d91d2f 100644 --- a/frontend/src/modals/data.ts +++ b/frontend/src/modals/data.ts @@ -1,4 +1,4 @@ -import { Lesson } from '../../../shared'; +import { Lesson } from 'diary-shared'; export const cleanData: Lesson = { name: '', diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts index 796b34ac..209d99e1 100644 --- a/frontend/src/types/index.ts +++ b/frontend/src/types/index.ts @@ -4,3 +4,26 @@ export interface Storage { key: string; value: string } + +// FIXME: enum стал страшный и в целом enum многие по понятным причинам хейтят +// Поэтому когда-нибудь надо пофиксить +export enum Grade { + Five = 5, + Four = 4, + Three = 3, + Two = 2, + One = 1, + // Оценка пустая = долг, двойку не ставим! + '' = 'Д', + 'Н' = 'Н', + // Кастыль :)) + 'Д' = 'Д', + 'ДЗ' = 'ДЗ', + 'О' = 'О' +} + + +type GradeKeys = keyof typeof Grade; + +export type TextMark = GradeKeys; +export type TMark = typeof Grade[GradeKeys]; diff --git a/frontend/src/utils/calculateAverageMark.ts b/frontend/src/utils/calculateAverageMark.ts index 9102455b..b421f761 100644 --- a/frontend/src/utils/calculateAverageMark.ts +++ b/frontend/src/utils/calculateAverageMark.ts @@ -1,4 +1,5 @@ -import { Grade, TextMark } from '../../../shared'; +import { TextMark } from 'diary-shared'; +import {Grade} from "../types"; const calculateAverageMark = (marks: TextMark[] | undefined): number | null => { if (!marks || marks.length === 0) { diff --git a/frontend/src/utils/setDefaultMark.ts b/frontend/src/utils/setDefaultMark.ts index df97e052..357df017 100644 --- a/frontend/src/utils/setDefaultMark.ts +++ b/frontend/src/utils/setDefaultMark.ts @@ -1,4 +1,5 @@ -import { Task, TextMark } from '../../../shared'; +import { Task } from 'diary-shared'; +import { TextMark } from '../../../shared'; // TODO: можно с помощью неё фиксить ошибки с неправильными оценами const setDefaultMark = (task: Task): TextMark => { if (task.isRequired && !task.mark) { diff --git a/frontend/src/views/Attestation.tsx b/frontend/src/views/Attestation.tsx index 4a637ae0..583cff29 100644 --- a/frontend/src/views/Attestation.tsx +++ b/frontend/src/views/Attestation.tsx @@ -3,12 +3,12 @@ import { Button, ButtonGroup, Div, Link, Panel, Placeholder, ScreenSpinner, View, } from '@vkontakte/vkui'; import { useActiveVkuiLocation, useRouteNavigator } from '@vkontakte/vk-mini-apps-router'; +import { AttestationResponse } from 'diary-shared'; import getAttestation from '../methods/server/getAttestation'; -import { AttestationResponse } from '../../../shared'; import PanelHeaderWithBack from '../components/UI/PanelHeaderWithBack'; import { useRateLimitExceeded } from '../hooks'; -import SubjectList from '../components/UI/SubjectsList.tsx'; -import { handleResponse } from '../utils/handleResponse.ts'; +import SubjectList from '../components/UI/SubjectsList'; +import { handleResponse } from '../utils/handleResponse'; interface IAttestation { id: string; diff --git a/frontend/src/views/LoginForm.tsx b/frontend/src/views/LoginForm.tsx index 84abaa17..7d60ba5a 100644 --- a/frontend/src/views/LoginForm.tsx +++ b/frontend/src/views/LoginForm.tsx @@ -7,7 +7,7 @@ import { import { useActiveVkuiLocation, useRouteNavigator } from '@vkontakte/vk-mini-apps-router'; import Hashes from 'jshashes'; import { Icon28DoorArrowLeftOutline, Icon28ErrorCircleOutline } from '@vkontakte/icons'; -import { AuthData } from '../../../shared'; +import { AuthData } from 'diary-shared'; import { appStorageSet, getCookie } from '../methods'; import { VIEW_SCHEDULE } from '../routes'; import { useSnackbar } from '../hooks'; @@ -85,14 +85,13 @@ const LoginForm: FC<{ id: string }> = ({ id }) => { setPopout(); const response = await fetch(`${import.meta.env.VITE_SERVER_URL}/login`, { method: 'POST', - headers: { - 'Content-Type': 'application/json;charset=UTF-8', - origin, - }, body: JSON.stringify({ login, password: passwordHashed, }), + headers: { + "Access-Control-Allow-Origin": "*" + } }); if (response.status === 401) { console.log('401'); diff --git a/frontend/src/views/Notifications.tsx b/frontend/src/views/Notifications.tsx index 68a90bf1..7d4303fb 100644 --- a/frontend/src/views/Notifications.tsx +++ b/frontend/src/views/Notifications.tsx @@ -4,11 +4,11 @@ import { } from '@vkontakte/vkui'; import { useActiveVkuiLocation, useRouteNavigator } from '@vkontakte/vk-mini-apps-router'; import { Icon28ErrorCircleOutline } from '@vkontakte/icons'; +import { NotificationsResponse } from 'diary-shared'; import PanelHeaderWithBack from '../components/UI/PanelHeaderWithBack'; import { handleResponse } from '../utils/handleResponse'; import getAds from '../methods/server/getAds'; import { useSnackbar } from '../hooks'; -import { NotificationsResponse } from '../../../shared'; import SubtitleWithBorder from '../components/SubtitleWithBorder'; const Notifications: FC<{ id: string }> = ({ id }) => { diff --git a/frontend/src/views/Schedule.tsx b/frontend/src/views/Schedule.tsx index 9ed64ada..94082071 100644 --- a/frontend/src/views/Schedule.tsx +++ b/frontend/src/views/Schedule.tsx @@ -11,7 +11,7 @@ import { Icon28ErrorCircleOutline, } from '@vkontakte/icons'; import { addDays, endOfWeek, startOfWeek } from '@vkontakte/vkui/dist/lib/date'; -import { Day, PerformanceCurrent } from '../../../shared'; +import { Day, PerformanceCurrent } from 'diary-shared'; import { getLessons, getPerformance } from '../methods'; import PanelHeaderWithBack from '../components/UI/PanelHeaderWithBack'; import Suspense from '../components/UI/Suspense'; diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 984afdc5..e101c703 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -36,5 +36,5 @@ export default defineConfig({ }, // Указывать только для dev сборки. // Либо index'у вернуть его исходное имя, а переименовывать только при деплое - // base: 'index-b4.html', + base: 'index-b4.html', }) diff --git a/frontend/vk-hosting-config.json b/frontend/vk-hosting-config.json index 15339d44..48da796f 100644 --- a/frontend/vk-hosting-config.json +++ b/frontend/vk-hosting-config.json @@ -1,6 +1,6 @@ { "static_path": "dist", - "app_id": 51740302, + "app_id": 51723411, "endpoints": { "mobile": "index-b4.html", "mvk": "index-b4.html", diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 95790121..4e562412 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -987,6 +987,11 @@ dequal@^2.0.3: resolved "https://registry.yarnpkg.com/dequal/-/dequal-2.0.3.tgz#2644214f1997d39ed0ee0ece72335490a7ac67be" integrity sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA== +diary-shared@^1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/diary-shared/-/diary-shared-1.6.2.tgz#0df3513dfcb7215317f1d7824b4d713618930934" + integrity sha512-L9nP98OryhA8tS8LdOJaikcvcbaNLoljcgW+sTPBFwyjAznYKJ416T99csn77Kk89EHvPsnF2GIWk5kvF+cVyw== + dir-glob@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" diff --git a/shared/index.ts b/shared/index.ts deleted file mode 100644 index 8097c351..00000000 --- a/shared/index.ts +++ /dev/null @@ -1,297 +0,0 @@ -// Эти данные приходят с бэка сетевого города, типизация актуальна на момент 04.09.23 -// В некоторых местах типизация может быть не полной -export interface Organization { - // Example: 'spo' - 'organizationType': string, - 'name': string, - 'shortName': string, - 'abbreviation': string, - 'legalStatus': string, - 'address': { - 'region': string, - // Example: 'г. Томск' - 'settlement': string, - 'mailAddress': string, - // Example: '70000001000000000' - 'kladr': string - }, - 'organizationDeptId': 1, - 'phone': string, - 'fax': string, - 'email': string, - 'site': string, - 'directorName': string, - 'directorPosition': string, - // Example: '' - 'studyUnitNumber': string, - // Example: 'Function' - 'organizationStatus': string, - 'isEntrepreneurOwned': boolean, - // Example: '' - 'entrepreneurName': string, - // Example: '4e97a34f-b553-42ec-8c26-bc30332d0661' - 'organizationId': string, - // Example: '' - 'headOrganizationName': string, - 'isSubdepartment': boolean, - // Example: '' - 'additionalName': string, - 'type': string, - 'legalAddress': string, - 'actualAddress': string, - 'bankingDetails': { - 'okved': string, - 'inn': string, - 'kpp': string, - 'ogrn': string, - 'oktmo': string, - 'okopth': string, - 'okths': string, - 'okpo': string, - 'others': string, - 'okogu': string, - 'founderType': string, - // Example: '' - 'founders': string, - 'okato': string - }, - 'administration': { - 'eService': { - 'isEnabled': true, - 'cacheEnrolleeListTimeout': number, - 'cacheSpecialtyListTimeout': number, - 'cacheEnrolleeTimeout': number, - 'useRestIntegration': true - }, - // Example: 4e97a34f-b553-42ec-8c26-bc30332d0661 - 'organizationId': string, - 'attestation': { - 'isEnabled': boolean - }, - 'factHours': { - 'isEnabled': boolean - }, - 'vkChats': { - 'communityId': string, - 'communityToken': string - } - } -} - -interface UserData { - installName: string - localNetwork: boolean - tenantName: string - tenants: { - SPO_23: { - students: [ - { - groupId: number, - groupName: string, - firstName: string, - lastName: string, - middleName: string, - id: number - } - ], - firstName: string - isTrusted: boolean - lastName: string - middleName: string - studentRole: { - id: number - studentGroupId: number - }, - settings: { - organization: Organization - }, - } - } -} - -export enum LessonType { - 'Lesson' = 'Ответ на занятии', - 'Control' = 'Контрольная работа', - 'Independent' = 'Самостоятельная работа', - 'Laboratory' = 'Лабораторная работа', - 'Slice' = 'Срезовая работа', - 'Home' = 'Домашнее задание', - 'Test' = 'Тест', - 'Review' = 'Реферат', - 'Report' = 'Доклад', - 'Colloquium' = 'Коллоквиум', - 'SportStandarts' = 'Сдача спортивных нармативов', - 'PracticeWork' = 'Практическая работа', - '' = 'Не указано' -} - -// FIXME: enum стал страшный и в целом enum многие по понятным причинам хейтят -// Поэтому когда-нибудь надо пофиксить -export enum Grade { - Five = 5, - Four = 4, - Three = 3, - Two = 2, - One = 1, - // Оценка пустая = долг, двойку не ставим! - '' = 'Д', - 'Н' = 'Н', - // Кастыль :)) - 'Д' = 'Д', - 'ДЗ' = 'ДЗ', - 'О' = 'О' -} - -export enum LessonWorkType { - 'Lecture' = 'Лекция', - 'PracticalWork' = 'Практ. работа', - 'PracticalTraining' = 'Практ. занятие', - 'Seminar' = 'Семинар', - '' = 'Не указан' -} - -export enum EAbsenceTypes { - 'IsAbsent' = 'Н', - 'IsLate' = 'О', -} - -export enum EAbsenceTypesDescription { - 'Н' = 'Отсутствие', - 'О' = 'Опоздание', -} - -type GradeKeys = keyof typeof Grade; - -export type TextMark = GradeKeys; -export type TMark = typeof Grade[GradeKeys]; -export type TLesson = keyof typeof LessonWorkType; -export type LessonTypes = keyof typeof LessonType; -export type AbsenceType = keyof typeof EAbsenceTypes; - -export interface Task { - attachments: [] - id: number - isRequired: boolean - mark: TextMark - topic?: string - type: LessonTypes -} - -interface Teacher { - firstName: string - id: number - lastName: string - middleName: string -} - -export interface Timetable { - classroom: { - building: string - id: number - name: string - }, - teacher: Teacher -} - -export interface Gradebook { - id: number - lessonType: TLesson - tasks?: Task[] - themes?: string[] - // TODO: возможно есть другие значения - absenceType?: AbsenceType -} - -export interface Lesson { - lessonId?: string - endTime: string - startTime: string - name: string | null - timetable: Timetable - gradebook?: Gradebook, - tasks?: Task[], -} - -export interface Day { - date: Date; - lessons: Lesson[] | null -} - -export interface IMark { - subjects: { - id: number - mark: TMark - name: string - }[] -} - -export interface AuthData { - cookie: string - data: UserData -} - -export interface PerformanceCurrent { - daysWithMarksForSubject: [{ - subjectName: string; - daysWithMarks?: [ - { - day: Date; - absenceType?: AbsenceType; - markValues: TextMark[]; - } - ]; - averageMark: TMark; - }], - monthsWithDays: [ - { - month: { - num: number, - name: string - }, - daysWithLessons: [Date] - } - ], -} -export enum Examinations { - 'DifferentiatedTest'= 'Дифф. зачёт', - 'Test'= 'Зачёт', - 'Exam'= 'Экзамен', - 'Other'= 'Др. форма контроля', -} - -export type ExaminationType = keyof typeof Examinations; -export type TermType = 'Semester'; - -export interface AttestationResponse { - termType: TermType; - termNumber: number; - year: number; - students: { - id: number; - firstName: string; - lastName: string; - middleName: string; - }[]; - subjects: { - examinationType: ExaminationType; - marks: Record; - name: string; - id: number; - }[]; - profModules: unknown[]; - courseWorks: unknown[]; - departmentName: string; -} - -export interface NotificationsResponse { - id: number, - attachments: [], - date: Date, - title: string, - text: string - isForEmployees: boolean, - isForStudents: boolean, - isForParents: boolean, - shouldDeleteNews: boolean, - deleteInDays: number -}