Commit 8b5a9281 authored by Thor-Herman's avatar Thor-Herman
Browse files

Add comments to types #14 #15

parent b6223b73
import {OrderingState} from "./ordering"; import {OrderingState} from "./ordering";
export type FilterKeys = "" | "length" | "genre" | "year";
// For filtering components
export type FilterFormData = {
[key in Genres]: boolean;
} & {
from: string; // TODO: Remove
to: string;
};
// Action types
export const CHANGE_FILTER = "CHANGE_FILTER"; export const CHANGE_FILTER = "CHANGE_FILTER";
export const CLEAR_FILTER = "CLEAR_FILTER"; export const CLEAR_FILTER = "CLEAR_FILTER";
export type FilterKeys = "" | "length" | "genre" | "year"; // Redux action
export type FilterAction = { type: string, payload: FilterState };
// Redux state
export type FilterState = { export type FilterState = {
genres: {[key in Genres]: boolean} genres: {[key in Genres]: boolean}
year: { to: string, from: string, }, year: { to: string, from: string, },
...@@ -12,14 +26,6 @@ export type FilteringState = { ...@@ -12,14 +26,6 @@ export type FilteringState = {
filter: FilterState, filter: FilterState,
ordering: OrderingState, ordering: OrderingState,
} }
export type FilterAction = { type: string, payload: FilterState };
export type FilterFormData = {
[key in Genres]: boolean;
} & {
from: string;
to: string;
};
export type Genres = "Action" | "Comedy" | "Musical" | "Romance" | "Drama" | "Horror"; export type Genres = "Action" | "Comedy" | "Musical" | "Romance" | "Drama" | "Horror";
...@@ -2,6 +2,7 @@ import {Action} from "redux"; ...@@ -2,6 +2,7 @@ import {Action} from "redux";
import {RootState} from "../reducers"; import {RootState} from "../reducers";
import {ThunkAction} from "redux-thunk"; import {ThunkAction} from "redux-thunk";
// For using redux thunks
type AppThunk<ReturnType = void> = ThunkAction< type AppThunk<ReturnType = void> = ThunkAction<
ReturnType, ReturnType,
RootState, RootState,
......
...@@ -23,6 +23,8 @@ export type MoviePage = { ...@@ -23,6 +23,8 @@ export type MoviePage = {
results: Movie[]; results: Movie[];
}; };
// Redux actions
type FetchMovieAction = { type FetchMovieAction = {
type: typeof ADD_MOVIE; type: typeof ADD_MOVIE;
payload: Movie; payload: Movie;
......
export const CHANGE_ORDERING = "CHANGE_ORDERING"; export const CHANGE_ORDERING = "CHANGE_ORDERING";
export const CLEAR_ORDERING = "CLEAR_ORDERING"; export const CLEAR_ORDERING = "CLEAR_ORDERING";
export type OrderingOptions = "" | "title" | "length" | "year"
// Redux actions
export type OrderingAction = { type: string, payload: OrderingActionPayload}; export type OrderingAction = { type: string, payload: OrderingActionPayload};
export type OrderingActionPayload = OrderingState | {key: OrderingOptions} | {order: "asc" | "desc"}; export type OrderingActionPayload = OrderingState | {key: OrderingOptions} | {order: "asc" | "desc"};
export type OrderingOptions = "" | "title" | "length" | "year"
// Redux state
export type OrderingState = { export type OrderingState = {
key: OrderingOptions, key: OrderingOptions,
order: "asc" | "desc", order: "asc" | "desc",
......
...@@ -2,12 +2,15 @@ export const PAGE_SIZE = 12; ...@@ -2,12 +2,15 @@ export const PAGE_SIZE = 12;
export const CHANGE_PAGE = "CHANGE_PAGE"; export const CHANGE_PAGE = "CHANGE_PAGE";
export const UPDATE_TOTAL_PAGES = "UPDATE_TOTAL_PAGES"; export const UPDATE_TOTAL_PAGES = "UPDATE_TOTAL_PAGES";
// Redux state
export type PageState = { export type PageState = {
total: number, total: number,
current: number, current: number,
next: number | null, next: number | null,
prev: number | null prev: number | null
} }
// Redux actions
export type ChangePageAction = { export type ChangePageAction = {
type: string, type: string,
payload: { payload: {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment