Skip to content

Commit

Permalink
Merge branch '25086-idra-news-events-split' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbutura committed Jun 4, 2024
2 parents 726aafc + de036cb commit 0515777
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,20 @@ const FacetedSearch: React.FC<FacetedSearchProps> = ({ searchIndex }) => {
)}
</Flex>
)}
<SearchListing
appConfig={appConfig}
meta={meta}
results={items || []}
searchIndex={searchIndex}
searchText={searchText}
/>
{total > 0 && (
<SearchListing
appConfig={appConfig}
meta={meta}
results={items || []}
searchIndex={searchIndex}
searchText={searchText}
/>
)}
{total == 0 && appConfig.emptyText && (
<Flex>

Check failure on line 119 in packages/next-drupal/src/components/blocks/FacetedSearch/FacetedSearch/FacetedSearch.tsx

View workflow job for this annotation

GitHub Actions / Linting

Replace `⏎··················{appConfig.emptyText}⏎················` with `{appConfig.emptyText}`
{appConfig.emptyText}
</Flex>
)}
</Container>
{total > 0 && (
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ interface TabsFiltersProps {
id: string
onChange: (id: string, value: string) => void
options: TabOption[]
value: string[]
value: string[],

Check failure on line 23 in packages/next-drupal/src/components/blocks/FacetedSearch/TabsFilters.tsx

View workflow job for this annotation

GitHub Actions / Linting

Delete `,`
hideShowAll?: boolean,

Check failure on line 24 in packages/next-drupal/src/components/blocks/FacetedSearch/TabsFilters.tsx

View workflow job for this annotation

GitHub Actions / Linting

Expected "hideShowAll" to come before "value"

Check failure on line 24 in packages/next-drupal/src/components/blocks/FacetedSearch/TabsFilters.tsx

View workflow job for this annotation

GitHub Actions / Linting

Delete `,`
}

const TabsFilters: React.FC<TabsFiltersProps> = ({
Expand All @@ -29,24 +30,27 @@ const TabsFilters: React.FC<TabsFiltersProps> = ({
onChange,
options,
value,
hideShowAll,

Check failure on line 33 in packages/next-drupal/src/components/blocks/FacetedSearch/TabsFilters.tsx

View workflow job for this annotation

GitHub Actions / Linting

Expected "hideShowAll" to come before "value"
}) => {
return (
<div className="search-tabs-filters">
<Button
className={classNames({
active: value.length === 0,
})}
shape="round"
onClick={() => onChange(id, '')}
{...ButtonOptionProps}
>
Show All
</Button>
{!hideShowAll && (
<Button
className={classNames({
active: value.length === 0,
})}
shape="round"
onClick={() => onChange(id, '')}
{...ButtonOptionProps}
>
Show All
</Button>
)}
{options.map((option) => (
<Button
key={option.values.value}
className={classNames({
active: value.includes(option.values.value),
active: value.includes(option.values.value)

Check failure on line 53 in packages/next-drupal/src/components/blocks/FacetedSearch/TabsFilters.tsx

View workflow job for this annotation

GitHub Actions / Linting

Insert `,`
})}
shape="round"
onClick={() => onChange(id, option.values.value)}
Expand Down
23 changes: 21 additions & 2 deletions packages/next-drupal/src/hooks/useSearchApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,29 @@ export const useSearchApp = (
djap.addFilter('field_date', todayDate, '>')
}

// EVENTS SORT
// EVENTS SORT/FILTER
if (searchIndex === 'events') {
if (sort?.date?.field) {
djap.addSort(sort.date.field)
let dateFilter = djap.getQueryObject()?.filter?.date;

Check failure on line 132 in packages/next-drupal/src/hooks/useSearchApp.ts

View workflow job for this annotation

GitHub Actions / Linting

Delete `;`

// If there is no date filter, default to showing upcoming events.
if (!dateFilter) {
// relative_date_facets module transforms a single date filter
// into a range.
// We need to set a future date so that the module will return
// all future events between now and +100 years.
let futureDate = new Date();

Check failure on line 140 in packages/next-drupal/src/hooks/useSearchApp.ts

View workflow job for this annotation

GitHub Actions / Linting

'futureDate' is never reassigned. Use 'const' instead

Check failure on line 140 in packages/next-drupal/src/hooks/useSearchApp.ts

View workflow job for this annotation

GitHub Actions / Linting

Delete `;`
futureDate.setFullYear(futureDate.getFullYear() + 100);
dateFilter = futureDate.toISOString().split('T')[0];
djap.addFilter('date', dateFilter)
}

let sortField = sort.date.field;
// Upcoming events should be sorted chronologically.
if (dateFilter >= todayDate) {
sortField = sortField.replace('-', '');
}
djap.addSort(sortField)
}
}

Expand Down

0 comments on commit 0515777

Please sign in to comment.