movies.ts 992 Bytes
Newer Older
1
2
export const LOG_IN = 'LOG_IN';
export const LOG_OUT = 'LOG_OUT';
Thor-Herman's avatar
Thor-Herman committed
3
4

export const ADD_MOVIE = 'ADD_MOVIE';
5
export const ADD_MOVIES = 'ADD_MOVIES';
Thor-Herman's avatar
Thor-Herman committed
6
7
8
9
export const UPDATE_MOVIES = 'UPDATE_MOVIES';
export const SEARCH_TITLES = 'SEARCH_TITLES';

export type Movie = {
10
11
12
13
14
15
16
17
  id: number;
  title: string;
  genre: string;
  year: number;
  length: number;
  description: string;
  image: string;
};
Thor-Herman's avatar
Thor-Herman committed
18
19

export type MoviePage = {
20
21
22
23
24
  count: number;
  next: string | null;
  previous: string | null;
  results: Movie[];
};
Thor-Herman's avatar
Thor-Herman committed
25

Thor-Herman's avatar
Thor-Herman committed
26
27

// Redux actions
Thor-Herman's avatar
Thor-Herman committed
28
type FetchMovieAction = {
29
30
31
32
33
34
35
36
  type: typeof ADD_MOVIE;
  payload: Movie;
};

type AddMoviesAction = {
  type: typeof ADD_MOVIES;
  payload: Array<Movie>;
};
Thor-Herman's avatar
Thor-Herman committed
37
38

type UpdateMoviesAction = {
39
40
41
  type: typeof UPDATE_MOVIES;
  payload: Array<Movie>;
};
Thor-Herman's avatar
Thor-Herman committed
42
43

type SearchTitlesAction = {
44
45
46
  type: typeof SEARCH_TITLES;
  payload: Record<Movie['id'], Movie['title']>;
};
Thor-Herman's avatar
Thor-Herman committed
47

48
49
50
51
52
export type MovieActionTypes =
  | FetchMovieAction
  | SearchTitlesAction
  | UpdateMoviesAction
  | AddMoviesAction;