Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IT2810 H20
Team Ad Hoc
4-t-h
Commits
8b5a9281
Commit
8b5a9281
authored
Nov 13, 2020
by
Thor-Herman
Browse files
Add comments to types
#14
#15
parent
b6223b73
Changes
5
Hide whitespace changes
Inline
Side-by-side
prosjekt-4/types/filter.ts
View file @
8b5a9281
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
"
;
prosjekt-4/types/index.ts
View file @
8b5a9281
...
...
@@ -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
,
...
...
prosjekt-4/types/movies.ts
View file @
8b5a9281
...
...
@@ -23,6 +23,8 @@ export type MoviePage = {
results
:
Movie
[];
};
// Redux actions
type
FetchMovieAction
=
{
type
:
typeof
ADD_MOVIE
;
payload
:
Movie
;
...
...
prosjekt-4/types/ordering.ts
View file @
8b5a9281
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
"
,
...
...
prosjekt-4/types/page.ts
View file @
8b5a9281
...
...
@@ -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
:
{
...
...
Thor-Herman Van Eggelen
@theggele
mentioned in commit
a61dfa07
·
Nov 13, 2020
mentioned in commit
a61dfa07
mentioned in commit a61dfa07b591e4c8b918892e24239fafe26875fe
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment