diff --git a/typing-app/src/components/molecules/GameStartButton.tsx b/typing-app/src/components/molecules/GameStartButton.tsx new file mode 100644 index 0000000..cb3eb81 --- /dev/null +++ b/typing-app/src/components/molecules/GameStartButton.tsx @@ -0,0 +1,21 @@ +"use client"; + +import React from "react"; +import { Button, useDisclosure } from "@chakra-ui/react"; +import LoginModal from "./LoginModal"; // LoginModalコンポーネントをインポート + +const GameStartButton = () => { + const { isOpen, onOpen, onClose } = useDisclosure(); + + return ( + <> + + + + + ); +}; + +export default GameStartButton; diff --git a/typing-app/src/components/molecules/LoginModal.tsx b/typing-app/src/components/molecules/LoginModal.tsx new file mode 100644 index 0000000..0a3585a --- /dev/null +++ b/typing-app/src/components/molecules/LoginModal.tsx @@ -0,0 +1,57 @@ +import React, { useState } from "react"; +import { useRouter } from "next/navigation"; +import { + Modal, + ModalOverlay, + ModalContent, + ModalHeader, + ModalFooter, + ModalBody, + ModalCloseButton, + Button, + Input, +} from "@chakra-ui/react"; + +interface LoginModalProps { + isOpen: boolean; + onClose: () => void; +} + +const LoginModal: React.FC = ({ isOpen, onClose }) => { + const [studentId, setStudentId] = useState(""); + const router = useRouter(); + + const handleLogin = async () => { + // TODO:ログイン済みかどうかを判別 + // TODO:学籍番号を使用したログイン処理 + console.log(studentId); + router.push("/game"); + }; + + return ( + + + + 続けるにはログインが必要です + + setStudentId(e.target.value)} + /> + + + + + + + + + ); +}; + +export default LoginModal; diff --git a/typing-app/src/components/molecules/LogoutButton.tsx b/typing-app/src/components/molecules/LogoutButton.tsx new file mode 100644 index 0000000..336ba3e --- /dev/null +++ b/typing-app/src/components/molecules/LogoutButton.tsx @@ -0,0 +1,28 @@ +"use client"; + +import React from "react"; +import { useRouter } from "next/navigation"; +import { Button, useDisclosure } from "@chakra-ui/react"; +import LogoutModal from "./LogoutModal"; // 正しいパスに変更してください + +const LogoutButton: React.FC = () => { + const { isOpen, onOpen, onClose } = useDisclosure(); + const router = useRouter(); + + const handleLogout = async () => { + // TODO:ログアウト処理を実装 + onOpen(); + }; + + return ( + <> + + + + + ); +}; + +export default LogoutButton; diff --git a/typing-app/src/components/molecules/LogoutModal.tsx b/typing-app/src/components/molecules/LogoutModal.tsx new file mode 100644 index 0000000..42bd549 --- /dev/null +++ b/typing-app/src/components/molecules/LogoutModal.tsx @@ -0,0 +1,26 @@ +import React from "react"; +import { Modal, ModalOverlay, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from "@chakra-ui/react"; + +interface LogoutModalProps { + isOpen: boolean; + onClose: () => void; +} + +const LogoutModal: React.FC = ({ isOpen, onClose }) => { + return ( + + + + ログアウトしました + ご利用ありがとうございました。 + + + + + + ); +}; + +export default LogoutModal; diff --git a/typing-app/src/components/molecules/RankingButton.tsx b/typing-app/src/components/molecules/RankingButton.tsx new file mode 100644 index 0000000..7345d14 --- /dev/null +++ b/typing-app/src/components/molecules/RankingButton.tsx @@ -0,0 +1,21 @@ +"use client"; + +import { useRouter } from "next/navigation"; +import { Button } from "@chakra-ui/react"; + +const RankingButton = () => { + const router = useRouter(); + + const handleRouteRanking = async () => { + //TODO:ログインの維持を実装 + router.push("/ranking"); + }; + + return ( + + ); +}; + +export default RankingButton; diff --git a/typing-app/src/components/organism/HomeMenuContainer.tsx b/typing-app/src/components/organism/HomeMenuContainer.tsx new file mode 100644 index 0000000..1b044fe --- /dev/null +++ b/typing-app/src/components/organism/HomeMenuContainer.tsx @@ -0,0 +1,19 @@ +import { Flex, VStack } from "@chakra-ui/react"; +import GameStartButton from "../molecules/GameStartButton"; +import RankingButton from "../molecules/RankingButton"; +import LogoutButton from "../molecules/LogoutButton"; + +const HomeMenuContainer = () => { + return ( + + + {/* TODO: ログイン状況に応じて表示を切り替え */} + + + + + + ); +}; + +export default HomeMenuContainer; diff --git a/typing-app/src/components/pages/Home.tsx b/typing-app/src/components/pages/Home.tsx index 440ae8f..df1d7db 100644 --- a/typing-app/src/components/pages/Home.tsx +++ b/typing-app/src/components/pages/Home.tsx @@ -1,13 +1,10 @@ import React from "react"; -import { Text, VStack } from "@chakra-ui/react"; +import HomeMenuContainer from "../organism/HomeMenuContainer"; const HomePage: React.FC = () => { return ( <> - - Hello, World! - Welcome to the ITS Room - + ); };