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
eea65fd8
Commit
eea65fd8
authored
Nov 13, 2020
by
Thor-Herman
Browse files
Remove to and from properties from filter
#15
parent
a3dd8f47
Changes
5
Hide whitespace changes
Inline
Side-by-side
prosjekt-4/actions/filterActions.ts
View file @
eea65fd8
...
...
@@ -14,9 +14,8 @@ export const changeFilters = (data: FilterFormData) => {
type
:
CHANGE_FILTER
,
payload
:
{
genres
:
{
...
_
.
omit
(
data
,
[
'
to
'
,
'
from
'
])
,
// Will return every genre and not to and from properties.
TODO: Remove
...
data
,
// Will return every genre and not to and from properties.
},
year
:
{
to
:
data
.
to
,
from
:
data
.
from
},
},
};
};
prosjekt-4/actions/utility/decideFilters.ts
View file @
eea65fd8
...
...
@@ -4,9 +4,6 @@ import _ from 'lodash';
// Helper method. Converts the selected filters to REST query
export
const
decideFilters
=
({
filter
,
ordering
}:
FilteringState
)
=>
{
let
returnString
=
''
;
if
(
filter
.
year
.
to
&&
filter
.
year
.
from
)
{
// TODO: Remove
returnString
+=
`&year__gte=
${
filter
.
year
.
from
}
&year__lte=
${
filter
.
year
.
to
}
`
;
}
const
regex
=
decideRegex
(
filter
.
genres
);
returnString
+=
`&genre__regex=
${
regex
}
`
;
if
(
ordering
)
{
...
...
prosjekt-4/components/FilterList.tsx
View file @
eea65fd8
...
...
@@ -23,7 +23,7 @@ const FilterList = () => {
const
onPress
=
(
genre
:
Genres
)
=>
{
const
checked
=
checkedGenres
[
genre
];
dispatch
(
changeFilters
({...
checkedGenres
,
[
genre
]:
!
checked
,
to
:
""
,
from
:
""
}));
// TODO: Change
dispatch
(
changeFilters
({...
checkedGenres
,
[
genre
]:
!
checked
}));
};
const
filterItems
=
genres
.
map
((
genre
)
=>
(
...
...
prosjekt-4/reducers/filterReducer.ts
View file @
eea65fd8
...
...
@@ -10,8 +10,7 @@ const initialFilterState = {
Comedy
:
false
,
Musical
:
false
,
Drama
:
false
,
},
year
:
{
to
:
""
,
from
:
""
}
// TODO: Remove
}
}
// Stores which genres are currently checked
...
...
prosjekt-4/types/filter.ts
View file @
eea65fd8
...
...
@@ -5,10 +5,7 @@ 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
"
;
...
...
@@ -19,7 +16,6 @@ export type FilterAction = { type: string, payload: FilterState };
// Redux state
export
type
FilterState
=
{
genres
:
{[
key
in
Genres
]:
boolean
}
year
:
{
to
:
string
,
from
:
string
,
},
}
export
type
FilteringState
=
{
filter
:
FilterState
,
...
...
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