Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[장문원] week14 #451

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions components/layout/login-layout/LoginLayout.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@import "@/styles/global.scss";

.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 3rem;
width: 100%;
height: 100vh;
background-color: $color-background;
}
13 changes: 13 additions & 0 deletions components/layout/login-layout/LoginLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ReactNode } from "react";
import styles from "./LoginLayout.module.scss";
import classNames from "classnames/bind";

interface LoginLayoutProps {
children: ReactNode;
}

const cx = classNames.bind(styles);

export const LoginLayout = ({ children }: LoginLayoutProps) => {
return <div className={cx("container")}>{children}</div>;
};
24 changes: 24 additions & 0 deletions components/login-header/LoginHeader.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@import "@/styles/global.scss";

.header-container {
display: flex;
flex-direction: column;
gap: 1.6rem;
}

.header-content {
display: flex;
gap: 0.8rem;
}

.header-message {
font-size: 1.6rem;
font-weight: 400;
}

.header-link {
font-size: 1.6rem;
font-weight: 600;
color: $color-primary;
border-bottom: 0.1rem solid $color-primary;
}
33 changes: 33 additions & 0 deletions components/login-header/LoginHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import styles from "./LoginHeader.module.scss";
import classNames from "classnames/bind";
import Link from "next/link";
import Image from "next/image";
import Logo from "@/public/logo.svg";

const cx = classNames.bind(styles);

interface LoginHeaderProps {
href: string;
message: string;
linkName: string;
}

export default function LoginHeader({
href,
message,
linkName,
}: LoginHeaderProps) {
return (
<header className={cx("header-container")}>
<Link href="/">
<Image src={Logo} alt="Logo" width={210} height={38} priority />
</Link>
<div className={cx("header-content")}>
<span className={cx("header-message")}>{message}</span>
<Link href={href} className={cx("header-link")}>
{linkName}
</Link>
</div>
</header>
);
}
24 changes: 24 additions & 0 deletions components/login-social-box/SocialBox.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@import "@/styles/global.scss";

.social-login-container {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
max-width: 40rem;
padding: 1.2rem 2.4rem;
border: 0.1rem solid $color-grey20;
border-radius: 0.8rem;
background-color: $color-grey10;
}

.social-login-text {
font-size: 1.4rem;
font-weight: 400;
color: $color-grey100;
}

.social-login-icon {
display: flex;
gap: 1.6rem;
}
24 changes: 24 additions & 0 deletions components/login-social-box/SocialBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Image from "next/image";
import Link from "next/link";
import styles from "./SocialBox.module.scss";
import classNames from "classnames/bind";
import Googlelogin from "@/public/Googlelogin.svg";
import Kakaologin from "@/public/Kakaologin.svg";

const cx = classNames.bind(styles);

export default function SocialBox({ text }: { text: string }) {
return (
<div className={cx("social-login-container")}>
<span className={cx("social-login-text")}>{text}</span>
<div className={cx("social-login-icon")}>
<Link href="https://www.google.com">
<Image src={Googlelogin} width={42} height={42} alt="google" />
</Link>
<Link href="https://www.kakaocorp.com/page">
<Image src={Kakaologin} width={42} height={42} alt="kakao" />
</Link>
</div>
</div>
);
}
64 changes: 64 additions & 0 deletions lib/schema.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jangmoonwon

음 각 필드 요소에 대해 스키마를 짜기보단,

user가 지녀야 하는 정보에 대한 스키마라면 userSchema로,
로그인 인증을 위해 필요한 데이터 스키마라면 loginAuthSchema로,
회원가입을 위해 필요한 스키마라면 registerAuthSchema로 구분짓는게 좋겠어요

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { z } from "zod";

const PWD_VALIDATION = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/;

function emailSchema() {
return z
.string()
.min(1, { message: "이메일을 입력해 주세요." })
.email({ message: "올바른 이메일 주소가 아닙니다." });
}

function emailCheckSchema() {
return z
.string()
.min(1, { message: "이메일을 입력해 주세요." })
.email({ message: "올바른 이메일 주소가 아닙니다." })
.refine((data) => data !== "test@codeit.com", {
message: "이미 사용 중인 이메일입니다.",
path: ["email"],
});
}

function passwordSchema() {
return z
.string()
.min(1, { message: "비밀번호를 입력해 주세요." })
.max(16, { message: "최대 16자리입니다." });
}

function passwordCheckSchema() {
return z
.string()
.min(1, { message: "비밀번호를 입력해 주세요." })
.max(16, { message: "최대 16자리입니다." })
.regex(PWD_VALIDATION, {
message: "영문, 숫자를 조합해 8자 이상 입력해 주세요.",
});
}

//signin schema
export type FormFields = z.infer<typeof schema>;

export const schema = z.object({
email: emailSchema(),
password: passwordSchema(),
});

//signup schema
export type FormFieldsCheck = z.infer<typeof schemaCheck>;

export const schemaCheck = z
.object({
email: emailCheckSchema(),
password: passwordCheckSchema(),
passwordCheck: passwordCheckSchema(),
})
.refine((data) => data.email !== "test@codeit.com", {
message: "이미 사용 중인 이메일입니다.",
path: ["email"],
})
.refine((data) => data.password === data.passwordCheck, {
message: "비밀번호가 일치하지 않아요.",
path: ["passwordCheck"],
});
Loading
Loading