Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new shared & update deps #92

Merged
merged 27 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/base/mocs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Lesson } from 'diary-shared'
import { Lesson } from '@diary-spo/shared'
import { IMarksByDay } from '../../src/components'

/** Переданные данные **/
Expand Down
2 changes: 1 addition & 1 deletion __tests__/formatted/f.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
formatLessonName,
formatStatisticsData,
} from '@utils'
import { PerformanceCurrent } from 'diary-shared'
import { PerformanceCurrent } from '@diary-spo/shared'

describe('Тесты утилит для форматирования', () => {
/** convertStringToTime **/
Expand Down
3 changes: 2 additions & 1 deletion __tests__/marks/m.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
getSize,
setDefaultMark,
} from '@utils'
import { Task } from 'diary-shared'
import { Task } from '@diary-spo/shared'

import {
expectedExtractByDayData,
expectedInvalidExtractByDayData,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/marks/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PerformanceCurrent } from 'diary-shared'
import { PerformanceCurrent } from '@diary-spo/shared'
import { SubjectMarksMap } from '@utils'

/** createSubjectMarksMap */
Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,47 @@
"coverage": "vitest run --coverage"
},
"dependencies": {
"@vkontakte/icons": "^2.72.0",
"@vkontakte/vk-bridge": "^2.11.2",
"@vkontakte/icons": "^2.79.0",
"@vkontakte/vk-bridge": "^2.12.1",
"@vkontakte/vk-bridge-react": "^1.0.0",
"@vkontakte/vk-mini-apps-router": "^1.1.1",
"@vkontakte/vkui": "^5.9.4",
"@vkontakte/vk-mini-apps-router": "^1.2.0",
"@vkontakte/vkui": "^5.9.6",
"jshashes": "^1.0.8",
"preact": "^10.16.0",
"preact": "^10.19.2",
"react": "npm:@preact/compat",
"react-dom": "npm:@preact/compat"
},
"devDependencies": {
"@babel/eslint-parser": "^7.22.15",
"@preact/preset-vite": "^2.5.0",
"@babel/eslint-parser": "^7.23.3",
"@diary-spo/shared": "^1.8.5",
"@preact/preset-vite": "^2.7.0",
"@rollup/plugin-terser": "^0.4.4",
"@types/node": "^20.8.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.8.0",
"@types/node": "^20.9.1",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"@vitest/coverage-v8": "^0.34.6",
"@vkontakte/vk-miniapps-deploy": "^0.1.6",
"diary-shared": "^1.8.1",
"eslint": "^8.52.0",
"eslint": "^8.53.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-preact": "^1.3.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard-with-typescript": "^38.0.0",
"eslint-config-standard-with-typescript": "^39.1.1",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^27.4.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-n": "^16.0.2",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-n": "^16.3.1",
"eslint-plugin-preact": "^0.1.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"eslint-plugin-react-refresh": "^0.4.4",
"gh-pages": "^6.0.0",
"jsdom": "^22.1.0",
"prettier": "^3.0.3",
"prettier": "^3.1.0",
"typescript": "^5.2.2",
"vite": "^4.4.5",
"vite": "^5.0.0",
"vitest": "^0.34.6",
"vitest-localstorage-mock": "^0.0.1"
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ScheduleGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CardGrid } from '@vkontakte/vkui'
import { Day } from 'diary-shared'
import { Day } from '@diary-spo/shared'
import { FunctionComponent } from 'preact'
import { memo } from 'preact/compat'
import LessonCard from './UI/Lesson/LessonCard'
Expand Down
2 changes: 1 addition & 1 deletion src/components/UI/AttestationSubjects/SubjectCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Card, CardGrid, Div, InfoRow, Subhead, Title } from '@vkontakte/vkui'
import { FunctionalComponent } from 'preact'
import { Examinations } from 'diary-shared'
import { Examinations } from '@diary-spo/shared'
import Subject from './types'

interface ISubjectCard {
Expand Down
2 changes: 1 addition & 1 deletion src/components/UI/AttestationSubjects/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExaminationType } from 'diary-shared'
import { ExaminationType } from '@diary-spo/shared'

