diff --git a/src/components/common/Filter/WineTypeFilter.tsx b/src/components/common/Filter/WineTypeFilter.tsx index 952e3bb..566681a 100644 --- a/src/components/common/Filter/WineTypeFilter.tsx +++ b/src/components/common/Filter/WineTypeFilter.tsx @@ -7,10 +7,16 @@ import useFilterStore, { WineType } from '@/stores/filterStore'; import DualSlider from '../slider/DualSlider'; interface WineTypeFilterProps { - showBorder: boolean; + showBorder?: boolean; + hasMargin?: boolean; + className?: string; } -const WineTypeFilter = ({ showBorder = false }: WineTypeFilterProps) => { +const WineTypeFilter = ({ + showBorder = false, + hasMargin = true, + className, +}: WineTypeFilterProps) => { const { type, setType, minPrice, maxPrice, setPriceRange, rating, setRating } = useFilterStore(); const wineTypeOptions: WineType[] = ['Red', 'White', 'Sparkling']; @@ -19,7 +25,7 @@ const WineTypeFilter = ({ showBorder = false }: WineTypeFilterProps) => { const borderClass = 'border-b border-gray-100'; return ( -
+
WINE TYPES
diff --git a/src/stores/filterStore.ts b/src/stores/filterStore.ts index e094e6d..a59a8fd 100644 --- a/src/stores/filterStore.ts +++ b/src/stores/filterStore.ts @@ -10,16 +10,22 @@ type FilterState = { setPriceRange: (range: [number, number]) => void; rating: string; setRating: (val: string) => void; + reset: () => void; }; -const useFilterStore = create((set) => ({ - type: 'Red', - setType: (val) => set({ type: val }), +const initialFilterState = { + type: 'Red' as WineType, minPrice: 0, maxPrice: 1000000, - setPriceRange: ([min, max]) => set({ minPrice: min, maxPrice: max }), rating: 'all', - setRating: (val) => set({ rating: val }), +}; + +const useFilterStore = create((set) => ({ + ...initialFilterState, + setType: (type) => set({ type }), + setPriceRange: ([minPrice, maxPrice]) => set({ minPrice, maxPrice }), + setRating: (rating) => set({ rating }), + reset: () => set(initialFilterState), })); export default useFilterStore;