Skip to content

Commit

Permalink
fix: conditional on filter
Browse files Browse the repository at this point in the history
  • Loading branch information
irfan-maulana-tkp committed Jul 20, 2021
1 parent f3925bf commit 7f8f13b
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions components/search-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,22 @@ export function SearchForm({
<option value="">Semua</option>
{buckets.map((bucket: any, bIdx: number) => {
if (bucket.key) {
if (checkDocSize && bucket.doc_count > 0) {
if (checkDocSize) {
if (bucket.doc_count > 0) {
return (
<option
key={`option-${key}-${bIdx + 1}`}
value={bucket.key}
>
{bucket.key}
</option>
);
}
// Do not print, when doc_count = 0 and checkDocSize set to true
return null;
} else {
// FAQ page doesn't check the doc_count
// just pass checkDocSize props to false
return (
<option
key={`option-${key}-${bIdx + 1}`}
Expand All @@ -175,16 +190,6 @@ export function SearchForm({
</option>
);
}

// FAQ page doesn't check the doc_count
return (
<option
key={`option-${key}-${bIdx + 1}`}
value={bucket.key}
>
{bucket.key}
</option>
);
}
return null;
})}
Expand Down

0 comments on commit 7f8f13b

Please sign in to comment.