From 8a4770debaf3c6fb6f9d857d8de6c8314abc76e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Rod?= Date: Tue, 17 Mar 2020 19:31:27 +0100 Subject: [PATCH] [js] migrace interface na type (TS) #74 --- frontend/src/auth/AuthContext.tsx | 4 ++-- frontend/src/components/DashboardDay.tsx | 2 +- frontend/src/components/buttons/AddButton.tsx | 2 +- .../src/components/buttons/BackButton.tsx | 2 +- .../src/components/buttons/CustomButton.tsx | 2 +- .../src/components/buttons/DeleteButton.tsx | 2 +- .../src/components/buttons/EditButton.tsx | 2 +- .../src/components/buttons/SubmitButton.tsx | 2 +- .../src/contexts/AttendanceStatesContext.tsx | 4 ++-- .../src/contexts/ClientsActiveContext.tsx | 6 +++--- .../src/contexts/CoursesVisibleContext.tsx | 6 +++--- frontend/src/contexts/GroupsActiveContext.tsx | 6 +++--- frontend/src/pages/Settings.tsx | 2 +- frontend/src/types/models.ts | 20 +++++++++---------- frontend/src/types/types.ts | 6 +++--- 15 files changed, 34 insertions(+), 34 deletions(-) diff --git a/frontend/src/auth/AuthContext.tsx b/frontend/src/auth/AuthContext.tsx index 7d37588b..1edd2cff 100644 --- a/frontend/src/auth/AuthContext.tsx +++ b/frontend/src/auth/AuthContext.tsx @@ -10,12 +10,12 @@ import Token from "./Token" /** Hodnota zbývající platnosti tokenu, při které dojde k požadavku na jeho obnovení. */ const AUTH_REFRESH_THRESHOLD = 60 * 65 // sekundy -> 65 minut -interface State { +type State = { isLoading: boolean isAuth: boolean } -interface Context extends State { +type Context = State & { login: (credentials: AuthorizationType) => void logout: fEmptyVoid isAuthenticated: (refreshExpiringToken?: boolean) => void diff --git a/frontend/src/components/DashboardDay.tsx b/frontend/src/components/DashboardDay.tsx index 70baa15c..a3b7af18 100644 --- a/frontend/src/components/DashboardDay.tsx +++ b/frontend/src/components/DashboardDay.tsx @@ -27,7 +27,7 @@ import LectureNumber from "./LectureNumber" import Loading from "./Loading" import UncontrolledTooltipWrapper from "./UncontrolledTooltipWrapper" -interface Props extends AttendanceStatesContextProps { +type Props = AttendanceStatesContextProps & { withoutWaiting?: boolean date: string shouldRefresh: boolean diff --git a/frontend/src/components/buttons/AddButton.tsx b/frontend/src/components/buttons/AddButton.tsx index f77d6089..5a74f337 100644 --- a/frontend/src/components/buttons/AddButton.tsx +++ b/frontend/src/components/buttons/AddButton.tsx @@ -2,7 +2,7 @@ import * as React from "react" import { Button, ButtonProps } from "reactstrap" import "./buttons.css" -interface Props extends ButtonProps { +type Props = ButtonProps & { content: string small?: boolean } diff --git a/frontend/src/components/buttons/BackButton.tsx b/frontend/src/components/buttons/BackButton.tsx index e8b7fd05..09e45c9f 100644 --- a/frontend/src/components/buttons/BackButton.tsx +++ b/frontend/src/components/buttons/BackButton.tsx @@ -3,7 +3,7 @@ import { Button, ButtonProps } from "reactstrap" import "./BackButton.css" import "./buttons.css" -interface Props extends ButtonProps { +type Props = ButtonProps & { content?: string } diff --git a/frontend/src/components/buttons/CustomButton.tsx b/frontend/src/components/buttons/CustomButton.tsx index 7ee285c8..e30cd8d9 100644 --- a/frontend/src/components/buttons/CustomButton.tsx +++ b/frontend/src/components/buttons/CustomButton.tsx @@ -2,7 +2,7 @@ import * as React from "react" import { Button, ButtonProps } from "reactstrap" import { noop } from "../../global/utils" -interface Props extends ButtonProps { +type Props = ButtonProps & { content: React.ReactNode } diff --git a/frontend/src/components/buttons/DeleteButton.tsx b/frontend/src/components/buttons/DeleteButton.tsx index 31500bee..ee40732a 100644 --- a/frontend/src/components/buttons/DeleteButton.tsx +++ b/frontend/src/components/buttons/DeleteButton.tsx @@ -1,7 +1,7 @@ import * as React from "react" import { Button, ButtonProps } from "reactstrap" -interface Props extends ButtonProps { +type Props = ButtonProps & { content?: string } diff --git a/frontend/src/components/buttons/EditButton.tsx b/frontend/src/components/buttons/EditButton.tsx index 876df40c..1df26329 100644 --- a/frontend/src/components/buttons/EditButton.tsx +++ b/frontend/src/components/buttons/EditButton.tsx @@ -5,7 +5,7 @@ import { Button, ButtonProps } from "reactstrap" import { makeIdFromString } from "../../global/utils" import UncontrolledTooltipWrapper from "../UncontrolledTooltipWrapper" -interface Props extends ButtonProps { +type Props = ButtonProps & { content?: string } diff --git a/frontend/src/components/buttons/SubmitButton.tsx b/frontend/src/components/buttons/SubmitButton.tsx index 56ec972c..979b053a 100644 --- a/frontend/src/components/buttons/SubmitButton.tsx +++ b/frontend/src/components/buttons/SubmitButton.tsx @@ -3,7 +3,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" import * as React from "react" import { Button, ButtonProps } from "reactstrap" -interface Props extends ButtonProps { +type Props = ButtonProps & { content?: string loading?: boolean disabled?: boolean diff --git a/frontend/src/contexts/AttendanceStatesContext.tsx b/frontend/src/contexts/AttendanceStatesContext.tsx index 2f307c89..4547bb2a 100644 --- a/frontend/src/contexts/AttendanceStatesContext.tsx +++ b/frontend/src/contexts/AttendanceStatesContext.tsx @@ -4,12 +4,12 @@ import { noop } from "../global/utils" import { AttendanceStateType } from "../types/models" import { fFunction } from "../types/types" -interface StateContext { +type StateContext = { isLoaded: boolean attendancestates: Array } -interface Context extends StateContext { +type Context = StateContext & { funcRefresh: (callback?: fFunction) => void } diff --git a/frontend/src/contexts/ClientsActiveContext.tsx b/frontend/src/contexts/ClientsActiveContext.tsx index ec8e8ba0..665fbd7c 100644 --- a/frontend/src/contexts/ClientsActiveContext.tsx +++ b/frontend/src/contexts/ClientsActiveContext.tsx @@ -4,16 +4,16 @@ import { clientName, noop } from "../global/utils" import { ClientActiveType } from "../types/models" import { fEmptyVoid, fFunction } from "../types/types" -interface StateContext { +type StateContext = { isLoaded: boolean clients: Array } -interface State extends StateContext { +type State = StateContext & { loadRequested: boolean } -interface Context extends StateContext { +type Context = StateContext & { funcRefresh: (callback?: fFunction) => void funcHardRefresh: fEmptyVoid } diff --git a/frontend/src/contexts/CoursesVisibleContext.tsx b/frontend/src/contexts/CoursesVisibleContext.tsx index 410ea592..a2367147 100644 --- a/frontend/src/contexts/CoursesVisibleContext.tsx +++ b/frontend/src/contexts/CoursesVisibleContext.tsx @@ -4,16 +4,16 @@ import { noop } from "../global/utils" import { CourseType } from "../types/models" import { fEmptyVoid, fFunction } from "../types/types" -interface StateContext { +type StateContext = { isLoaded: boolean courses: Array } -interface State extends StateContext { +type State = StateContext & { loadRequested: boolean } -interface Context extends StateContext { +type Context = StateContext & { funcRefresh: (callback?: fFunction) => void funcHardRefresh: fEmptyVoid } diff --git a/frontend/src/contexts/GroupsActiveContext.tsx b/frontend/src/contexts/GroupsActiveContext.tsx index 416ea77c..bf02c5b8 100644 --- a/frontend/src/contexts/GroupsActiveContext.tsx +++ b/frontend/src/contexts/GroupsActiveContext.tsx @@ -4,16 +4,16 @@ import { noop } from "../global/utils" import { GroupType } from "../types/models" import { fEmptyVoid, fFunction } from "../types/types" -interface StateContext { +type StateContext = { isLoaded: boolean groups: Array } -interface State extends StateContext { +type State = StateContext & { loadRequested: boolean } -interface Context extends StateContext { +type Context = StateContext & { funcRefresh: (callback?: fFunction) => void funcHardRefresh: fEmptyVoid } diff --git a/frontend/src/pages/Settings.tsx b/frontend/src/pages/Settings.tsx index 4fcd2a11..49e8434b 100644 --- a/frontend/src/pages/Settings.tsx +++ b/frontend/src/pages/Settings.tsx @@ -24,7 +24,7 @@ import { CustomRouteComponentProps, QA } from "../types/types" import APP_URLS from "../urls" import "./Settings.css" -interface VisibleProps extends QA { +type VisibleProps = QA & { visible: boolean } diff --git a/frontend/src/types/models.ts b/frontend/src/types/models.ts index 0181e8d9..403ad9f5 100644 --- a/frontend/src/types/models.ts +++ b/frontend/src/types/models.ts @@ -7,7 +7,7 @@ Reprezentují data tak, jak je obdržíme z API. Respektují způsoby vnoření dat a všechny možnosti API. ************************************************************************************************* */ -export interface ClientType extends Model { +export type ClientType = Model & { active: boolean email: string note: string @@ -16,34 +16,34 @@ export interface ClientType extends Model { surname: string } -export interface ClientActiveType extends ClientType { +export type ClientActiveType = ClientType & { normalized: Array } -export interface CourseType extends Model { +export type CourseType = Model & { name: string color: string duration: number visible: boolean } -export interface MembershipType extends Model { +export type MembershipType = Model & { prepaid_cnt: number client: ClientType } -export interface ApplicationType extends Model { +export type ApplicationType = Model & { note: string created_at: string client: ClientType course: CourseType } -export interface LectureTypeWithDate extends LectureType { +export type LectureTypeWithDate = LectureType & { start: string } -export interface LectureType extends Model { +export type LectureType = Model & { course: CourseType start: string | null group: null | GroupType @@ -53,7 +53,7 @@ export interface LectureType extends Model { attendances: Array } -export interface AttendanceType extends Model { +export type AttendanceType = Model & { client: ClientType remind_pay: boolean note: string @@ -62,14 +62,14 @@ export interface AttendanceType extends Model { attendancestate: AttendanceStateType["id"] } -export interface GroupType extends Model { +export type GroupType = Model & { name: string memberships: Array active: boolean course: CourseType } -export interface AttendanceStateType extends Model { +export type AttendanceStateType = Model & { name: string visible: boolean default?: boolean diff --git a/frontend/src/types/types.ts b/frontend/src/types/types.ts index 988e00cc..1b49cb71 100644 --- a/frontend/src/types/types.ts +++ b/frontend/src/types/types.ts @@ -3,17 +3,17 @@ import * as React from "react" import { RouteProps, StaticContext } from "react-router" import { RouteComponentProps } from "react-router-dom" -export interface Model { +export type Model = { id: number } export type ErrMsg = React.ReactElement | string -export interface CustomRouteProps extends RouteProps { +export type CustomRouteProps = RouteProps & { title: string } -export interface QA { +export type QA = { "data-qa"?: string }