diff --git a/sadajo_fe/src/components/Category.jsx b/sadajo_fe/src/components/Category.jsx index f855cbb..4773a53 100644 --- a/sadajo_fe/src/components/Category.jsx +++ b/sadajo_fe/src/components/Category.jsx @@ -1,11 +1,188 @@ -import React from 'react'; +import React, { useState } from 'react'; + +const CategoryComponent = () => { + const [isDealAvailable, setIsDealAvailable] = useState(false); + const [selectedLocation, setSelectedLocation] = useState(''); + const [selectedCategory, setSelectedCategory] = useState(''); + const [selectedTip, setSelectedTip] = useState(''); + const [tipRange, setTipRange] = useState({ min: 0, max: 0 }); + + const rawLocations = ['장전동', '금사동', '금성동', '남산동', '노포동']; + const rawCategories = ['과자', '도넛', '빵', '초콜릿', '쿠키']; + const tipOptions = ['무료', '1,000원 이하', '5,000원 이하', '10,000원 이하']; + + const reorderList = (list, selected) => { + if (!selected) return [...list].sort(); + const sortedList = [...list].sort(); + return [selected, ...sortedList.filter((item) => item !== selected)]; + }; + + const handleReset = () => { + setIsDealAvailable(false); + setSelectedLocation(''); + setSelectedCategory(''); + setSelectedTip(''); + setTipRange({ min: 0, max: 0 }); + }; + + const handleApply = () => { + console.log('적용된 필터:', { + isDealAvailable, + selectedLocation, + selectedCategory, + selectedTip, + tipRange, + }); + }; + + const locations = reorderList(rawLocations, selectedLocation); + const categories = reorderList(rawCategories, selectedCategory); -function CategoryComponent() { return ( -
- +
+ {/* 필터 타이틀 */} +
+

필터

+ +
+ + {/* 거래 가능 */} +
+ +
+ +
+ + {/* 위치 */} +
+

위치

+

부산시 금정구

+ + {locations.map((loc) => ( + + ))} + + +
+ +
+ + {/* 카테고리 */} +
+

카테고리

+ + {categories.map((cat) => ( + + ))} + + +
+ +
+ + {/* 웨이터 팁 */} +
+

웨이터 팁

+ +
+ {tipOptions.map((tip) => ( + + ))} +
+ +
+ + setTipRange({ ...tipRange, min: Number(e.target.value) }) + } + className="w-20 p-2 border border-gray-300 rounded text-[14px] text-[#4F4F4F]" + /> + ~ + + setTipRange({ ...tipRange, max: Number(e.target.value) }) + } + className="w-20 p-2 border border-gray-300 rounded text-[14px] text-[#4F4F4F]" + /> +
+
+ + {/* 적용하기 */} +
+ +
); -} +}; -export default CategoryComponent; \ No newline at end of file +export default CategoryComponent;