export default interface Subject {
id: string
Expand Down
6 changes: 3 additions & 3 deletions src/components/UI/Lesson/LessonCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FC, memo } from 'react'
import { Card, Group, Placeholder } from '@vkontakte/vkui'
import { useRouteNavigator } from '@vkontakte/vk-mini-apps-router'
import { useCallback } from 'preact/hooks'
import { Day, Gradebook, Timetable } from 'diary-shared'
import { Day, Gradebook, Timetable } from '@diary-spo/shared'
import useModal from '../../../store/useModal'
import { MODAL_PAGE_LESSON } from '../../../modals/ModalRoot'
import { formatLessonDate, isToday } from '@utils'
Expand Down Expand Up @@ -67,8 +67,8 @@ const LessonCard: FC<ILessonCard> = ({ lesson }) => {
const displayDay = isLessonToday
? 'Сегодня'
: dayEnded
? ' День завершён'
: undefined
? ' День завершён'
: undefined

const lessonComponents = useMemo(() => {
if (lesson.lessons && lesson.lessons.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/UI/Lesson/LessonCell.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from 'react'
import { SimpleCell } from '@vkontakte/vkui'
import { Gradebook, Lesson, Timetable } from 'diary-shared'
import { Gradebook, Lesson, Timetable } from '@diary-spo/shared'
import LessonSubtitle from './LessonSubtitle'
import { setDefaultMark } from '@utils'
import Mark from '../Mark'
Expand Down
2 changes: 1 addition & 1 deletion src/components/UI/Lesson/LessonSubtitle.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AbsenceTypes, Gradebook, LessonWorkType } from 'diary-shared'
import { AbsenceTypes, Gradebook, LessonWorkType } from '@diary-spo/shared'
import { FC } from 'react'
import TimeRemaining from '../TimeRemaining'
import SubtitleWithBorder from '../SubtitleWithBorder'
Expand Down
6 changes: 3 additions & 3 deletions src/components/UI/Marks/MarksByGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC } from 'react'
import { FC } from 'preact/compat'
import {
Card,
CardGrid,
Expand All @@ -8,7 +8,7 @@ import {
HorizontalScroll,
Title,
} from '@vkontakte/vkui'
import { PerformanceCurrent } from 'diary-shared'
import { PerformanceCurrent } from '@diary-spo/shared'
import { createSubjectMarksMap } from '@utils'
import MarksList from './MarksList'
import AverageMarkCell from './AverageMarkCell'
Expand All @@ -20,7 +20,7 @@ interface IMarksByGroup {

const MarksByGroup: FC<IMarksByGroup> = ({ marksForSubject }) => {
if (!marksForSubject) {
return NoData
return <NoData />
}

const subjectMarksMap = createSubjectMarksMap(marksForSubject)
Expand Down
2 changes: 1 addition & 1 deletion src/components/UI/Marks/MarksList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC } from 'react'
import { AbsenceTypes, Grade } from 'diary-shared'
import { AbsenceTypes, Grade } from '@diary-spo/shared'
import Mark from '../Mark'
import { SubjectMarksMap } from '@utils'

Expand Down
2 changes: 1 addition & 1 deletion src/components/UI/MarksByDay/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FunctionalComponent } from 'preact'
import { HorizontalScroll } from '@vkontakte/vkui'
import { PerformanceCurrent } from 'diary-shared'
import { PerformanceCurrent } from '@diary-spo/shared'
import { extractMarksByDay, sortByDay } from '@utils'
import { memo } from 'preact/compat'
import LessonGrades, { ILessonGrades } from './LessonGrades'
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Icon20RefreshOutline, Icon28SchoolOutline } from '@vkontakte/icons'

import bridge from '@vkontakte/vk-bridge'
// import { useRouteNavigator } from '@vkontakte/vk-mini-apps-router'
// import { Organization } from 'diary-shared';
// import { Organization } from '@diary-spo/shared';
// import { useRateLimitExceeded } from '../hooks'
// import { MODAL_COLLEGE_INFO } from '../modals/ModalRoot'
// import { getCollegeInfo } from '../methods'
Expand Down
2 changes: 1 addition & 1 deletion src/methods/server/getAds.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NotificationsResponse } from 'diary-shared'
import { NotificationsResponse } from '@diary-spo/shared'
import makeRequest from './makeRequest'

export const getAds = async (): Promise<NotificationsResponse[] | 418 | 429> =>
Expand Down
2 changes: 1 addition & 1 deletion src/methods/server/getAttestation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AttestationResponse } from 'diary-shared'
import { AttestationResponse } from '@diary-spo/shared'
import makeRequest from './makeRequest'

