Skip to content

Commit

Permalink
bump deps (#142)
Browse files Browse the repository at this point in the history
* wip

* wip
  • Loading branch information
rodlukas committed Dec 15, 2023
1 parent fa4fe41 commit b61ff6a
Show file tree
Hide file tree
Showing 41 changed files with 534 additions and 213 deletions.
8 changes: 3 additions & 5 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ module.exports = {
ecmaVersion: 2018,
sourceType: "module",

// nastaveni potrebna pro type-aware typescript-eslint
// https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md
tsconfigRootDir: __dirname,
project: "./tsconfig.json",
project: true,
},
plugins: [
"import",
Expand All @@ -102,8 +100,8 @@ module.exports = {
extends: [
"eslint:recommended",

"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking", // pravidla zahrnujici typy
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",

"plugin:react/recommended",

Expand Down
504 changes: 425 additions & 79 deletions frontend/package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"@types/react-dom": "^17.0.25",
"@types/react-router-dom": "^5.3.3",
"@types/react-select": "^3.1.2",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"audit-ci": "^6.6.1",
"babel-jest": "^27.5.1",
"babel-loader": "^9.1.3",
Expand All @@ -50,11 +50,11 @@
"css-loader": "^6.8.1",
"css-minimizer-webpack-plugin": "^4.2.2",
"cssnano": "^5.1.15",
"csstype": "^3.1.2",
"csstype": "^3.1.3",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest-dom": "^4.0.3",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.0.1",
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ const searchOptions: Fuse.IFuseOptions<ClientActiveType> = {
/** Hlavní kostra aplikace. */
const Main: React.FC = () => {
const [isMenuOpened, setIsMenuOpened] = React.useState(false)
const [foundResults, setFoundResults] = React.useState<
Array<Fuse.FuseResult<ClientActiveType>>
>([])
const [foundResults, setFoundResults] = React.useState<Fuse.FuseResult<ClientActiveType>[]>([])
const [searchVal, setSearchVal] = React.useState("")
const authContext = useAuthContext()
const clientsActiveContext = useClientsActiveContext()
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/axiosRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const axiosInstance = axios.create({

/** Vloží do hlavičky HTTP požadavku JWT token. */
const setAuthHeader = (): void => {
axiosInstance.defaults.headers.common["Authorization"] = `${JWT_HEADER_PREFIX}${Token.get()}`
axiosInstance.defaults.headers.common.Authorization = `${JWT_HEADER_PREFIX}${Token.get()}`
}

/** Wrapper pro axios používaný pro HTTP požadavky na API. */
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/api/parseDjangoError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { AxiosError } from "axios"

/** Rozparsuje pro frontend chybu vrácenou z API. */
export function parseDjangoError(error: AxiosError): null | { [key: string]: any } | string {
export function parseDjangoError(error: AxiosError): null | Record<string, any> | string {
if (!error.request) {
return null
}
Expand All @@ -19,7 +19,7 @@ export function parseDjangoError(error: AxiosError): null | { [key: string]: any
// obecna chyba nevztazena ke konkretnimu field,
// nebo chyba muze obsahovat detailni informace (napr. metoda PUT neni povolena)
if ("non_field_errors" in json || "detail" in json) {
result = json["non_field_errors"] || json["detail"]
result = json.non_field_errors || json.detail
// stringify, kdyz prijde objekt
if (Array.isArray(result) && result.length !== 1) {
result = JSON.stringify(result)
Expand All @@ -33,7 +33,7 @@ export function parseDjangoError(error: AxiosError): null | { [key: string]: any
Object.keys(json).forEach((field) => {
json[field] = Array.isArray(json[field])
? json[field]
.map((subField: { [key: string]: any } | string | []) => {
.map((subField: Record<string, any> | string | []) => {
let errContent
if (typeof subField === "object" && !Array.isArray(subField)) {
errContent = `${Object.keys(subField)[0]}: ${
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/services/ApplicationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { API_DELIM, API_METHODS, API_URLS } from "../urls"
const baseUrl = API_URLS.applications.url

type Item = ApplicationType
type List = Array<Item>
type List = Item[]

/** Získá všechny zájemce o kurzy. */
function getAll(): Promise<List> {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/services/AttendanceStateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { API_DELIM, API_METHODS, API_URLS } from "../urls"
const baseUrl = API_URLS.attendanceStates.url

type Item = AttendanceStateType
type List = Array<Item>
type List = Item[]

/** Získá všechny stavy účasti. */
function getAll(): Promise<List> {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/api/services/ClientService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { API_DELIM, API_METHODS, API_URLS } from "../urls"
const baseUrl = API_URLS.clients.url

type Item = ClientType
type List = Array<Item>
export type ListWithActiveClients = Array<ClientActiveType>
type List = Item[]
export type ListWithActiveClients = ClientActiveType[]

/** Získá klienta. */
function get(id: Item["id"]): Promise<Item> {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/services/CourseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { API_DELIM, API_METHODS, API_URLS } from "../urls"
const baseUrl = API_URLS.courses.url

type Item = CourseType
type List = Array<Item>
type List = Item[]

/** Získá všechny kurzy. */
function getAll(): Promise<List> {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/services/GroupService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { API_DELIM, API_METHODS, API_URLS } from "../urls"
const baseUrl = API_URLS.groups.url

type Item = GroupType
type List = Array<Item>
type List = Item[]

/** Získá skupinu. */
function get(id: Item["id"]): Promise<Item> {
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/api/services/LectureService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const ordering = (asc: boolean): string =>
`&${API_ORDERING}=${!asc ? "-" : ""}${API_URLS.lectures.ordering.start}`

type Item = LectureType
type List = Array<Item>
type ListWithDate = Array<LectureTypeWithDate>
type List = Item[]
type ListWithDate = LectureTypeWithDate[]

/** Získá lekci. */
function get(id: Item["id"]): Promise<Item> {
Expand Down Expand Up @@ -77,7 +77,7 @@ function remove(id: Item["id"]): Promise<Item> {
})
}

function create(context: LecturePostApi | Array<LecturePostApi>): Promise<Item> {
function create(context: LecturePostApi | LecturePostApi[]): Promise<Item> {
return requestData<Item>({
url: baseUrl,
method: API_METHODS.post,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const API_URLS = Object.freeze({
})

/** Metody, které poskytuje API. */
export const API_METHODS: { [key: string]: Method } = Object.freeze({
export const API_METHODS: Record<string, Method> = Object.freeze({
get: "get",
post: "post",
patch: "patch",
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/Bank.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,9 @@ export default class Bank extends React.PureComponent<{}, State> {
<td
colSpan={duplicates ? 2 : undefined}
data-gdpr>
{commentObj && commentObj.value ? (
{commentObj?.value ? (
commentObj.value
) : targetAccountOwnerObj &&
targetAccountOwnerObj.value ? (
) : targetAccountOwnerObj?.value ? (
`Vlastník protiúčtu: ${targetAccountOwnerObj.value}`
) : (
<NoInfo />
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Celebration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import UncontrolledTooltipWrapper from "./UncontrolledTooltipWrapper"

type Props = {
/** ID označující, co slaví lektorka (svátek/narozeniny/nic). */
isUserCelebratingResult: number
isUserCelebratingResult: USER_CELEBRATION
}

/** Komponenta zobrazující přání k svátku/narozeninám lektorky. */
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/ClientsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ComponentsList from "./ComponentsList"

type Props = {
/** Pole se členstvími všech členů skupiny. */
memberships: Array<MembershipType>
memberships: MembershipType[]
}

/** Komponenta zobrazující čárkami oddělený seznam všech členů skupiny. */
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/ComponentsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react"

type Props = {
/** Pole jakýchkoliv komponent. */
components: Array<React.ReactNode>
components: React.ReactNode[]
}

/** Obecná komponenta zajišťující výpis pole komponent oddělených čárkami. */
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/DashboardDay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ type Props = AttendanceStatesContextProps & {
/** Datum pro zobrazované lekce. */
date: string
/** Typ aktualizace komponenty se dnem - pro propagaci aktualizací dalších dní (aktualizaci požaduje rodič). */
updateType: number
updateType: DASHBOARDDAY_UPDATE_TYPE
/** Funkce, která se zavolá po nějaké aktualizaci v rámci komponenty. */
setUpdateType: fEmptyVoid
}

type State = {
/** Pole lekcí pro daný den. */
lectures: Array<LectureTypeWithDate>
lectures: LectureTypeWithDate[]
/** Probíhá načítání (true). */
isLoading: boolean
}
Expand Down Expand Up @@ -84,7 +84,7 @@ class DashboardDay extends React.Component<Props, State> {
) {
// pokud se nema uplatnit prodleva nebo se nemeni den (napr. se upravil jen stav ucasti)
if (
this.props.withoutWaiting ||
this.props.withoutWaiting === true ||
(this.props.date === prevProps.date &&
this.props.updateType === DASHBOARDDAY_UPDATE_TYPE.DAY_UNCHANGED)
) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/GroupsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import GroupName from "./GroupName"

type Props = {
/** Pole se skupinami. */
groups: Array<GroupType>
groups: GroupType[]
}

/** Komponenta zobrazující čárkami oddělený seznam všech skupin, ve kterých je daný klient. */
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Props = {
const Loading: React.FC<Props> = ({ text = "Načítání" }) => {
const [loadingState, setLoadingState] = React.useState(LOADING_STATE.NORMAL_LOADING)

function setLoadingTimeout(newLoadingState: number): number {
function setLoadingTimeout(newLoadingState: LOADING_STATE): number {
return window.setTimeout(
() => setLoadingState(newLoadingState),
(newLoadingState === LOADING_STATE.LONG_LOADING
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/components/PrepaidCounters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import UncontrolledTooltipWrapper from "./UncontrolledTooltipWrapper"

type Props = {
/** Pole se členstvími všech klientů. */
memberships: Array<MembershipType>
memberships: MembershipType[]
/** Funkce, která se zavolá po aktualizaci počtu předplacených lekcí. */
funcRefreshPrepaidCnt: (
id: MembershipType["id"],
Expand All @@ -34,11 +34,11 @@ type Props = {
isGroupActive: boolean
}

/** Objekt držící počty předplacených lekcí jednotlivých klientů. */
type PrepaidCntObjectsType = {
/** ID členství: počet předplacených lekcí. */
[key: number]: MembershipType["prepaid_cnt"]
}
/**
* Objekt držící počty předplacených lekcí jednotlivých klientů.
* ID členství: počet předplacených lekcí.
*/
type PrepaidCntObjectsType = Record<number, MembershipType["prepaid_cnt"]>

/** Komponenta zobrazující počítadla předplacených lekcí pro členy skupiny. */
const PrepaidCounters: React.FC<Props> = (props) => {
Expand All @@ -57,7 +57,7 @@ const PrepaidCounters: React.FC<Props> = (props) => {
function onChange(e: React.ChangeEvent<HTMLInputElement>): void {
const target = e.currentTarget
const value = Number(target.value)
const id = Number(target.dataset.id as string)
const id = Number(target.dataset.id!)
setPrepaidCnts((prevPrepaidCnts) => {
// vytvorime kopii prepaidCnts (ma jen jednu uroven -> staci melka kopie)
const newPrepaidCnts = { ...prevPrepaidCnts }
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Loading from "./Loading"

type Props = {
/** Výsledky vyhledávání klientů. */
foundResults: Array<Fuse.FuseResult<ClientActiveType>>
foundResults: Fuse.FuseResult<ClientActiveType>[]
/** Vyhledávaný výraz. */
searchVal: string
/** Funkce pro zahájení vyhledávání klientů. */
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/contexts/AttendanceStatesContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type StateContext = {
/** Data v kontextu jsou načtená (true). */
isLoaded: boolean
/** Pole se stavy účastí. */
attendancestates: Array<AttendanceStateType>
attendancestates: AttendanceStateType[]
}

type Context = StateContext & {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/contexts/ClientsActiveContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type StateContext = {
/** Data v kontextu jsou načtená (true). */
isLoaded: boolean
/** Pole s aktivními klienty. */
clients: Array<ClientActiveType>
clients: ClientActiveType[]
}

type State = StateContext & {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/contexts/CoursesVisibleContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type StateContext = {
/** Data v kontextu jsou načtená (true). */
isLoaded: boolean
/** Pole s viditelnými klienty. */
courses: Array<CourseType>
courses: CourseType[]
}

type State = StateContext & {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/contexts/GroupsActiveContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type StateContext = {
/** Data v kontextu jsou načtená (true). */
isLoaded: boolean
/** Pole s aktivními skupinami. */
groups: Array<GroupType>
groups: GroupType[]
}

type State = StateContext & {
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/forms/FormApplications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type State = {
/** Poznámka k zájemci o kurz. */
note: ApplicationPostApiDummy["note"]
/** Pole klientů. */
clients: Array<ClientType>
clients: ClientType[]
/** Probíhá načítání (true). */
isLoading: boolean
/** Formulář byl odeslán (true). */
Expand Down Expand Up @@ -95,8 +95,8 @@ class FormApplications extends React.Component<Props, State> {
if (alertRequired("kurz nebo klient", course, client)) {
return
}
const courseId = (course as ApplicationType["course"]).id
const clientId = (client as ApplicationType["client"]).id
const courseId = course!.id
const clientId = client!.id
let request: Promise<ApplicationType>
const dataPost: ApplicationPostApi = { course_id: courseId, client_id: clientId, note }
if (this.isApplication(this.props.application)) {
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/forms/FormGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ type State = {
/** Kurz skupiny. */
course: GroupPostApiDummy["course"]
/** Pole členů skupiny. */
members: Array<ClientType>
members: ClientType[]
/** Pole klientů. */
clients: Array<ClientType>
clients: ClientType[]
/** Probíhá načítání (true). */
isLoading: boolean
/** Formulář byl odeslán (true). */
Expand All @@ -88,7 +88,7 @@ class FormGroups extends React.Component<Props, State> {
}

// pripravi pole se cleny ve spravnem formatu, aby fungoval react-select
getMembersOfGroup(members: Array<MembershipType>): Array<ClientType> {
getMembersOfGroup(members: MembershipType[]): ClientType[] {
return members.map((member) => member.client)
}

Expand All @@ -99,7 +99,7 @@ class FormGroups extends React.Component<Props, State> {

onSelectChange = (
name: "members" | "course",
obj?: CourseType | ReadonlyArray<ClientType> | ClientType | null,
obj?: CourseType | readonly ClientType[] | ClientType | null,
): void => {
this.props.setFormDirty()
// react-select muze vratit null (napr. pri smazani vsech) nebo undefined, udrzujme tedy stav konzistentni
Expand Down Expand Up @@ -132,7 +132,7 @@ class FormGroups extends React.Component<Props, State> {
if (alertRequired("kurz", course)) {
return
}
const courseId = (course as GroupType["course"]).id
const courseId = course!.id
let request: Promise<GroupType>
const dataPost: GroupPostApi = {
name,
Expand Down

0 comments on commit b61ff6a

Please sign in to comment.