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) => ( + + ))} + + +