diff --git a/content/webapp/services/wellcome/common/filters.ts b/content/webapp/services/wellcome/common/filters.ts index 9c5c44fb6e..c534e60df7 100644 --- a/content/webapp/services/wellcome/common/filters.ts +++ b/content/webapp/services/wellcome/common/filters.ts @@ -630,13 +630,18 @@ const eventsAudienceFilter = ({ const eventsIsAvailableOnlineFilter = ({ events, props, -}: EventsFilterProps): BooleanFilter => ({ - type: 'boolean', - id: 'isAvailableOnline', - label: 'Catch-up events only', - count: events?.aggregations?.isAvailableOnline?.buckets?.[1]?.count || 0, - isSelected: !!props.isAvailableOnline, -}); +}: EventsFilterProps): BooleanFilter => { + const isAvailableOnlineTrueBucket = + events?.aggregations?.isAvailableOnline.buckets.find(b => b.data.value); + + return { + type: 'boolean', + id: 'isAvailableOnline', + label: 'Catch-up events only', + count: isAvailableOnlineTrueBucket?.count || 0, + isSelected: !!props.isAvailableOnline, + }; +}; // TODO re-add when https://github.com/wellcomecollection/content-api/issues/106 is done // const eventsInterpretationFilter = ({ diff --git a/content/webapp/services/wellcome/content/types/api.ts b/content/webapp/services/wellcome/content/types/api.ts index bb5be0b750..922630f54e 100644 --- a/content/webapp/services/wellcome/content/types/api.ts +++ b/content/webapp/services/wellcome/content/types/api.ts @@ -1,5 +1,6 @@ import { ArticleFormatId } from '@weco/content/data/content-format-ids'; import { + BooleanBucketData, WellcomeAggregation, WellcomeResultList, } from '@weco/content/services/wellcome'; @@ -116,7 +117,7 @@ export type ArticleAggregations = BasicAggregations & { export type EventAggregations = BasicAggregations & { audience: WellcomeAggregation; interpretation: WellcomeAggregation; - isAvailableOnline: WellcomeAggregation; + isAvailableOnline: WellcomeAggregation; }; // Results diff --git a/content/webapp/services/wellcome/index.ts b/content/webapp/services/wellcome/index.ts index e75cc21d78..70fa3cdbeb 100644 --- a/content/webapp/services/wellcome/index.ts +++ b/content/webapp/services/wellcome/index.ts @@ -55,9 +55,14 @@ export type UnidentifiedBucketData = { type: string; }; +export type BooleanBucketData = UnidentifiedBucketData & { + value: boolean; +}; + export type WellcomeAggregation< BucketData extends | IdentifiedBucketData + | BooleanBucketData | UnidentifiedBucketData = IdentifiedBucketData, > = { buckets: {