Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
SeungJL committed Nov 22, 2024
1 parent 322b8b2 commit 52516ea
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 46 deletions.
9 changes: 7 additions & 2 deletions components/atoms/buttons/WritingButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Link href={url} onClick={onClick}>
<Layout isBottomNav={isBottomNav}>
<i className="fa-light fa-pen-line fa-lg" style={{ color: "white" }} />
{type === "thunder" ? (
<i className="fa-light fa-bolt-lightning fa-lg" style={{ color: "white" }} />
) : (
<i className="fa-light fa-pen-line fa-lg" style={{ color: "white" }} />
)}
</Layout>
</Link>
);
Expand Down
2 changes: 1 addition & 1 deletion components/organisms/location/LocationSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function LocationSearch({
<Layout>
<Wrapper>
<InputGroup
placeholder="스터디 장소를 검색해 보세요"
placeholder="장소를 검색해 보세요"
onChange={onChange}
value={value}
icon={<i className="fa-solid fa-location-dot" />}
Expand Down
13 changes: 12 additions & 1 deletion pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
44 changes: 2 additions & 42 deletions pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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<LiteralUnion<BuiltInProviderType, string>, ClientSafeProvider>;
}> = ({ providers }) => {
Expand All @@ -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,
});
Expand Down Expand Up @@ -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 (
<>
<Flex direction="column" alignItems="center" height="100vh" overflow="hidden">
Expand Down Expand Up @@ -149,7 +124,7 @@ const Login: NextPage<{
leftIcon={<IconKakao />}
pr="32px"
>
<span>카카오톡으로 시작하기</span>
<span>카카오톡으로 5초만에 시작하기</span>
<div />
</Button>
<Button
Expand All @@ -169,7 +144,7 @@ const Login: NextPage<{
<div />
</Button>

<Button variant="ghost" size="md" fontSize="13px" onClick={() => setIsLoginModal(true)}>
<Button variant="ghost" size="md" fontSize="13px" onClick={() => router.push("/loginId")}>
<u
style={{
fontWeight: "400",
Expand Down Expand Up @@ -205,21 +180,6 @@ const Login: NextPage<{
가입 대기중입니다. <br /> 며칠 내에 카톡으로 연락드려요!
</ModalLayout>
)}
{isLoginModal && (
<ModalLayout title="로그인" setIsModal={setIsLoginModal}>
<Box textAlign="start" mb={4}>
<Box as="span">아이디</Box>
<Input value={id} onChange={(e) => setId(e.target.value)} />
</Box>
<Box textAlign="start">
<Box as="span">비밀번호</Box>
<Input value={pw} onChange={(e) => setPw(e.target.value)} />
</Box>
<Button mt={4} w="full" colorScheme="mint" onClick={handleLogin}>
로그인
</Button>
</ModalLayout>
)}
</>
);
};
Expand Down
78 changes: 78 additions & 0 deletions pages/loginId.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<ProgressHeader title="로그인" value={100} />
<RegisterLayout>
<RegisterOverview>
<span>외부인 로그인</span>
<span>동아리원을 희망하시는 분은 사용하지 말아주세요.</span>
</RegisterOverview>

<Box textAlign="start" mb={4}>
<Box mb={1}>아이디(이메일)</Box>
<Input
placeholder="example@about.kr"
value={id}
onChange={(e) => setId(e.target.value)}
/>
</Box>
<Box textAlign="start">
<Box mb={1}>비밀번호</Box>
<Input placeholder="password" value={pw} onChange={(e) => setPw(e.target.value)} />
</Box>
<Button mt={5} w="full" colorScheme="mint" onClick={handleLogin}>
로그인
</Button>
<Box
mt={5}
onClick={() => router.push("/loginRegister")}
fontSize="13px"
color="gray.600"
ml="auto"
width="max-content"
>
회원가입 하기
</Box>
</RegisterLayout>
</>
);
}

export default LoginId;
51 changes: 51 additions & 0 deletions pages/loginRegister.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<ProgressHeader title="회원가입" value={100} />
<RegisterLayout>
<RegisterOverview>
<span>외부인 로그인</span>
<span>동아리원을 희망하시는 분은 사용하지 말아주세요.</span>
</RegisterOverview>

<Box textAlign="start" mb={4}>
<Box mb={1}>아이디(이메일)</Box>
<Input
placeholder="example@about.kr"
value={id}
onChange={(e) => setId(e.target.value)}
/>
</Box>
<Box textAlign="start">
<Box mb={1}>비밀번호</Box>
<Input placeholder="password" value={pw} onChange={(e) => setPw(e.target.value)} />
</Box>
<Button mt={5} w="full" colorScheme="mint" onClick={handleLogin}>
회원가입
</Button>
</RegisterLayout>
</>
);
}

export default LoginId;

0 comments on commit 52516ea

Please sign in to comment.