From 2304b998d8ba5f3d46c47a9821f391d9d4ac83aa Mon Sep 17 00:00:00 2001 From: "lkh14011424@gmail.com" Date: Sun, 26 Jan 2025 12:17:03 +0900 Subject: [PATCH] =?UTF-8?q?[feat/#146]=20=ED=81=AC=EB=A3=A8=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=9D=B4=EC=8A=88=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Crew/CrewList.tsx | 9 ++++-- src/components/Crew/CrewRanking.tsx | 28 +++++++++++-------- .../Crew/MyCrew/MyCrewRankingContainer.tsx | 2 +- src/layouts/CrewLayout.tsx | 9 ++++++ src/layouts/index.ts | 1 + src/pages/Crew.tsx | 2 +- src/pages/MyCrew.tsx | 2 +- src/routes/Router.tsx | 3 +- 8 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 src/layouts/CrewLayout.tsx diff --git a/src/components/Crew/CrewList.tsx b/src/components/Crew/CrewList.tsx index 54d37eb..b0671a8 100644 --- a/src/components/Crew/CrewList.tsx +++ b/src/components/Crew/CrewList.tsx @@ -9,7 +9,7 @@ import SortCrewIcon from "@assets/icons/crew-sort-icon.svg?react" import { ReactElement, useCallback, useEffect, useRef, useState, useMemo } from "react" import { modals } from "../Modal/Modals" import MyCrewRankingContainer from "./MyCrew/MyCrewRankingContainer" -import { useNavigate, useSearchParams } from "react-router-dom" +import { useLocation, useNavigate, useSearchParams } from "react-router-dom" import RoutePath from "@/constants/routes.json" import SearchIcon from "@assets/icons/crew-search-icon.svg?react" @@ -20,6 +20,7 @@ const SORT_LIST = [ const CrewList = (): ReactElement => { const navigate = useNavigate() + const location = useLocation() const { myGroupData, ranks, myRank, refetchAll, isLoading: isGroupLoading } = useMyGroup() const [isDropdownOpen, setIsDropdownOpen] = useState(false) // Dropdown 외부 클릭 감지 메모이제이션 @@ -117,7 +118,7 @@ const CrewList = (): ReactElement => {
empty crew
- {"만들어진 크루가 아직 없습니다."} + {keyword ? "검색된 크루가 없습니다." : "만들어진 크루가 아직 없습니다."}
) @@ -170,6 +171,10 @@ const CrewList = (): ReactElement => { } }, [openJoinCrewModal, searchParams, setSearchParams]) + useEffect(() => { + refetchAll() + }, [location.pathname]) + return (
{myGroupData && Object.keys(myGroupData).length > 0 && !params.keyword && ( diff --git a/src/components/Crew/CrewRanking.tsx b/src/components/Crew/CrewRanking.tsx index 0240565..9f422b4 100644 --- a/src/components/Crew/CrewRanking.tsx +++ b/src/components/Crew/CrewRanking.tsx @@ -46,21 +46,27 @@ const RankPillar = ({ rank, name, score, height }: any) => { {rank}등
-
{name}
-
자세 경고 {score}회
+
{name ?? "-"}
+
+ {score != null ? `자세 경고 ${score ? `${score}회` : "없음"}` : ""} +
) } const RankCard = ({ rank, name, score, isMe }: any) => (
-
-
{rank}
- {isMe ? "나" : name} +
+
{rank ?? "?"}
+ {isMe ? "나" : name}
- 자세경고 {score}회 + {`자세경고 ${ + score ? `${score}회` : "없음" + }`}
) @@ -71,16 +77,16 @@ const CrewRanking = ({ rankings, myRank }: { rankings: any[]; myRank: any }) =>
{/* 1, 2, 3등 랭킹 */}
- {topThree[0] && } - {topThree[1] && } - {topThree[2] && } + + +
{/* 전체 랭킹 목록 */}
- +
{rankings.map((rank, index) => ( diff --git a/src/components/Crew/MyCrew/MyCrewRankingContainer.tsx b/src/components/Crew/MyCrew/MyCrewRankingContainer.tsx index f0c9004..8b558ea 100644 --- a/src/components/Crew/MyCrew/MyCrewRankingContainer.tsx +++ b/src/components/Crew/MyCrew/MyCrewRankingContainer.tsx @@ -81,7 +81,7 @@ export default function MyCrewRankingContainer(props: MyCrewRankingContainerProp {/* 랭킹 표시 */}
- {ranks.length > 0 && myRank ? ( + {ranks.length > 0 ? ( ) : ( !isLoading && ( diff --git a/src/layouts/CrewLayout.tsx b/src/layouts/CrewLayout.tsx new file mode 100644 index 0000000..405fa02 --- /dev/null +++ b/src/layouts/CrewLayout.tsx @@ -0,0 +1,9 @@ +import { Outlet } from "react-router-dom" + +export default function CrewLayout() { + return ( +
+ +
+ ) +} diff --git a/src/layouts/index.ts b/src/layouts/index.ts index 9cb673c..9d08132 100644 --- a/src/layouts/index.ts +++ b/src/layouts/index.ts @@ -1,3 +1,4 @@ export { default as Layout } from "./BaseLayout" export { default as AnalysisLayout } from "./AnalysisLayout" export { default as MonitoringLayout } from "./MonitoringLayout" +export { default as CrewLayout } from "./CrewLayout" diff --git a/src/pages/Crew.tsx b/src/pages/Crew.tsx index ba8839b..3ffe219 100644 --- a/src/pages/Crew.tsx +++ b/src/pages/Crew.tsx @@ -2,7 +2,7 @@ import CrewList from "@/components/Crew/CrewList" export default function Crew() { return ( -
+
) diff --git a/src/pages/MyCrew.tsx b/src/pages/MyCrew.tsx index 3e32bbe..2918604 100644 --- a/src/pages/MyCrew.tsx +++ b/src/pages/MyCrew.tsx @@ -162,7 +162,7 @@ export default function MyCrew() {
{/* 랭킹 표시 */}
- {ranks.length > 0 && myRank ? ( + {ranks.length > 0 ? ( ) : ( !isLoading && ( diff --git a/src/routes/Router.tsx b/src/routes/Router.tsx index 42e8c86..b9d1a44 100644 --- a/src/routes/Router.tsx +++ b/src/routes/Router.tsx @@ -1,5 +1,6 @@ import Modals from "@/components/Modal/Modals" import RoutePath from "@/constants/routes.json" +import { CrewLayout } from "@/layouts" import AnalysisLayout from "@/layouts/AnalysisLayout" import BaseLayout from "@/layouts/BaseLayout" import HomeLayout from "@/layouts/HomeLayout" @@ -39,7 +40,7 @@ const Router: React.FC = () => { } /> - }> + }> } />