diff --git a/src/components/collection/Search.js b/src/components/collection/Search.js index 9ff29f1..8379804 100644 --- a/src/components/collection/Search.js +++ b/src/components/collection/Search.js @@ -19,12 +19,12 @@ export default class SearchCollection extends React.Component { this.handleChange = this.handleChange.bind(this); this.reset = this.reset.bind(this); - this.setInput(); + this.cleanInput(); this.parseQuery(); } - setInput() { + cleanInput() { let input = { name: "", text: "", @@ -40,7 +40,7 @@ export default class SearchCollection extends React.Component { mull: {unique: false, loyal: false, legendary: false, mixed: false}, gender: {ambiguous: false, female: false, male: false} }; - for (const key in API.sets) input.sets[key] = false; + for (const key in API.sets) input.sets[key.toLowerCase()] = false; this.input = input; } @@ -60,7 +60,7 @@ export default class SearchCollection extends React.Component { if (query.sets) { query.sets.split(',').map(item => { - this.input.sets[item.toUpperCase()] = true; + this.input.sets[item] = true; }); } @@ -82,7 +82,7 @@ export default class SearchCollection extends React.Component { temp = ""; Object.keys(this.input.sets).forEach((item) => { if (this.input.sets[item] == true) - temp += item.toLowerCase() + ","; + temp += item + ","; }); if (temp.length > 0) { queryString += "sets=" + temp.replace(/\,$/, '&'); @@ -92,7 +92,7 @@ export default class SearchCollection extends React.Component { temp = ""; Object.keys(this.input.types).forEach((item) => { if (this.input.types[item] == true) - temp += item.toLowerCase() + ","; + temp += item + ","; }); if (temp.length > 0) { queryString += "types=" + temp.replace(/\,$/, '&'); @@ -121,23 +121,28 @@ export default class SearchCollection extends React.Component { return (Loading...); } - let setsInput = []; - for (const key in API.sets) setsInput.push( - - ); - - let card_types = []; - ["attack", "battlegear", "creature", "location", "mugic"].forEach((item, i) => { - card_types.push() + let sets = []; + Object.keys(this.input.sets).forEach((item, i) => { + sets.push( + ); }); + let types = []; + Object.keys(this.input.types).forEach((item, i) => { + types.push() + }); + + let rarity = []; + + let gender = []; + return (
- {card_types} - {setsInput} + {types} + {rarity} + {sets} + {gender}
   @@ -157,12 +162,7 @@ export default class SearchCollection extends React.Component { event.preventDefault(); event.stopPropagation(); this.props.history.push('/collection/'); - this.setInput(); - // Object.keys(this.input).forEach((key) => { - // Object.keys(this.input[key]).forEach((i) => { - // (typeof(this.input[key][i]) === 'boolean' ? this.input[key][i] = false : this.input[key][i] = ''); - // }); - // }); + this.cleanInput(); } search = (e) => { @@ -186,9 +186,8 @@ export default class SearchCollection extends React.Component { let setsList = []; for (const key in this.input.sets) { - if (this.input.sets[key]) { - setsList.push({'$eq': key}); - } + if (this.input.sets[key]) + setsList.push({'$eq': key.toUpperCase()}); } if (setsList.length > 0) { attackResults = attackResults.find({'gsx$set': {'$or': setsList} });