Skip to content

Commit

Permalink
[js] migrace interface na type (TS) #74
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlukas committed Mar 17, 2020
1 parent 29c4546 commit 8a4770d
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions frontend/src/auth/AuthContext.tsx
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/DashboardDay.tsx
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/buttons/AddButton.tsx
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/buttons/BackButton.tsx
Expand Up @@ -3,7 +3,7 @@ import { Button, ButtonProps } from "reactstrap"
import "./BackButton.css"
import "./buttons.css"

interface Props extends ButtonProps {
type Props = ButtonProps & {
content?: string
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/buttons/CustomButton.tsx
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion 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
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/buttons/EditButton.tsx
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/buttons/SubmitButton.tsx
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/contexts/AttendanceStatesContext.tsx
Expand Up @@ -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<AttendanceStateType>
}

interface Context extends StateContext {
type Context = StateContext & {
funcRefresh: (callback?: fFunction) => void
}

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/contexts/ClientsActiveContext.tsx
Expand Up @@ -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<ClientActiveType>
}

interface State extends StateContext {
type State = StateContext & {
loadRequested: boolean
}

interface Context extends StateContext {
type Context = StateContext & {
funcRefresh: (callback?: fFunction) => void
funcHardRefresh: fEmptyVoid
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/contexts/CoursesVisibleContext.tsx
Expand Up @@ -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<CourseType>
}

interface State extends StateContext {
type State = StateContext & {
loadRequested: boolean
}

interface Context extends StateContext {
type Context = StateContext & {
funcRefresh: (callback?: fFunction) => void
funcHardRefresh: fEmptyVoid
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/contexts/GroupsActiveContext.tsx
Expand Up @@ -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<GroupType>
}

interface State extends StateContext {
type State = StateContext & {
loadRequested: boolean
}

interface Context extends StateContext {
type Context = StateContext & {
funcRefresh: (callback?: fFunction) => void
funcHardRefresh: fEmptyVoid
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Settings.tsx
Expand Up @@ -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
}

Expand Down
20 changes: 10 additions & 10 deletions frontend/src/types/models.ts
Expand Up @@ -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
Expand All @@ -16,34 +16,34 @@ export interface ClientType extends Model {
surname: string
}

export interface ClientActiveType extends ClientType {
export type ClientActiveType = ClientType & {
normalized: Array<string>
}

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
Expand All @@ -53,7 +53,7 @@ export interface LectureType extends Model {
attendances: Array<AttendanceType>
}

export interface AttendanceType extends Model {
export type AttendanceType = Model & {
client: ClientType
remind_pay: boolean
note: string
Expand All @@ -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<MembershipType>
active: boolean
course: CourseType
}

export interface AttendanceStateType extends Model {
export type AttendanceStateType = Model & {
name: string
visible: boolean
default?: boolean
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/types/types.ts
Expand Up @@ -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
}

Expand Down

0 comments on commit 8a4770d

Please sign in to comment.