diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 74a3b130..cbc858f7 100755 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -56,7 +56,7 @@ const app = new Elysia() .use(routes) .listen(port) -sequelize.sync() +await sequelize.sync() console.log( `Backend running at http://${app.server?.hostname}:${app.server?.port}` diff --git a/apps/api/src/models/Task/actions/save/tasksSaveOrGet.ts b/apps/api/src/models/Task/actions/save/tasksSaveOrGet.ts index b801b120..1a72a686 100755 --- a/apps/api/src/models/Task/actions/save/tasksSaveOrGet.ts +++ b/apps/api/src/models/Task/actions/save/tasksSaveOrGet.ts @@ -31,6 +31,7 @@ export const tasksSaveOrGet = async ( scheduleId, topic: task?.topic ?? 'Не указано', idFromDiary: task.id, + condition: task.condition ?? null, taskTypeId } const promise = TaskModel.findOrCreate({ diff --git a/apps/api/src/models/Task/model.ts b/apps/api/src/models/Task/model.ts index 1dfc0421..7928d3c1 100755 --- a/apps/api/src/models/Task/model.ts +++ b/apps/api/src/models/Task/model.ts @@ -11,6 +11,7 @@ export type TaskModelType = { scheduleId: bigint taskTypeId: number topic: string + condition: string | null idFromDiary: number } @@ -43,6 +44,10 @@ export const TaskModel = sequelize.define('task', { type: DataTypes.TEXT, allowNull: false }, + condition: { + type: DataTypes.TEXT, + allowNull: true + }, idFromDiary: { type: DataTypes.INTEGER, allowNull: false, diff --git a/apps/api/src/routes/lessons/service/helpers/getFormattedGradebook.ts b/apps/api/src/routes/lessons/service/helpers/getFormattedGradebook.ts index 4cd7fc4e..b545eecf 100644 --- a/apps/api/src/routes/lessons/service/helpers/getFormattedGradebook.ts +++ b/apps/api/src/routes/lessons/service/helpers/getFormattedGradebook.ts @@ -9,13 +9,14 @@ export const getFormattedGradebook = ( const lessonType = rd.lessonType.name // Подготавливаем таски const tasks: Task[] = rd.tasks?.map((t) => { - const { idFromDiary: id, topic } = t + const { idFromDiary: id, topic, condition } = t const type = t.taskType.name const isRequired = t.requireds?.[0].isRequired ?? false - const mark = t.marks?.[0].markValue.value ?? undefined + const mark = t.marks?.[0]?.markValue?.value ?? undefined return { id, topic, + condition, type, isRequired, mark, diff --git a/apps/api/src/utils/fetcher.ts b/apps/api/src/utils/fetcher.ts index bb2e0434..b9573abd 100644 --- a/apps/api/src/utils/fetcher.ts +++ b/apps/api/src/utils/fetcher.ts @@ -1,6 +1,41 @@ -import ky from 'ky' +import ky, { type Input, type KyResponse, type Options } from 'ky' -export const fetcher = ky.extend({ +const defaultKy = ky.extend({ timeout: 10000, // 10 seconds retry: 2 }) + +const localFetcher = async ( + method: 'GET' | 'POST', + url: Input, + options?: Options +) => { + let result: KyResponse | null = null + + try { + switch (method) { + case 'GET': + result = await defaultKy.get(url, options) + break + case 'POST': + result = await defaultKy.post(url, options) + break + } + } catch {} + + return { + ok: result ? result.ok : false, + status: result ? result.status : 0, + headers: result ? result.headers : ({} as Headers), + json: async () => (result as KyResponse).json() + } +} + +export const fetcher = { + get: async (url: Input, options: Options) => { + return localFetcher('GET', url, options) + }, + post: async (url: Input, options: Options) => { + return localFetcher('POST', url, options) + } +} diff --git a/apps/api/src/worker/cookieUpdater/submodules/updateUserCookie.ts b/apps/api/src/worker/cookieUpdater/submodules/updateUserCookie.ts index 922ed81d..cd64db0f 100755 --- a/apps/api/src/worker/cookieUpdater/submodules/updateUserCookie.ts +++ b/apps/api/src/worker/cookieUpdater/submodules/updateUserCookie.ts @@ -15,11 +15,11 @@ export const updateUserCookie = async ( // 1. Авторизируемся const rawResponse = await ky.post(`${SERVER_URL}/services/security/login`, { - body: JSON.stringify({ + json: { login: user.login, password: user.password, isRemember: true - }) + } }) // Если дневник вернул что-то другое... diff --git a/apps/shared/src/api/original/index.ts b/apps/shared/src/api/original/index.ts index 5f0c7dee..9fd67714 100755 --- a/apps/shared/src/api/original/index.ts +++ b/apps/shared/src/api/original/index.ts @@ -181,16 +181,30 @@ export const AbsenceTypes: Record< > = { IsAbsent: 'Н', IsLate: 'О', - IsAbsentByNotValidReason: 'НП' + IsAbsentByNotValidReason: 'НП', + SickLeave: 'Б', + IsAbsentByValidReason: 'УП' } +export const AbsenceTypesColors: Record = { + IsAbsent: 'red', + IsLate: 'yellow', + IsAbsentByNotValidReason: 'red', + SickLeave: 'blue', + IsAbsentByValidReason: 'blue' +} + +export type ColorKeys = 'red' | 'yellow' | 'blue' + export const AbsenceTypesDescription: Record< AbsenceTypesDescriptionKeys, string > = { Н: 'Отсутствие', О: 'Опоздание', - НП: 'Неуважительное причина' + НП: 'Неуважительное причина', + УП: 'Уважительная причина', + Б: 'Пропуск по болезни' } export type TMark = MarkKeys @@ -204,6 +218,7 @@ export interface Task { isRequired: boolean mark: MarkKeys topic?: string + condition: string | null type: TLesson } diff --git a/apps/shared/src/api/original/keys.ts b/apps/shared/src/api/original/keys.ts index bf1e584d..e03ced9c 100755 --- a/apps/shared/src/api/original/keys.ts +++ b/apps/shared/src/api/original/keys.ts @@ -34,8 +34,10 @@ export type AbsenceTypesKeys = | 'IsAbsent' | 'IsLate' | 'IsAbsentByNotValidReason' + | 'IsAbsentByValidReason' + | 'SickLeave' -export type AbsenceTypesDescriptionKeys = 'Н' | 'О' | 'НП' +export type AbsenceTypesDescriptionKeys = 'Н' | 'О' | 'НП' | 'УП' | 'Б' export type AdditionalMarks = 'Д' | 'Зч' export type ExaminationKeys = 'DifferentiatedTest' | 'Test' | 'Exam' | 'Other' export type TermSubjectExaminationKeys = diff --git a/apps/web/package.json b/apps/web/package.json index c60ecf70..c3763f0d 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -18,7 +18,7 @@ "dependencies": { "@elysiajs/eden": "1.1.3", "@vkontakte/icons": "2.137.0", - "@vkontakte/vk-bridge": "^2.15.0", + "@vkontakte/vk-bridge": "^2.15.2", "@vkontakte/vk-bridge-react": "^1.0.1", "@vkontakte/vk-mini-apps-router": "1.4.6", "@vkontakte/vkui": "6.6.0", @@ -28,15 +28,15 @@ }, "devDependencies": { "@diary-spo/shared": "workspace:*", - "@happy-dom/global-registrator": "^15.7.3", - "@rsbuild/core": "^1.0.1-rc.5", - "@rsbuild/plugin-react": "^1.0.1-rc.5", + "@happy-dom/global-registrator": "^15.7.4", + "@rsbuild/core": "^1.0.18", + "@rsbuild/plugin-react": "^1.0.5", "@types/jsdom": "^21.1.7", - "@types/react": "^18.3.5", - "@types/react-dom": "^18.3.0", + "@types/react": "^18.3.12", + "@types/react-dom": "^18.3.1", "@vkontakte/vk-miniapps-deploy": "^0.1.8", "elysia": "1.1.12", - "gh-pages": "^6.1.1" + "gh-pages": "^6.2.0" }, "browserslist": { "production": [">0.2%", "not dead", "not op_mini all"], diff --git a/apps/web/src/app/AppWrapper/App/ModalRoot/modals/LessonModal/LessonTasks.tsx b/apps/web/src/app/AppWrapper/App/ModalRoot/modals/LessonModal/LessonTasks.tsx index 4aac1a43..b453b143 100755 --- a/apps/web/src/app/AppWrapper/App/ModalRoot/modals/LessonModal/LessonTasks.tsx +++ b/apps/web/src/app/AppWrapper/App/ModalRoot/modals/LessonModal/LessonTasks.tsx @@ -19,9 +19,17 @@ const Task: FC = ({ task, index }) => ( }> {LessonWorkType[task.type]} - + + + + {task?.topic} + {task?.condition && ( + + {task?.condition} + + )} diff --git a/apps/web/src/pages/Schedule/ui/LessonSubtitle/index.tsx b/apps/web/src/pages/Schedule/ui/LessonSubtitle/index.tsx index e6217c13..0314802a 100755 --- a/apps/web/src/pages/Schedule/ui/LessonSubtitle/index.tsx +++ b/apps/web/src/pages/Schedule/ui/LessonSubtitle/index.tsx @@ -1,4 +1,9 @@ -import { AbsenceTypes, type Gradebook, LessonType } from '@diary-spo/shared' +import { + AbsenceTypes, + AbsenceTypesColors, + type Gradebook, + LessonType +} from '@diary-spo/shared' import type { FC } from 'react' import { isDistant } from '../../../../shared' @@ -34,9 +39,7 @@ const LessonSubtitle: FC = ({ )} {gradebook?.absenceType && ( - + {AbsenceTypes[gradebook?.absenceType]} )} diff --git a/apps/web/src/shared/config/colors.ts b/apps/web/src/shared/config/colors.ts index e4aa6ee9..f3ee1bc0 100755 --- a/apps/web/src/shared/config/colors.ts +++ b/apps/web/src/shared/config/colors.ts @@ -6,6 +6,7 @@ export const VKUI_VIOLET = 'var(--vkui--color_accent_violet)' export const GREEN = 'linear-gradient(to right, #56ab2f, #a8e063)' export const RED = 'linear-gradient(to right, #ff416c, #ff4b2b)' export const ORANGE = 'linear-gradient(to right, #e56d1f, #f5af19)' +export const BLUE = 'linear-gradient(to right, #62cff4, #2c67f2)' export const VIOLET = 'linear-gradient(to right, rgb(73, 102, 207), rgb(154 80 255))' export const GRAY = '#959595' diff --git a/apps/web/src/shared/ui/Mark/helpers.ts b/apps/web/src/shared/ui/Mark/helpers.ts index 1f16dd97..d4b4ed5a 100755 --- a/apps/web/src/shared/ui/Mark/helpers.ts +++ b/apps/web/src/shared/ui/Mark/helpers.ts @@ -1,5 +1,5 @@ import type { Nullable } from '@diary-spo/shared' -import { GRAY, GREEN, ORANGE, RED, VIOLET } from '../../config' +import { BLUE, GRAY, GREEN, ORANGE, RED, VIOLET } from '../../config' import type { ReturnedMark } from '../../types.ts' export type Sizes = 'l' | 's' @@ -39,7 +39,11 @@ export const getBackgroundColor = (score?: Nullable): string => { return ORANGE case 'Н': case 'Д': + case 'НП': return RED + case 'Б': + case 'УП': + return BLUE default: return GRAY } diff --git a/apps/web/src/shared/ui/SubtitleWithBorder/index.tsx b/apps/web/src/shared/ui/SubtitleWithBorder/index.tsx index c56bc38b..74f519e8 100755 --- a/apps/web/src/shared/ui/SubtitleWithBorder/index.tsx +++ b/apps/web/src/shared/ui/SubtitleWithBorder/index.tsx @@ -5,6 +5,7 @@ type SubtitleColors = | 'red' | 'green' | 'yellow' + | 'blue' | 'red-outline' | 'green-outline' | 'yellow-outline' diff --git a/apps/web/src/shared/ui/SubtitleWithBorder/styles.ts b/apps/web/src/shared/ui/SubtitleWithBorder/styles.ts index c1447367..0ef39f73 100755 --- a/apps/web/src/shared/ui/SubtitleWithBorder/styles.ts +++ b/apps/web/src/shared/ui/SubtitleWithBorder/styles.ts @@ -1,4 +1,4 @@ -import { GREEN, ORANGE, RED } from '../../config' +import { BLUE, GREEN, ORANGE, RED } from '../../config' export const colors = { red: { @@ -31,6 +31,12 @@ export const colors = { borderRadius: '5px', border: '1px solid #ffb060', color: 'white' + }, + blue: { + background: BLUE, + borderRadius: '5px', + border: '1px solid #2c67f2', + color: 'white' } }