From ab868f3bcb8c4c2042d3e85204af654df506f795 Mon Sep 17 00:00:00 2001 From: TkymHrt <23.h.takayama.nutfes@gmail.com> Date: Fri, 15 Nov 2024 03:59:56 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20=E3=83=87=E3=82=B6=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=81=AE=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF=E3=83=AA?= =?UTF-8?q?=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/app/page.tsx | 110 ++++++++++++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 37 deletions(-) diff --git a/app/src/app/page.tsx b/app/src/app/page.tsx index 674b767..77f5a29 100755 --- a/app/src/app/page.tsx +++ b/app/src/app/page.tsx @@ -4,10 +4,10 @@ import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import { Progress } from "@/components/ui/progress"; import Timer from "@/components/view/Timer"; -import type { MyScoreDetail, todayAssignment } from "@/types"; -import { set } from "date-fns"; +import type { MyScoreDetail, Score, todayAssignment } from "@/types"; import { useRouter } from "next/navigation"; import { useEffect, useState } from "react"; +import { LuArrowRight, LuCheckCircle } from "react-icons/lu"; import ClockIcon from "../../public/icons/icon-clock.svg"; import PhotoCameraIcon from "../../public/icons/icon-photo-camera.svg"; @@ -19,6 +19,7 @@ export default function Home() { const [progressCount, setProgressCount] = useState(0); const router = useRouter(); const [isAnsweredAll, setIsAnsweredAll] = useState(false); + const [highestScore, setHighestScore] = useState(0); useEffect(() => { const fetchData = async () => { @@ -42,6 +43,13 @@ export default function Home() { } const data = await response.json(); setMyScore(data); + + const maxScore: number = data.reduce( + (max: number, score: Score) => + score.point > max ? score.point : max, + 0, + ); + setHighestScore(maxScore); setProgressCount(66); // get api/assignment/today @@ -85,40 +93,40 @@ export default function Home() { }, []); return ( -
+
- {isLoading ? ( - -
- Loading... - + {!isAnsweredAll && + (isLoading ? ( + +
+ Loading... + +
+
+ ) : ( +
+ {assignment[0]?.assignTime && ( + // fixme [0]番目を参照しているがお題ごとに可変的にする必要あり。 + + )}
- - ) : ( -
- {assignment[0]?.assignTime && ( - // fixme [0]番目を参照しているがお題ごとに可変的にする必要あり。 - - )} -
- )} - -
-

今日のお題

-

撮影してスコアを競おう!

-
-

- {todayAssignment?.english} - {isAnsweredAll && "チャレンジ終了!"} -

-
- {todayAssignment && ( + ))} + {!isAnsweredAll && todayAssignment && ( + +
+

今日のお題

+

撮影してスコアを競おう!

+
+

+ {todayAssignment?.english} +

+
- )} -
-
+
+
+ )} + {isAnsweredAll && ( + +
+ +

+ 全課題完了 +

+

+ おめでとうございます。全ての課題をクリアしました! +

+
+

+ 最終スコア +

+

+ {highestScore}点 +

+
+ +
+
+ )}

過去のチャレンジ

{myScore.length === 0 ? (