From 69c314ba18c373d61d6f19a3551e8e3c863aa605 Mon Sep 17 00:00:00 2001 From: Adrian Goh Jun Wei Date: Tue, 7 Jan 2025 18:44:27 +0800 Subject: [PATCH] Enhancement - collection tagfilters first (#973) * make 'others' a const * extract into consts * extract into getYearFilters * extract getCategoryFilters * add correct types * extract getTagFilters * rename to singular * move logic into each get*Filter function to improve readability * fix import * remove type renaming during import * refactor imports location * refactor: standardize code structure * only return filters with at least 2 items * add storybook * reorder collection filters to put "tags" first * do not render "category" if there's no category filter * remove shouldShowCategory * resolve merge * resolve merge --- .../next/layouts/Collection/utils/getAvailableFilters.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/components/src/templates/next/layouts/Collection/utils/getAvailableFilters.ts b/packages/components/src/templates/next/layouts/Collection/utils/getAvailableFilters.ts index 2e8530fe0..6a395c85f 100644 --- a/packages/components/src/templates/next/layouts/Collection/utils/getAvailableFilters.ts +++ b/packages/components/src/templates/next/layouts/Collection/utils/getAvailableFilters.ts @@ -7,9 +7,10 @@ import { getYearFilter } from "./getYearFilter" export const getAvailableFilters = ( items: ProcessedCollectionCardProps[], ): Filter[] => { + // TODO: Allow user to pass in order of filters to be shown return [ + ...getTagFilters(items), getCategoryFilter(items), getYearFilter(items), - ...getTagFilters(items), ].filter((filter) => filter.items.length >= 1) }