-
Notifications
You must be signed in to change notification settings - Fork 2
/
FilterWidget.jsx
61 lines (52 loc) · 1.99 KB
/
FilterWidget.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React from "react";
import SpellClassWidget from "./SpellClassWidget";
import { DSAGrid, DSAGridItem} from '../controls/DSAGrid';
import FilterFavoriteWidget from "../controls/DSAFilterFavoriteWidget";
import FilterPropertiesWidget from "../controls/DSAFilterPropertiesWidget";
import {DSASpellClasses} from "../data/DSASpellClasses";
import DSASearchField from '../controls/DSASearchField';
const SearchWidget = ({name, onUserInput}) => {
return <DSASearchField
value={name}
label="Suche"
helperText="Suche nach einem Zauberspruch."
onChange={(v) => onUserInput(v, "names")} />
};
export default function FilterWidget(props) {
const {spells,
filter,
onSearchInput,
onPropertiesInput,
onClassInput,
onFavoriteInput} = props;
const {properties, spellClasses, favorite, name} = filter;
const m = "Merkmal" in properties ? properties["Merkmal"] : [];
const d = "Verbreitung" in properties ? properties["Verbreitung"] : [];
return <DSAGrid>
<DSAGridItem lg={3} md={6} sm={12} xs={12}>
<SearchWidget name={name} spells={spells} onUserInput={onSearchInput}/>
</DSAGridItem>
<DSAGridItem lg={3} md={6} sm={12} xs={12}>
<SpellClassWidget classes={spellClasses} onUserInput={onClassInput} />
</DSAGridItem>
<DSAGridItem lg={3} md={6} sm={12} xs={12}>
<FilterPropertiesWidget
selected={m}
properties={DSASpellClasses["Merkmal"]}
property="Merkmal"
onUserInput={onPropertiesInput}
/>
</DSAGridItem>
<DSAGridItem lg={3} md={6} sm={12} xs={12}>
<FilterPropertiesWidget
selected={d}
properties={DSASpellClasses["Verbreitung"]}
property="Verbreitung"
onUserInput={onPropertiesInput}
/>
</DSAGridItem>
<DSAGridItem>
<FilterFavoriteWidget favorite={favorite} onUserInput={onFavoriteInput}/>
</DSAGridItem>
</DSAGrid>
};