Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/dateCourse/dateCourseSearchFilterOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ export default function DateCourseSearchFilterOption({
<div className="flex w-full gap-[16px] flex-wrap sm:justify-start justify-center">
{type === 'choice' &&
items?.map(({ label, value: apiValue }, idx) => {
const isSelected = value === apiValue; // 단일 선택 비교
return (
<DateCourseOptionButton
key={idx}
option={label}
isSelected={value === apiValue}
isSelected={isSelected}
onClick={() => {
onChange(apiValue!);
// ✅ 이미 선택되어 있으면 해제(null), 아니면 선택
onChange(isSelected ? null : apiValue!);
}}
/>
);
Expand Down
8 changes: 7 additions & 1 deletion src/pages/dateCourse/CoursePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function Course() {
const { openModal } = useModalStore();
const [current, setCurrent] = useState(1);

const { budget, datePlaces, dateDurationTime, startTime, mealTypes, transportation, userPreferredKeywords } = useFilterStore();
const { budget, datePlaces, dateDurationTime, startTime, mealTypes, transportation, userPreferredKeywords, reset } = useFilterStore();

const { data, isLoading, error } = useGetBookmarkedCourse({
page: current - 1,
Expand Down Expand Up @@ -62,6 +62,12 @@ export default function Course() {
{gradeData?.result.username ?? '회원님의'} 님만의 데이트 코스
</div>
<div className="flex gap-[12px] justify-center items-center sm:justify-end flex-col sm:flex-row">
<div
className="hover:cursor-pointer select-none px-[16px] py-[8px] gap-[4px] text-body2 rounding-16 flex rounding-16 w-fit border-[1px] border-default-gray-700 text-default-gray-700"
onClick={() => reset()}
>
필터 초기화
</div>
<div
className="hover:cursor-pointer select-none px-[16px] py-[8px] gap-[4px] text-body2 rounding-16 flex rounding-16 w-fit border-[1px] border-default-gray-700 text-default-gray-700"
onClick={() => openModal({ modalType: MODAL_TYPES.DateCourseSearchFilterModal })}
Expand Down
24 changes: 16 additions & 8 deletions src/pages/dateCourse/FindDateCourse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import useModalStore from '@/store/useModalStore';

function FindDateCourse() {
const { openModal } = useModalStore();
const [current, setCurrent] = useState(0);
const [current, setCurrent] = useState(1);
const navigate = useNavigate();
const { budget, datePlaces, dateDurationTime, startTime, mealTypes, transportation, userPreferredKeywords } = useFilterStore();
const { budget, datePlaces, dateDurationTime, startTime, mealTypes, transportation, userPreferredKeywords, reset } = useFilterStore();
useEffect(() => {
setCurrent(1);
}, [budget, datePlaces, dateDurationTime, startTime, mealTypes, transportation, userPreferredKeywords]);
Expand Down Expand Up @@ -48,12 +48,20 @@ function FindDateCourse() {
<div className="flex flex-col shadow-default rounding-16 px-[40px] py-[24px]">
<div className="flex w-full gap-[16px] flex-col items-center py-[24px] sm:flex-row sm:justify-between sm:items-center">
<div className="font-heading3 select-none flex">직접 데이트 코스 찾아보기</div>
<div
className="w-fit ml-auto px-[16px] flex-nowrap select-none py-[8px] rounding-16 flex rounding-16 border-[1px] border-default-gray-700 text-default-gray-700"
onClick={() => openModal({ modalType: MODAL_TYPES.DateCourseSearchFilterModal })}
>
<Filter stroke="#616161" />
검색 필터
<div className="flex gap-2">
<div
className="hover:cursor-pointer select-none px-[16px] py-[8px] gap-[4px] text-body2 rounding-16 flex rounding-16 w-fit border-[1px] border-default-gray-700 text-default-gray-700"
onClick={() => reset()}
>
필터 초기화
</div>
<div
className="w-fit ml-auto px-[16px] flex-nowrap select-none py-[8px] rounding-16 flex rounding-16 border-[1px] border-default-gray-700 text-default-gray-700"
onClick={() => openModal({ modalType: MODAL_TYPES.DateCourseSearchFilterModal })}
>
<Filter stroke="#616161" />
검색 필터
</div>
</div>
</div>
{isLoading ? (
Expand Down
2 changes: 1 addition & 1 deletion src/types/dateCourse/dateCourse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type TDateCourseOptionButtonProps = {
export type TDateCourseSearchFilterOption = {
options?: string[] | null;
value: string | string[] | null;
onChange: (value: string | string[]) => void;
onChange: (value: string | string[] | null) => void;
title: string;
subTitle?: string | null;
type: 'choice' | 'search' | 'time' | 'choices' | 'keyword';
Expand Down