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

Remove to and from properties from filter #15

parent a3dd8f47
......@@ -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 },
},
};
};
......@@ -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) {
......
......@@ -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) => (
......
......@@ -10,8 +10,7 @@ const initialFilterState = {
Comedy: false,
Musical: false,
Drama: false,
},
year: {to: "", from: ""} // TODO: Remove
}
}
// Stores which genres are currently checked
......
......@@ -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,
......
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