From 52516ead648cd36ccb62bba3d81b42bcb929c030 Mon Sep 17 00:00:00 2001 From: LSJ Date: Fri, 22 Nov 2024 18:09:53 +0900 Subject: [PATCH] . --- components/atoms/buttons/WritingButton.tsx | 9 ++- .../organisms/location/LocationSearch.tsx | 2 +- pages/api/auth/[...nextauth].ts | 13 +++- pages/login.tsx | 44 +---------- pages/loginId.tsx | 78 +++++++++++++++++++ pages/loginRegister.tsx | 51 ++++++++++++ 6 files changed, 151 insertions(+), 46 deletions(-) create mode 100644 pages/loginId.tsx create mode 100644 pages/loginRegister.tsx diff --git a/components/atoms/buttons/WritingButton.tsx b/components/atoms/buttons/WritingButton.tsx index 14bc9799d..f576c6853 100644 --- a/components/atoms/buttons/WritingButton.tsx +++ b/components/atoms/buttons/WritingButton.tsx @@ -7,13 +7,18 @@ interface IWritingIcon { url: string; isBottomNav?: boolean; onClick?: () => void; + type?: "thunder"; } -function WritingButton({ url, isBottomNav = true, onClick }: IWritingIcon) { +function WritingButton({ url, type, isBottomNav = true, onClick }: IWritingIcon) { return ( - + {type === "thunder" ? ( + + ) : ( + + )} ); diff --git a/components/organisms/location/LocationSearch.tsx b/components/organisms/location/LocationSearch.tsx index 8f62d4b3d..d60d44e5e 100644 --- a/components/organisms/location/LocationSearch.tsx +++ b/components/organisms/location/LocationSearch.tsx @@ -57,7 +57,7 @@ function LocationSearch({ } diff --git a/pages/api/auth/[...nextauth].ts b/pages/api/auth/[...nextauth].ts index 7b1d6d69c..0df7304b2 100644 --- a/pages/api/auth/[...nextauth].ts +++ b/pages/api/auth/[...nextauth].ts @@ -129,7 +129,18 @@ export const authOptions: NextAuthOptions = { return session; } - if (session.user.name === "guest") { + if (session.user.name === "게스트") { + session.user = { + id: "66f29811e0f0564ae35c52a4", + uid: "1234567890", + name: "게스트", + role: "member", + profileImage: + "http://img1.kakaocdn.net/thumb/R110x110.q70/?fname=http://t1.kakaocdn.net/account_images/default_profile.jpeg", + isActive: true, + location: "수원", + }; + } else if (session.user.name === "guest") { session.user = { id: "66f29811e0f0564ae35c52a4", uid: "1234567890", diff --git a/pages/login.tsx b/pages/login.tsx index 1f99e9a83..da01cc243 100644 --- a/pages/login.tsx +++ b/pages/login.tsx @@ -15,7 +15,6 @@ import Image from "next/image"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; import styled from "styled-components"; -import { Input } from "../components/atoms/Input"; import { useToast } from "../hooks/custom/CustomToast"; import { useUserInfoQuery } from "../hooks/user/queries"; @@ -24,9 +23,6 @@ import GuestLoginModal from "../modals/login/GuestLoginModal"; import { IFooterOptions, ModalLayout } from "../modals/Modals"; import { IconKakao, IconUser } from "../public/icons/Icons"; -const publicID = "abcdef1234"; -const publicPW = "abcd1234?!"; - const Login: NextPage<{ providers: Record, ClientSafeProvider>; }> = ({ providers }) => { @@ -41,9 +37,6 @@ const Login: NextPage<{ const [isWaitingModal, setIsWaitingModal] = useState(false); const [isLoginModal, setIsLoginModal] = useState(false); - const [id, setId] = useState(""); - const [pw, setPw] = useState(""); - const { data: userInfo } = useUserInfoQuery({ enabled: !!session, }); @@ -93,24 +86,6 @@ const Login: NextPage<{ main: {}, }; - const handleLogin = async () => { - if (id === publicID && pw === publicPW) { - const result = await signIn("credentials", { - callbackUrl: `${window.location.origin}/home`, - username: "게스트", - password: "비밀번호", - }); - - if (result?.error) { - console.error("로그인 실패:", result?.error); - } else { - console.log("로그인 성공!"); - } - } else { - toast("error", "아이디 비밀번호가 일치하지 않습니다."); - } - }; - return ( <> @@ -149,7 +124,7 @@ const Login: NextPage<{ leftIcon={} pr="32px" > - 카카오톡으로 시작하기 + 카카오톡으로 5초만에 시작하기
- - - )} ); }; diff --git a/pages/loginId.tsx b/pages/loginId.tsx new file mode 100644 index 000000000..4697591bf --- /dev/null +++ b/pages/loginId.tsx @@ -0,0 +1,78 @@ +import { Box, Button } from "@chakra-ui/react"; +import { useRouter } from "next/navigation"; +import { signIn } from "next-auth/react"; +import { useState } from "react"; + +import { Input } from "../components/atoms/Input"; +import ProgressHeader from "../components/molecules/headers/ProgressHeader"; +import { useToast } from "../hooks/custom/CustomToast"; +import RegisterLayout from "../pageTemplates/register/RegisterLayout"; +import RegisterOverview from "../pageTemplates/register/RegisterOverview"; + +const publicID = "team.about.20s@gmail.com"; +const publicPW = "abcde12345?!"; + +function LoginId() { + const router = useRouter(); + const toast = useToast(); + const [id, setId] = useState(""); + const [pw, setPw] = useState(""); + + const handleLogin = async () => { + if (id === publicID && pw === publicPW) { + const result = await signIn("credentials", { + callbackUrl: `${window.location.origin}/home`, + username: "게스트", + password: "비밀번호", + }); + + if (result?.error) { + console.error("로그인 실패:", result?.error); + } else { + console.log("로그인 성공!"); + } + } else { + toast("error", "아이디 비밀번호가 일치하지 않습니다."); + } + }; + + return ( + <> + + + + 외부인 로그인 + 동아리원을 희망하시는 분은 사용하지 말아주세요. + + + + 아이디(이메일) + setId(e.target.value)} + /> + + + 비밀번호 + setPw(e.target.value)} /> + + + router.push("/loginRegister")} + fontSize="13px" + color="gray.600" + ml="auto" + width="max-content" + > + 회원가입 하기 + + + + ); +} + +export default LoginId; diff --git a/pages/loginRegister.tsx b/pages/loginRegister.tsx new file mode 100644 index 000000000..baffa82b5 --- /dev/null +++ b/pages/loginRegister.tsx @@ -0,0 +1,51 @@ +import { Box, Button } from "@chakra-ui/react"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; + +import { Input } from "../components/atoms/Input"; +import ProgressHeader from "../components/molecules/headers/ProgressHeader"; +import { useToast } from "../hooks/custom/CustomToast"; +import RegisterLayout from "../pageTemplates/register/RegisterLayout"; +import RegisterOverview from "../pageTemplates/register/RegisterOverview"; + +function LoginId() { + const router = useRouter(); + const toast = useToast(); + const [id, setId] = useState(""); + const [pw, setPw] = useState(""); + + const handleLogin = async () => { + toast("success", "회원가입 완료"); + router.push("/loginId"); + }; + + return ( + <> + + + + 외부인 로그인 + 동아리원을 희망하시는 분은 사용하지 말아주세요. + + + + 아이디(이메일) + setId(e.target.value)} + /> + + + 비밀번호 + setPw(e.target.value)} /> + + + + + ); +} + +export default LoginId;