Commit e2331f47 authored by Thor-Herman's avatar Thor-Herman
Browse files

And types from project 3 #2

parent eb53019d
import {OrderingState} from "./ordering";
export const CHANGE_FILTER = "CHANGE_FILTER";
export const CLEAR_FILTER = "CLEAR_FILTER";
export type FilterKeys = "" | "length" | "genre" | "year";
export type FilterState = {
genres: {[key in Genres]: boolean}
year: { to: string, from: string, },
}
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";
import {Action} from "redux";
import RootState from "../reducers";
import {ThunkAction} from "redux-thunk";
type AppThunk<ReturnType = void> = ThunkAction<
ReturnType,
typeof RootState,
unknown,
Action<string>
>
export default AppThunk;
\ No newline at end of file
export const LOG_IN = "LOG_IN";
export const LOG_OUT = "LOG_OUT";
export const ADD_MOVIE = 'ADD_MOVIE';
export const UPDATE_MOVIES = 'UPDATE_MOVIES';
export const SEARCH_TITLES = 'SEARCH_TITLES';
export type Movie = {
id: number,
title: string,
genre: string,
year: number,
length: number,
description: string,
image: string,
}
export type MoviePage = {
count: number,
next: string | null,
previous: string | null,
results: Movie[],
}
type FetchMovieAction = {
type: typeof ADD_MOVIE,
payload: Movie
}
type UpdateMoviesAction = {
type: typeof UPDATE_MOVIES,
payload: Array<Movie>
}
type SearchTitlesAction = {
type: typeof SEARCH_TITLES;
payload: Record<Movie['id'], Movie['title']>
}
export type MovieActionTypes = FetchMovieAction | SearchTitlesAction | UpdateMoviesAction;
export const CHANGE_ORDERING = "CHANGE_ORDERING";
export const CLEAR_ORDERING = "CLEAR_ORDERING";
export type OrderingAction = { type: string, payload: OrderingActionPayload};
export type OrderingActionPayload = OrderingState | {key: OrderingOptions} | {order: "asc" | "desc"};
export type OrderingOptions = "" | "title" | "length" | "year"
export type OrderingState = {
key: OrderingOptions,
order: "asc" | "desc",
}
export const PAGE_SIZE = 12;
export const CHANGE_PAGE = "CHANGE_PAGE";
export const UPDATE_TOTAL_PAGES = "UPDATE_TOTAL_PAGES";
export type PageState = {
total: number,
current: number,
next: number | null,
prev: number | null
}
export type ChangePageAction = {
type: string,
payload: {
current: number,
next: number | null,
prev: number | null,
}
}
export type UpdatePageAction = {
type: string,
payload: { total: number, current: number },
}
export type PageActions = UpdatePageAction | ChangePageAction;
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