-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from su-its/feat/home-screen/buttons
Feat/home screen/buttons
- Loading branch information
Showing
7 changed files
with
174 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<> | ||
<Button colorScheme="green" size="lg" onClick={onOpen}> | ||
Game Start | ||
</Button> | ||
|
||
<LoginModal isOpen={isOpen} onClose={onClose} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default GameStartButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<LoginModalProps> = ({ isOpen, onClose }) => { | ||
const [studentId, setStudentId] = useState(""); | ||
const router = useRouter(); | ||
|
||
const handleLogin = async () => { | ||
// TODO:ログイン済みかどうかを判別 | ||
// TODO:学籍番号を使用したログイン処理 | ||
console.log(studentId); | ||
router.push("/game"); | ||
}; | ||
|
||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose}> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader>続けるにはログインが必要です</ModalHeader> | ||
<ModalBody> | ||
<Input | ||
placeholder="学籍番号を入力してください" | ||
value={studentId} | ||
onChange={(e) => setStudentId(e.target.value)} | ||
/> | ||
</ModalBody> | ||
|
||
<ModalFooter> | ||
<Button colorScheme="blue" mr={3} onClick={handleLogin}> | ||
ログインして続行 | ||
</Button> | ||
<Button variant="ghost" onClick={onClose}> | ||
閉じる | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default LoginModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<> | ||
<Button colorScheme="blue" size="lg" onClick={handleLogout}> | ||
Logout | ||
</Button> | ||
|
||
<LogoutModal isOpen={isOpen} onClose={onClose} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default LogoutButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<LogoutModalProps> = ({ isOpen, onClose }) => { | ||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose}> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader>ログアウトしました</ModalHeader> | ||
<ModalBody>ご利用ありがとうございました。</ModalBody> | ||
<ModalFooter> | ||
<Button colorScheme="blue" mr={3} onClick={onClose}> | ||
OK | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default LogoutModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Button colorScheme="orange" size="lg" onClick={handleRouteRanking}> | ||
Ranking | ||
</Button> | ||
); | ||
}; | ||
|
||
export default RankingButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Flex justify="center" align="center" h="65vh"> | ||
<VStack spacing={8} align="stretch" width="50%" maxWidth="md" mx="auto"> | ||
{/* TODO: ログイン状況に応じて表示を切り替え */} | ||
<GameStartButton /> | ||
<RankingButton /> | ||
<LogoutButton /> | ||
</VStack> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default HomeMenuContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters