diff --git a/src/assets/images/chin-up.png b/src/assets/images/chin-up.png new file mode 100644 index 0000000..e8dbbc4 Binary files /dev/null and b/src/assets/images/chin-up.png differ diff --git a/src/assets/images/shoulder-twist.png b/src/assets/images/shoulder-twist.png new file mode 100644 index 0000000..3fa86d4 Binary files /dev/null and b/src/assets/images/shoulder-twist.png differ diff --git a/src/assets/images/tail-bone-sit.png b/src/assets/images/tail-bone-sit.png new file mode 100644 index 0000000..09cce05 Binary files /dev/null and b/src/assets/images/tail-bone-sit.png differ diff --git a/src/assets/images/tutle-neck.png b/src/assets/images/tutle-neck.png new file mode 100644 index 0000000..4ae479d Binary files /dev/null and b/src/assets/images/tutle-neck.png differ diff --git a/src/pages/AnalysisDashboard.tsx b/src/pages/AnalysisDashboard.tsx index a1887f1..c231f95 100644 --- a/src/pages/AnalysisDashboard.tsx +++ b/src/pages/AnalysisDashboard.tsx @@ -1,10 +1,18 @@ +import React, { useState, useRef, useEffect } from "react" +import { useQuery } from "@tanstack/react-query" import { getTodayAnalysis, TodayAnalysisData } from "@/api/analysis" import { poseType } from "@/api/pose" -import { useQuery } from "@tanstack/react-query" import { Calendar, ChevronLeft, ChevronRight } from "lucide-react" -import { useMemo } from "react" + +import TurtleNeckImage from "@/assets/images/tutle-neck.png" +import ShoulderTwistImage from "@/assets/images/shoulder-twist.png" +import ChinUpImage from "@/assets/images/chin-up.png" +import TailBoneSitImage from "@/assets/images/tail-bone-sit.png" const AnalysisDashboard = () => { + const [currentIndex, setCurrentIndex] = useState(0) + const carouselRef = useRef(null) + const { data, isLoading, isError } = useQuery({ queryKey: ["todayAnalysis"], queryFn: getTodayAnalysis, @@ -14,19 +22,51 @@ const AnalysisDashboard = () => { return data?.count.find((item: any) => item.type === type)?.count || 0 } - const totalCount = useMemo(() => { - return data?.count.reduce((acc, item) => acc + item.count, 0) || 0 - }, [data]) + const totalCount = data?.count.reduce((acc, item) => acc + item.count, 0) || 0 + + const carouselItems = [ + { title: "거북목", type: "TURTLE_NECK" as poseType, image: TurtleNeckImage }, + { title: "어깨 틀어짐", type: "SHOULDER_TWIST" as poseType, image: ShoulderTwistImage }, + { title: "턱 괴기", type: "CHIN_UTP" as poseType, image: ChinUpImage }, + { title: "꼬리뼈로 앉기", type: "TAILBONE_SIT" as poseType, image: TailBoneSitImage }, + ] + + const moveCarousel = (direction: "left" | "right") => { + if (direction === "left" && currentIndex > 0) { + setCurrentIndex(currentIndex - 1) + } else if (direction === "right" && currentIndex < carouselItems.length - 3) { + setCurrentIndex(currentIndex + 1) + } + } + + useEffect(() => { + if (carouselRef.current) { + const itemWidth = (carouselRef.current as HTMLElement).offsetWidth / 3 + ;(carouselRef.current as HTMLElement).style.transform = `translateX(-${currentIndex * itemWidth}px)` + } + }, [currentIndex]) return (

오늘의 자세 분석

- -
@@ -35,30 +75,53 @@ const AnalysisDashboard = () => { {isLoading &&
로딩 중입니다...
} {isError &&
데이터를 불러오는 것에 실패했습니다
} - {/* 상단 카드 섹션 */} {!isLoading && !isError && data && ( - <> -
-
+
+
+ {/* 고정된 전체 틀어짐 횟수 카드 */} +

전체 틀어짐 횟수

{totalCount}회

{/* 차트 이미지 삽입 */}
- {[ - { title: "거북목", type: "TURTLE_NECK" as poseType }, - { title: "어깨 틀어짐", type: "SHOULDER_TWIST" as poseType }, - { title: "턱 괴기", type: "CHIN_UTP" as poseType }, - ].map(({ title, type }, index) => ( -
-

{title}

-

{getPoseCount(type)}회

-
{/* 이미지 삽입 */}
+ + {/* 캐러셀 컨테이너 */} +
+ {/* 왼쪽 그라디언트 */} + {currentIndex > 0 && ( +
+ )} + + {/* 캐러셀 아이템 */} +
+ {carouselItems.map(({ title, type, image }, index) => ( +
+
+ {title} +
+

{title}

+
+
{getPoseCount(type)}
+
+
+
+
+
+ ))}
- ))} -
+ {/* 오른쪽 그라디언트 */} + {currentIndex < 1 && ( +
+ )} +
+
{/* 차트 섹션 */} -
+
@@ -82,7 +145,7 @@ const AnalysisDashboard = () => { ))}
- +
)}
) diff --git a/src/pages/HomePage.tsx b/src/pages/HomePage.tsx index c500667..7f0d3ba 100644 --- a/src/pages/HomePage.tsx +++ b/src/pages/HomePage.tsx @@ -10,7 +10,7 @@ const HomePage: React.FC = () => { } return ( -
+
{/* header */}