export const getAttestation = async (): Promise<
Expand Down
2 changes: 1 addition & 1 deletion src/methods/server/getCollegeInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Organization } from 'diary-shared'
import { Organization } from '@diary-spo/shared'
import makeRequest from './makeRequest'

export const getCollegeInfo = async (): Promise<Organization | 418 | 429> =>
Expand Down
2 changes: 1 addition & 1 deletion src/methods/server/getLessons.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Day } from 'diary-shared'
import { Day } from '@diary-spo/shared'
import { formatDateForRequest } from '@utils'
import makeRequest from './makeRequest'

Expand Down
2 changes: 1 addition & 1 deletion src/methods/server/getPerformance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PerformanceCurrent } from 'diary-shared'
import { PerformanceCurrent } from '@diary-spo/shared'
import makeRequest from './makeRequest'

export const getPerformance = async (): Promise<
Expand Down
6 changes: 5 additions & 1 deletion src/modals/LessonModal/LessonGrade.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { FC } from 'preact/compat'
import { Group, Header, SimpleCell } from '@vkontakte/vkui'
import { AbsenceTypes, AbsenceTypesDescription, Lesson } from 'diary-shared'
import {
AbsenceTypes,
AbsenceTypesDescription,
Lesson,
} from '@diary-spo/shared'
import { Mark, ExplanationTooltip } from '@components'
import LessonTasks from './LessonTasks'

Expand Down
2 changes: 1 addition & 1 deletion src/modals/LessonModal/LessonMainInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from 'react'
import { Group, Header, InfoRow, SimpleCell } from '@vkontakte/vkui'
import { LessonWorkType, TLesson } from 'diary-shared'
import { LessonWorkType, TLesson } from '@diary-spo/shared'
import { ExplanationTooltip } from '@components'
import { textToLink } from '@utils'

Expand Down
2 changes: 1 addition & 1 deletion src/modals/LessonModal/LessonTasks.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC } from 'react'
import { Lesson, LessonType } from 'diary-shared'
import { Lesson, LessonType } from '@diary-spo/shared'
import { InfoRow, Separator, SimpleCell, Spacing, Text } from '@vkontakte/vkui'
import { Mark } from '@components'
import { setDefaultMark } from '@utils'
Expand Down
2 changes: 1 addition & 1 deletion src/modals/LessonModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ModalPage, ModalPageHeader } from '@vkontakte/vkui'
import { Lesson } from 'diary-shared'
import { Lesson } from '@diary-spo/shared'
import { FC } from 'preact/compat'
import { useEffect, useState } from 'preact/hooks'
import LessonMainInfo, { ILessonMainInfo } from './LessonMainInfo'
Expand Down
2 changes: 1 addition & 1 deletion src/modals/data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Lesson } from 'diary-shared'
import { Lesson } from '@diary-spo/shared'

export const cleanData: Lesson = {
name: '',
Expand Down
2 changes: 1 addition & 1 deletion src/store/useModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useSyncExternalStore } from 'react'
import { Lesson } from 'diary-shared'
import { Lesson } from '@diary-spo/shared'
import { cleanData } from '../modals/data'
import createStore from './index'

Expand Down
2 changes: 1 addition & 1 deletion src/utils/formatted/formatStatisticsData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Grade, PerformanceCurrent, TextMark } from 'diary-shared'
import { Grade, PerformanceCurrent, TextMark } from '@diary-spo/shared'

