From 54e862ef8e448fe8adf5700aed3d0e3108b801d0 Mon Sep 17 00:00:00 2001 From: LMS10 Date: Sun, 16 Feb 2025 03:21:23 +0900 Subject: [PATCH 01/11] =?UTF-8?q?=F0=9F=90=9B=20fix=20:=20=EC=8A=AC?= =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=8D=94=20=EB=B3=80=EA=B2=BD=20=ED=9B=84=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=EC=9D=B4=20=EB=B0=9C=EC=83=9D=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20onFinalChange=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=ED=95=B8=EB=93=A4=EB=9F=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wines/_components/FilterPrice.tsx | 14 ++++++- .../wines/_components/WineFilter.tsx | 7 +++- .../wines/_components/WineFilterModal.tsx | 37 ++++++++++--------- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/app/(with-header)/wines/_components/FilterPrice.tsx b/src/app/(with-header)/wines/_components/FilterPrice.tsx index fc6a58f..21ef3f2 100644 --- a/src/app/(with-header)/wines/_components/FilterPrice.tsx +++ b/src/app/(with-header)/wines/_components/FilterPrice.tsx @@ -5,9 +5,10 @@ const MAX_PRICE = 2000000; type FilterPriceProps = { priceRange: [number, number]; onPriceChange: (values: number[]) => void; + onFinalChange: (values: number[]) => void; }; -const FilterPrice = ({ priceRange, onPriceChange }: FilterPriceProps) => { +const FilterPrice = ({ priceRange, onPriceChange, onFinalChange }: FilterPriceProps) => { return (
PRICE
@@ -23,6 +24,7 @@ const FilterPrice = ({ priceRange, onPriceChange }: FilterPriceProps) => { max={MAX_PRICE} values={priceRange} onChange={onPriceChange} + onFinalChange={onFinalChange} renderTrack={({ props, children }) => (
{ {children}
)} - renderThumb={({ props, index }) =>
} + renderThumb={({ props, index }) => { + return ( +
+
+
+ ); + }} />
diff --git a/src/app/(with-header)/wines/_components/WineFilter.tsx b/src/app/(with-header)/wines/_components/WineFilter.tsx index 7958f5e..b6a5985 100644 --- a/src/app/(with-header)/wines/_components/WineFilter.tsx +++ b/src/app/(with-header)/wines/_components/WineFilter.tsx @@ -24,6 +24,11 @@ export default function WineFilter({ onChangeFilter }: WineFilterProps) { const handlePriceChange = (values: number[]) => { const [minPrice, maxPrice] = values; setPriceRange([minPrice, maxPrice]); + }; + + const handleFinalPriceChange = (values: number[]) => { + const [minPrice, maxPrice] = values; + setPriceRange([minPrice, maxPrice]); onChangeFilter({ type: selectedType, minPrice, maxPrice, rating: selectedRating }); }; @@ -35,7 +40,7 @@ export default function WineFilter({ onChangeFilter }: WineFilterProps) { return (
- +
); diff --git a/src/app/(with-header)/wines/_components/WineFilterModal.tsx b/src/app/(with-header)/wines/_components/WineFilterModal.tsx index 2f5fb32..036f4c6 100644 --- a/src/app/(with-header)/wines/_components/WineFilterModal.tsx +++ b/src/app/(with-header)/wines/_components/WineFilterModal.tsx @@ -24,10 +24,28 @@ export default function WineFilterModal({ isOpen, onClose, onApply, onFilterChan const [selectedRating, setSelectedRating] = useState(initialFilters.rating); const handlePriceChange = (values: number[]) => { - if (values.length !== 2) return; setPriceRange([values[0], values[1]]); }; + const handleFinalPriceChange = (values: number[]) => { + setPriceRange([values[0], values[1]]); + }; + + const handleFilterApply = () => { + onApply({ type: selectedType, minPrice: priceRange[0], maxPrice: priceRange[1], rating: selectedRating }); + onClose(); + }; + + const handleReset = () => { + setSelectedType(null); + setPriceRange([0, MAX_PRICE]); + setSelectedRating(null); + }; + + useEffect(() => { + onFilterChange({ type: selectedType, minPrice: priceRange[0], maxPrice: priceRange[1], rating: selectedRating }); + }, [selectedType, priceRange, selectedRating, onFilterChange]); + useEffect(() => { document.body.style.overflow = isOpen ? 'hidden' : 'auto'; return () => { @@ -51,21 +69,6 @@ export default function WineFilterModal({ isOpen, onClose, onApply, onFilterChan }; }, [handleKeyDown]); - const handleFilterApply = () => { - onApply({ type: selectedType, minPrice: priceRange[0], maxPrice: priceRange[1], rating: selectedRating }); - onClose(); - }; - - const handleReset = () => { - setSelectedType(null); - setPriceRange([0, MAX_PRICE]); - setSelectedRating(null); - }; - - useEffect(() => { - onFilterChange({ type: selectedType, minPrice: priceRange[0], maxPrice: priceRange[1], rating: selectedRating }); - }, [selectedType, priceRange, selectedRating, onFilterChange]); - if (!isOpen) return null; return ( @@ -83,7 +86,7 @@ export default function WineFilterModal({ isOpen, onClose, onApply, onFilterChan
- +
From 2613ee75f8e2d53bdf015b59e6699e91cc7dd368 Mon Sep 17 00:00:00 2001 From: LMS10 Date: Sun, 16 Feb 2025 03:32:15 +0900 Subject: [PATCH 02/11] =?UTF-8?q?=F0=9F=92=84=20design=20:=20Types,=20Rati?= =?UTF-8?q?ng=20=ED=95=84=ED=84=B0=EC=97=90=20hover=20=EC=8A=A4=ED=83=80?= =?UTF-8?q?=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(with-header)/wines/_components/FilterRating.tsx | 2 +- src/app/(with-header)/wines/_components/FilterTypes.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/(with-header)/wines/_components/FilterRating.tsx b/src/app/(with-header)/wines/_components/FilterRating.tsx index 073a193..a6fcfdf 100644 --- a/src/app/(with-header)/wines/_components/FilterRating.tsx +++ b/src/app/(with-header)/wines/_components/FilterRating.tsx @@ -20,7 +20,7 @@ const FilterRating = ({ selectedRating, onRatingChange }: FilterRatingProps) => onRatingChange(item.value)} />
- {item.label} + {item.label} ))}
diff --git a/src/app/(with-header)/wines/_components/FilterTypes.tsx b/src/app/(with-header)/wines/_components/FilterTypes.tsx index 15ea19d..e4d6cd4 100644 --- a/src/app/(with-header)/wines/_components/FilterTypes.tsx +++ b/src/app/(with-header)/wines/_components/FilterTypes.tsx @@ -16,7 +16,7 @@ const FilterTypes = ({ selectedType, onTypeChange }: FilterTypesProps) => { {['Red', 'White', 'Sparkling'].map((type) => ( +