diff --git a/src/components/diagnosis/CompareBarChart.js b/src/components/diagnosis/CompareBarChart.js index fd87dd7..ca1a1be 100644 --- a/src/components/diagnosis/CompareBarChart.js +++ b/src/components/diagnosis/CompareBarChart.js @@ -11,7 +11,7 @@ const CompareBarChart = ({ pre, now, className, ...props }) => { let isMobileScreen = window.innerWidth < 768; const data = { - labels: ["이전 진단", "현재 진단."], + labels: ["이전 진단", "현재 진단"], datasets: [ { data: [pre, now, 32], diff --git a/src/hooks/Diagnosis/queries/useFetchRecentDiagnosis.js b/src/hooks/Diagnosis/queries/useFetchRecentDiagnosis.js index 5dc6b6c..074bded 100644 --- a/src/hooks/Diagnosis/queries/useFetchRecentDiagnosis.js +++ b/src/hooks/Diagnosis/queries/useFetchRecentDiagnosis.js @@ -22,6 +22,7 @@ const useFetchRecentDiagnosis = () => { isFetching, isSuccess, isCanRender: isSuccess && !isFetching, + isRecordExist: isSuccess && !isFetching && record?.length !== 0, }; }; diff --git a/src/pages/dementiaDiagnosis/DiagnosisResult.js b/src/pages/dementiaDiagnosis/DiagnosisResult.js index 326c387..488a78a 100644 --- a/src/pages/dementiaDiagnosis/DiagnosisResult.js +++ b/src/pages/dementiaDiagnosis/DiagnosisResult.js @@ -14,17 +14,19 @@ const DiagnosisResult = () => { const { state } = useLocation(); const { text, textColor } = getDiagnosisState(state.totalScore); const [recentResult, setRecentResult] = useState(0); - const { userId } = useRequireAuth; + const { userId, isAutoLoginSuccess } = useRequireAuth(); useEffect(() => { + if (!isAutoLoginSuccess) return; const fetchResult = async () => { const res = await DiagnosisController.getRecentDiagnosis({ userId, }); + console.log(res.data.result[1].totalScore); setRecentResult(res.data.result[1].totalScore ?? 0); }; fetchResult(); - }, []); + }, [isAutoLoginSuccess]); return (
@@ -46,7 +48,13 @@ const DiagnosisResult = () => { 전문가와의 상담을 권장합니다.
진단 결과 비교
- + ); diff --git a/src/pages/mypage/MyPage.jsx b/src/pages/mypage/MyPage.jsx index 770ed20..31ca0a7 100644 --- a/src/pages/mypage/MyPage.jsx +++ b/src/pages/mypage/MyPage.jsx @@ -10,12 +10,13 @@ import { useQueryClient } from "@tanstack/react-query"; import RecentDiagnosisGraph from "../../components/mypage/RecentDiagnosisGraph"; import useFetchRecentDiagnosis from "../../hooks/Diagnosis/queries/useFetchRecentDiagnosis"; import { RECENT_DIARIES_PAGE_PATH } from "./RecentDiaries"; +import SurveyIcon from "../../assets/home/button/btn_survey.png"; +import useGoDiagnosisGuide from "../../hooks/Diagnosis/useGoDiagnosisGuide"; export const MY_PAGE_PATH = "/mypage"; const MyPage = () => { const { user } = useFetchUser(); - const { record, isCanRender } = useFetchRecentDiagnosis(); const navigate = useNavigate(); const [isOpen, setIsOpen] = useState({ @@ -36,14 +37,10 @@ const MyPage = () => { return (
-

{user?.username}

+

{user?.username}

-

최근 진단 결과

-
- {isCanRender && } -
-

+

최근 일기 @@ -57,6 +54,44 @@ const MyPage = () => { ); }; +const RecentDiagnosisSection = ({ ...props }) => { + const { record, isCanRender, isRecordExist } = useFetchRecentDiagnosis(); + + const { goDiagnosisGuide } = useGoDiagnosisGuide(); + + if (isCanRender && isRecordExist) { + return ( + <> +

최근 진단 결과

+
+ +
+

+ + ); + } + if (isCanRender && !isRecordExist) { + return ( +

+ 사진 +
+
치매 진단 기록이 없습니다!
+
진단하러 가볼까요?
+
+
+ ); + } +}; + const LogoutButton = () => { const navigate = useNavigate(); const { setUserLogout } = userStore((state) => state);