Skip to content

Commit

Permalink
some search fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewplummer committed Sep 11, 2024
1 parent 54a41eb commit dc3320c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
11 changes: 7 additions & 4 deletions services/web/src/components/SearchDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ export default class SearchDropdown extends React.Component {
};

async fetchSelectedItems() {
const { value } = this.props;
if (Array.isArray(value) && !value.length) {
return;
}
try {
const selected = await this.fetch({
ids: (Array.isArray(this.props.value)
? this.props.value
: [this.props.value]
).map((item) => this.props.getOptionValue(item)),
ids: (Array.isArray(value) ? value : [value]).map((item) =>
this.props.getOptionValue(item)
),
});

this.setState({
Expand Down
18 changes: 17 additions & 1 deletion services/web/src/screens/Shops/List/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ export default class ShopList extends React.Component {
});
return data;
};

fetchCategories = async (props) => {
const { data } = await request({
method: 'POST',
path: '/1/categories/search',
body: props,
});
return data;
};
// --- Generator: end

getFilterMapping() {
Expand Down Expand Up @@ -109,11 +118,18 @@ export default class ShopList extends React.Component {
label="Country"
/>
<SearchFilters.Dropdown
onDataNeeded={(name) => this.fetchOwners({ name })}
search
onDataNeeded={this.fetchOwners}
name="owner"
label="Owner"
/>
<SearchFilters.Dropdown
search
multiple
onDataNeeded={this.fetchCategories}
name="categories"
label="Categories"
/>
<SearchFilters.DateRange
label="Created At"
name="createdAt"
Expand Down

0 comments on commit dc3320c

Please sign in to comment.