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

Add comments to types #14 #15

parent b6223b73
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 CLEAR_FILTER = "CLEAR_FILTER";
export type FilterKeys = "" | "length" | "genre" | "year";
// Redux action
export type FilterAction = { type: string, payload: FilterState };
// Redux state
export type FilterState = {
genres: {[key in Genres]: boolean}
year: { to: string, from: string, },
......@@ -12,14 +26,6 @@ export type FilteringState = {
filter: FilterState,
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";
......@@ -2,6 +2,7 @@ import {Action} from "redux";
import {RootState} from "../reducers";
import {ThunkAction} from "redux-thunk";
// For using redux thunks
type AppThunk<ReturnType = void> = ThunkAction<
ReturnType,
RootState,
......
......@@ -23,6 +23,8 @@ export type MoviePage = {
results: Movie[];
};
// Redux actions
type FetchMovieAction = {
type: typeof ADD_MOVIE;
payload: Movie;
......
export const CHANGE_ORDERING = "CHANGE_ORDERING";
export const CLEAR_ORDERING = "CLEAR_ORDERING";
export type OrderingOptions = "" | "title" | "length" | "year"
// Redux actions
export type OrderingAction = { type: string, payload: OrderingActionPayload};
export type OrderingActionPayload = OrderingState | {key: OrderingOptions} | {order: "asc" | "desc"};
export type OrderingOptions = "" | "title" | "length" | "year"
// Redux state
export type OrderingState = {
key: OrderingOptions,
order: "asc" | "desc",
......
......@@ -2,12 +2,15 @@ export const PAGE_SIZE = 12;
export const CHANGE_PAGE = "CHANGE_PAGE";
export const UPDATE_TOTAL_PAGES = "UPDATE_TOTAL_PAGES";
// Redux state
export type PageState = {
total: number,
current: number,
next: number | null,
prev: number | null
}
// Redux actions
export type ChangePageAction = {
type: string,
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