From cbf23de73d7d88f1157da0e4abe7af4d30663bf7 Mon Sep 17 00:00:00 2001 From: skwldwld Date: Tue, 6 Aug 2024 22:45:59 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=94=94=EC=9E=90=EC=9D=B8=20=EB=94=94?= =?UTF-8?q?=ED=85=8C=EC=9D=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/atom.js | 3 ++- src/components/Common/MapCon.jsx | 2 +- .../MainPage/SelectedContentBox.jsx | 21 +++++++++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/atom.js b/src/atom.js index 3ca25f4..652d80d 100644 --- a/src/atom.js +++ b/src/atom.js @@ -20,5 +20,6 @@ export const selectedDateState = atom({ }); export const selectedPriceState = atom({ key: "selectedPrice", - default: { min: 0, max: 100000 }, + default: {}, + // default: { min: 0, max: 100000 }, }); diff --git a/src/components/Common/MapCon.jsx b/src/components/Common/MapCon.jsx index e3852f2..97f32b5 100644 --- a/src/components/Common/MapCon.jsx +++ b/src/components/Common/MapCon.jsx @@ -100,7 +100,7 @@ export default function MapCon() { const OverlayWrapper = styled.div` background-color: #4aabf9; width: 191px; - height: 34px; + height: 20px; border-radius: 10px; padding: 11px; box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); diff --git a/src/components/MainPage/SelectedContentBox.jsx b/src/components/MainPage/SelectedContentBox.jsx index bed9dbe..c267330 100644 --- a/src/components/MainPage/SelectedContentBox.jsx +++ b/src/components/MainPage/SelectedContentBox.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import styled from "styled-components"; import { useRecoilState } from "recoil"; import { selectedRegionState } from "../../atom"; @@ -6,8 +6,11 @@ import { selectedSportTypeState } from "../../atom"; import { selectedDisabilityTypeState } from "../../atom"; import { selectedDateState } from "../../atom"; import { selectedPriceState } from "../../atom"; +import { useLocation } from "react-router-dom"; const SelectedContentBox = ({ handleClearSelection, regionOptions = [] }) => { + const location = useLocation(); + const currentPath = location.pathname; const [selectedRegion, setsSlectedRegion] = useRecoilState(selectedRegionState); const [selectedSportType, setSelectedSportType] = useRecoilState( @@ -35,6 +38,10 @@ const SelectedContentBox = ({ handleClearSelection, regionOptions = [] }) => { return mainRegion ? mainRegion.name : null; }; + useEffect(() => { + if (currentPath === "/") setSelectedPrice({}); + }, []); + return ( <> {selectedRegion.map((item, index) => { @@ -88,11 +95,13 @@ const SelectedContentBox = ({ handleClearSelection, regionOptions = [] }) => { ))} - - # - {selectedPrice.min.toLocaleString()}원 ~{" "} - {selectedPrice.max.toLocaleString()}원 - + {selectedPrice.min !== undefined && selectedPrice.max !== undefined && ( + + # + {selectedPrice.min.toLocaleString()}원 ~{" "} + {selectedPrice.max.toLocaleString()}원 + + )} ); };