/**
* Функция 'formatStatisticsData' обрабатывает данные оценок, вычисляя статистику на их основе.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/marks/calculateAverageMark.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Grade, TextMark } from 'diary-shared'
import { Grade, TextMark } from '@diary-spo/shared'

/**
* Функция 'calculateAverageMark' высчитывает средний балл учащегося до двух знаков после запятой.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/marks/createSubjectMarksMap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AbsenceType, PerformanceCurrent, TextMark } from 'diary-shared'
import { AbsenceType, PerformanceCurrent, TextMark } from '@diary-spo/shared'

export interface SubjectMarksMap {
[subjectName: string]: {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/marks/extractMarksByDay.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Grade, PerformanceCurrent } from 'diary-shared'
import { Grade, PerformanceCurrent } from '@diary-spo/shared'
import { IMarksByDay } from '@components'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/utils/marks/setDefaultMark.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Grade, Task, TextMark } from 'diary-shared'
import { Grade, Task, TextMark } from '@diary-spo/shared'

export type ReturnedMark = TextMark | 'Н' | 'ДЗ' | 'О' | 'Д' | number

Expand Down
4 changes: 2 additions & 2 deletions src/utils/setLessonDetails.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Lesson } from 'diary-shared'
import { Lesson, LessonWorkTypeKeys } from '@diary-spo/shared'
import { formatLessonName } from './formatted/formatLessonName'

/**
Expand Down Expand Up @@ -28,7 +28,7 @@ export const setLessonDetails = (lesson: Lesson) => {
gradebook: {
absenceType: gradebook?.absenceType,
id: gradebook?.id || 0,
lessonType: gradebook?.lessonType || 'Не задан',
lessonType: gradebook?.lessonType || ('Не задан' as LessonWorkTypeKeys),
tasks: tasksArray,
themes: gradebook?.themes,
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/Attestation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Panel,
Placeholder,
} from '@vkontakte/vkui'
import { AttestationResponse } from 'diary-shared'
import { AttestationResponse } from '@diary-spo/shared'
import { FC, lazy } from 'preact/compat'
import { useCallback, useEffect, useState } from 'preact/hooks'
import { PanelHeaderWithBack } from '@components'
Expand Down
14 changes: 7 additions & 7 deletions src/views/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Icon28DoorArrowLeftOutline,
Icon28ErrorCircleOutline,
} from '@vkontakte/icons'
import { AuthData } from 'diary-shared'
import { AuthData } from '@diary-spo/shared'
import { useEffect, useState } from 'preact/hooks'
import { ChangeEvent, FC } from 'preact/compat'
import { PanelHeaderWithBack } from '@components'
Expand Down Expand Up @@ -166,14 +166,14 @@ const LoginForm: FC<{ id: string }> = ({ id }) => {
const loginTopText = isLoginEmpty
? 'Логин'
: loginPattern.test(login)
? 'Логин введён'
: 'Введите корректный логин'
? 'Логин введён'
: 'Введите корректный логин'
const passwordTopText =
password === ''
? 'Пароль'
: isPasswordValid
? 'Пароль введён'
: 'Введите корректный пароль'
? 'Пароль введён'
: 'Введите корректный пароль'

return (
<Panel nav={id}>
Expand All @@ -194,8 +194,8 @@ const LoginForm: FC<{ id: string }> = ({ id }) => {
isLoginEmpty
? 'default'
: loginPattern.test(login)
? 'valid'
: 'error'
? 'valid'
: 'error'
}
bottom={isLoginEmpty || loginTopText}
bottomId="login-type"
Expand Down
2 changes: 1 addition & 1 deletion src/views/Marks.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Group, Panel, PanelSpinner, PullToRefresh } from '@vkontakte/vkui'
import { Icon28ErrorCircleOutline, Icon28InfoCircle } from '@vkontakte/icons'
import { PerformanceCurrent } from 'diary-shared'
import { PerformanceCurrent } from '@diary-spo/shared'
import { FC } from 'preact/compat'
import { useEffect, useState } from 'preact/hooks'
import {
Expand Down
2 changes: 1 addition & 1 deletion src/views/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Title,
} from '@vkontakte/vkui'
import { Icon28ErrorCircleOutline } from '@vkontakte/icons'
import { NotificationsResponse } from 'diary-shared'
import { NotificationsResponse } from '@diary-spo/shared'
import { useEffect, useState } from 'preact/hooks'
import { FC } from 'preact/compat'
import { PanelHeaderWithBack, SubtitleWithBorder } from '@components'
Expand Down
2 changes: 1 addition & 1 deletion src/views/Schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
Icon24ChevronRightCircle,
} from '@vkontakte/icons'
import { addDays, endOfWeek, startOfWeek } from '@vkontakte/vkui/dist/lib/date'
import { Day, PerformanceCurrent } from 'diary-shared'
import { Day, PerformanceCurrent } from '@diary-spo/shared'
import { getLessons, getPerformance } from '../methods'
import { ExplanationTooltip, PanelHeaderWithBack, Suspense } from '@components'
import {
Expand Down
Loading
Loading