diff --git a/src/views/Home/components/ExistingUser/ExistingUser.tsx b/src/views/Home/components/ExistingUser/ExistingUser.tsx index 86bda3b..8bda9b7 100644 --- a/src/views/Home/components/ExistingUser/ExistingUser.tsx +++ b/src/views/Home/components/ExistingUser/ExistingUser.tsx @@ -1,51 +1,127 @@ -import { SetStateAction, useState } from "react" - +import React, { useState } from 'react'; import { - Button, - ChakraProvider, - Container, - FormControl, - Input, - Stack, - Text, - VStack, - extendTheme, - CSSReset, - Box, - Grid, - } from '@chakra-ui/react'; + Button, + ChakraProvider, + Container, + FormControl, + Input, + Stack, + Text, + VStack, + extendTheme, + CSSReset, + Box, + Grid, + Modal, + ModalOverlay, + ModalContent, + ModalHeader, + ModalBody, + ModalFooter, + ModalCloseButton, + Alert, + AlertIcon, +} from '@chakra-ui/react'; import { IScUserInfo } from "@/utils/types/sc.interface"; - -// Define custom Chakra UI theme to control transitions + const theme = extendTheme({ - initialColorMode: 'light', + initialColorMode: 'light', }); function ExistingUser(userInfo: IScUserInfo) { + const [isWordsVisible, setWordsVisible] = useState(false); + const [isPinModalOpen, setPinModalOpen] = useState(false); + const [pin, setPin] = useState(''); + const [showError, setShowError] = useState(false); + const correctPin = '1234'; + + const toggleWordsVisibility = () => { + if (pin === correctPin) { + setWordsVisible(!isWordsVisible); + setShowError(false); // Reset error state + } else { + setPinModalOpen(true); + } + }; + + const handlePinSubmit = () => { + if (pin === correctPin) { + setWordsVisible(true); + setPinModalOpen(false); + setShowError(false); // Reset error state + } else { + setShowError(true); + setPin(''); + setPinModalOpen(false); // Close the modal when PIN is incorrect + } + }; + + return ( + + + + + Username: {userInfo.username} + + + Address: {userInfo.address} + + + + {isWordsVisible && ( + + {userInfo.secretWords.map((word, index) => ( + + {word} + + ))} + + )} + setPinModalOpen(false)} isCentered> + + + Enter PIN + + + + setPin(e.target.value)} + /> + + + + + + + + - return ( - - - - - Username: {userInfo.username} - - - Address: {userInfo.address} - - - Words: - - - {userInfo.secretWords.map((word, index) => ( - - {word} - - ))} - - - - ); + {showError && ( + + + Incorrect PIN. Please try again. + + )} + + + ); } -export default ExistingUser; \ No newline at end of file +export default ExistingUser;