Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1638 - remove disabled filters on the campaign list page #1641

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/tests/smoke/smoke-campaigns.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test.describe('Campaigns page smoke tests - BG language version', async () => {
expect(
await campaignsPage.getFilterButtonsCount(),
'Filter buttons count is not correct!',
).toEqual(12)
).toEqual(4)
})

test('Support Now action button navigates to the Donation page for particular campaign', async () => {
Expand Down
12 changes: 11 additions & 1 deletion src/components/client/campaigns/CampaignFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ const Root = styled('div')(() => ({
color: theme.palette.primary.light,
borderBottom: `5px solid ${theme.palette.primary.light}`,
},

'&[aria-selected="true"]': {
color: theme.palette.primary.light,
borderBottom: `5px solid ${theme.palette.primary.light}`,
},
},
}))

Expand Down Expand Up @@ -103,10 +108,12 @@ export default function CampaignFilter() {
{Object.values(CampaignTypeCategory).map((category) => {
const count =
campaigns?.filter((campaign) => campaign.campaignType.category === category).length ?? 0
if (count === 0) return
return (
<IconButton
key={category}
disabled={count === 0}
aria-selected={selectedCategory === category}
className={classes.filterButtons}
onClick={() => setSelectedCategory(category)}>
{categories[category].icon ?? <Category fontSize="small" />}
Expand All @@ -116,7 +123,10 @@ export default function CampaignFilter() {
</IconButton>
)
})}
<IconButton className={classes.filterButtons} onClick={() => setSelectedCategory('ALL')}>
<IconButton
aria-selected={selectedCategory === 'ALL'}
className={classes.filterButtons}
onClick={() => setSelectedCategory('ALL')}>
<FilterNone fontSize="small" />
<Typography>
{t(`campaigns:filters.all`)} ({campaigns?.length ?? 0})
Expand Down
Loading