From 083252a03a039ebec157dd974a075aceba46bd31 Mon Sep 17 00:00:00 2001 From: toothlessdev Date: Tue, 10 Sep 2024 03:00:55 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20react-toastify=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 23 +++++++++++++++++++++++ package.json | 1 + src/App.tsx | 15 +++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/package-lock.json b/package-lock.json index dfa1ecb..9359bc8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.26.1", + "react-toastify": "^10.0.5", "react-transition-group": "^4.4.5", "zustand": "^4.5.5" }, @@ -5611,6 +5612,15 @@ "node": ">=12" } }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -11384,6 +11394,19 @@ "react-dom": ">=16.8" } }, + "node_modules/react-toastify": { + "version": "10.0.5", + "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-10.0.5.tgz", + "integrity": "sha512-mNKt2jBXJg4O7pSdbNUfDdTsK9FIdikfsIE/yUCxbAEXl4HMyJaivrVFcn3Elvt5xvCQYhUZm+hqTIu1UXM3Pw==", + "license": "MIT", + "dependencies": { + "clsx": "^2.1.0" + }, + "peerDependencies": { + "react": ">=18", + "react-dom": ">=18" + } + }, "node_modules/react-transition-group": { "version": "4.4.5", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", diff --git a/package.json b/package.json index aa04d39..d50d20e 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.26.1", + "react-toastify": "^10.0.5", "react-transition-group": "^4.4.5", "zustand": "^4.5.5" }, diff --git a/src/App.tsx b/src/App.tsx index 8cb7ab2..cb2df19 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,6 @@ import { BrowserRouter } from "react-router-dom"; +import { Bounce, ToastContainer } from "react-toastify"; +import "react-toastify/dist/ReactToastify.css"; import { FontsStyle } from "@/styles/fonts"; import { GlobalStyle } from "@/styles/global"; @@ -9,6 +11,19 @@ import { Global } from "@emotion/react"; export default function App() { return ( + From 260ae010c43a4f093ece0b049e9ac0766d137b42 Mon Sep 17 00:00:00 2001 From: toothlessdev Date: Tue, 10 Sep 2024 03:01:05 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20=EC=84=A0=ED=83=9D=20=EB=B9=84?= =?UTF-8?q?=EC=9C=A8=20API=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useRatioResult.tsx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/hooks/useRatioResult.tsx diff --git a/src/hooks/useRatioResult.tsx b/src/hooks/useRatioResult.tsx new file mode 100644 index 0000000..d184d96 --- /dev/null +++ b/src/hooks/useRatioResult.tsx @@ -0,0 +1,32 @@ +import { useEffect, useState } from "react"; +import { useSearchParams } from "react-router-dom"; + +import { api } from "@/config/axios"; + +interface RatioResultResponse { + status: number; + count: number; + total_count: number; +} + +export const useRatioResult = () => { + const [searchParams] = useSearchParams(); + + const [isPending, setIsPending] = useState(false); + const [totalCount, setTotalCount] = useState(0); + const [mbtiCount, setMbtiCount] = useState(0); + + useEffect(() => { + setIsPending(true); + api.get(`/stats?type=${searchParams.get("type")}`) + .then((data) => { + setMbtiCount(data.data.count); + setTotalCount(data.data.total_count); + }) + .finally(() => { + setIsPending(false); + }); + }, []); + + return { isPending, totalCount, mbtiCount }; +}; From ae8c37f8d5323ca1589125d318c98d9beae268af Mon Sep 17 00:00:00 2001 From: toothlessdev Date: Tue, 10 Sep 2024 03:01:21 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=ED=86=B5=EA=B3=84=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=8B=AB=EA=B8=B0=20=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AnalyticsPage.style.ts | 7 +++++++ src/pages/AnalyticsPage.tsx | 27 +++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/pages/AnalyticsPage.style.ts b/src/pages/AnalyticsPage.style.ts index de24ea4..acecf63 100644 --- a/src/pages/AnalyticsPage.style.ts +++ b/src/pages/AnalyticsPage.style.ts @@ -1,5 +1,12 @@ import styled from "@emotion/styled"; +export const AnalyticsPageWrapper = styled.div` + width: 100%; + height: 100%; + + margin-top: 60px; +`; + export const TitleContainer = styled.div` display: flex; flex-direction: column; diff --git a/src/pages/AnalyticsPage.tsx b/src/pages/AnalyticsPage.tsx index 9c41d81..3a4b7be 100644 --- a/src/pages/AnalyticsPage.tsx +++ b/src/pages/AnalyticsPage.tsx @@ -4,6 +4,7 @@ import { useNavigate } from "react-router-dom"; import Footer from "@/components/display/Footer"; import DropDown from "@/components/form/DropDown"; import TopBar from "@/components/layout/TopBar"; +import { TopBarContainer, TopBarWrapper } from "@/components/layout/TopBar.styled"; import { Text } from "@/components/typography"; import { useTop10 } from "@/hooks/useTop10"; @@ -13,7 +14,17 @@ import backIcon from "@/assets/back.svg"; import { results } from "@/constants/results"; -import { TitleContainer, TitleTop, Main, MiddleSection, TableContainer, Card, Rank, Type } from "./AnalyticsPage.style"; +import { + TitleContainer, + TitleTop, + Main, + MiddleSection, + TableContainer, + Card, + Rank, + Type, + AnalyticsPageWrapper, +} from "./AnalyticsPage.style"; export interface top10Response { top: [string, number][]; @@ -67,10 +78,18 @@ export default function AnalyticsPage() { }, [selectedDepartment]); return ( - <> - + + + + + + 전체 통계 + + + + 어떤 유형이 가장 많을까요? @@ -103,6 +122,6 @@ export default function AnalyticsPage() { {selectedDepartment && renderData(top10ByDepartment, top10ByDepartmentLoading, top10ByDepartmentError)}