-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/email login page #18
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d1c58cb
feat: 백 버튼 컴포넌트 추가
dasosann 1db2ca0
feat: 이메일 로그인 페이지 및 관련 컴포넌트 추가
dasosann 9c59594
feat: 자체 로그인 페이지 퍼블리싱
dasosann 066e57f
fix: 해결 간단한 코드리뷰들 반영
dasosann 68a0816
feat: BackButton 컴포넌트에 "use client" 추가
dasosann d01d57c
feat: useActionState추가 및 useRouter Link로 변경
dasosann f2f18cb
feat: 로그인 폼에서 버튼을 링크로 변경하여 이메일 찾기 및 비밀번호 변경 기능 추가
dasosann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,17 @@ | ||
| import React from "react"; | ||
|
|
||
| const LocalLoginIntro = () => { | ||
| return ( | ||
| <section className="mt-6 flex flex-col items-start gap-2"> | ||
| <span className="typo-26-700 leading-[1.4] text-black"> | ||
| 이메일로 | ||
| <br /> 코매칭 시작하기 | ||
| </span> | ||
| <span className="typo-16-500 text-color-text-caption2"> | ||
| 로그인하거나 새로운 계정을 만들어보세요. | ||
| </span> | ||
| </section> | ||
| ); | ||
| }; | ||
|
|
||
| export default LocalLoginIntro; | ||
This file contains hidden or 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,85 @@ | ||
| "use client"; | ||
| import BubbleDiv from "@/app/_components/BubbleDiv"; | ||
| import Button from "@/components/ui/Button"; | ||
| import { User } from "lucide-react"; | ||
| import React, { useActionState } from "react"; | ||
| import { loginAction } from "@/lib/actions/loginAction"; | ||
|
|
||
| const INPUT_STYLE = { | ||
| background: | ||
| "linear-gradient(180deg, rgba(248, 248, 248, 0.03) 0%, rgba(248, 248, 248, 0.24) 100%)", | ||
| }; | ||
| const INPUT_CLASSNAME = | ||
| "all:unset box-border w-full border-b border-gray-300 px-2 py-[14.5px] leading-[19px] placeholder:text-[#B3B3B3]"; | ||
|
|
||
| export const LoginForm = () => { | ||
| // React 19: useActionState로 폼 상태 및 팬딩 처리 관리 | ||
| const [state, formAction, isPending] = useActionState(loginAction, { | ||
| success: false, | ||
| message: "", | ||
| }); | ||
|
|
||
| return ( | ||
| <section className="mt-10 flex w-full flex-1 flex-col items-start gap-6"> | ||
| <form className="flex w-full flex-col gap-4" action={formAction}> | ||
| <div className="flex w-full flex-col gap-2"> | ||
| <label htmlFor="email" className="typo-14-500 text-gray-700"> | ||
| 아이디(이메일) | ||
| </label> | ||
| <input | ||
| id="email" | ||
| type="email" | ||
| name="email" | ||
| placeholder="이메일 입력" | ||
| required | ||
| autoComplete="email" | ||
| className={INPUT_CLASSNAME} | ||
| style={INPUT_STYLE} | ||
| /> | ||
| </div> | ||
|
|
||
| <div className="relative mb-6 flex w-full flex-col gap-2"> | ||
| <label htmlFor="password" className="typo-14-500 text-gray-700"> | ||
| 비밀번호 | ||
| </label> | ||
| <input | ||
| id="password" | ||
| type="password" | ||
| name="password" | ||
| placeholder="비밀번호 입력" | ||
| required | ||
| autoComplete="current-password" | ||
| className={INPUT_CLASSNAME} | ||
| style={INPUT_STYLE} | ||
| /> | ||
| {!state.success && ( | ||
| <span className="typo-12-400 text-color-flame-700 absolute bottom-[-25px] left-0"> | ||
| * 이메일 혹은 비밀번호가 틀립니다 | ||
| </span> | ||
dasosann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| )} | ||
dasosann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| <Button shadow={true} type="submit" disabled={isPending}> | ||
| {isPending ? "로그인 중..." : "로그인"} | ||
| </Button> | ||
| </form> | ||
| <div className="typo-14-500 text-color-text-caption2 flex w-full justify-center"> | ||
| <button type="button">이메일 찾기</button> | ||
| <span className="mx-4">|</span> | ||
| <button type="button">비밀번호 변경</button> | ||
| </div> | ||
dasosann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| <div className="mt-auto flex w-full flex-col items-center gap-4"> | ||
| <BubbleDiv w={162} h={26} typo="typo-12-600" top={3}> | ||
| 아직 계정이 없으신가요?! | ||
| </BubbleDiv> | ||
| <button | ||
| type="button" | ||
| className="typo-14-500 flex items-center gap-1 border-b-2 border-gray-500 text-gray-500" | ||
| > | ||
| <User /> | ||
| 이메일로 회원가입 | ||
| </button> | ||
| </div> | ||
| </section> | ||
| ); | ||
| }; | ||
This file contains hidden or 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,16 @@ | ||
| import React from "react"; | ||
| import { BackButton } from "@/components/ui/BackButton"; | ||
| import LocalLoginIntro from "./LocalLoginIntro"; | ||
| import { LoginForm } from "./LoginForm"; | ||
|
|
||
| const ScreenLocalLoginPage = () => { | ||
| return ( | ||
| <main className="flex h-dvh flex-col items-start px-4 pt-2 pb-[6.2vh]"> | ||
| <BackButton /> | ||
| <LocalLoginIntro /> | ||
| <LoginForm /> | ||
| </main> | ||
| ); | ||
| }; | ||
|
|
||
| export default ScreenLocalLoginPage; | ||
dasosann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or 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,14 @@ | ||
| import React from "react"; | ||
| import { Metadata } from "next"; | ||
| import ScreenLocalLoginPage from "./_components/ScreenLocalLoginPage"; | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: "로그인 | COMAtching", | ||
| description: "COMAtching 로그인 페이지", | ||
| }; | ||
|
|
||
| const LoginPage = () => { | ||
| return <ScreenLocalLoginPage />; | ||
| }; | ||
|
|
||
| export default LoginPage; |
This file contains hidden or 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,36 @@ | ||
| "use client"; | ||
| import React from "react"; | ||
| import { useRouter } from "next/navigation"; | ||
| import { ChevronLeft } from "lucide-react"; | ||
| import { cn } from "@/lib/utils"; | ||
|
|
||
| type BackButtonProps = { | ||
| variant?: "absolute" | "static"; | ||
| className?: string; | ||
| onClick?: () => void; | ||
| }; | ||
|
|
||
| export const BackButton = ({ | ||
| variant = "static", | ||
| className = "", | ||
| onClick, | ||
| }: BackButtonProps) => { | ||
| const router = useRouter(); | ||
| const positionClass = variant === "absolute" ? "absolute left-4 top-2" : ""; | ||
| const handleClick = onClick ?? (() => router.back()); | ||
|
|
||
| return ( | ||
| <button | ||
| type="button" | ||
| onClick={handleClick} | ||
| aria-label="뒤로 가기" | ||
| className={cn( | ||
| "flex h-12 w-12 cursor-pointer items-center justify-center rounded-full border border-[#FFFFFF]/30 bg-[#FFFFFF]/50 [box-shadow:0px_4px_8px_rgba(0,0,0,0.08),0px_0px_16px_rgba(0,0,0,0.1)] backdrop-blur-[15px]", | ||
| positionClass, | ||
| className, | ||
| )} | ||
| > | ||
| <ChevronLeft className="text-[#282828]" size={20} /> | ||
| </button> | ||
dasosann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
| }; | ||
This file contains hidden or 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
This file contains hidden or 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,31 @@ | ||
| "use server"; | ||
|
|
||
| type LoginState = { | ||
| success: boolean; | ||
| message: string; | ||
| }; | ||
|
|
||
| export async function loginAction( | ||
| prevState: LoginState, | ||
| formData: FormData, | ||
| ): Promise<LoginState> { | ||
| const email = formData.get("email"); | ||
| const password = formData.get("password"); | ||
|
Comment on lines
+12
to
+13
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 서버 액션에서 예시 (zod 사용): import { z } from "zod";
const loginSchema = z.object({
email: z.string().email({ message: "올바른 이메일 형식이 아닙니다." }),
password: z.string().min(1, { message: "비밀번호를 입력해주세요." }),
});
export async function loginAction(...) {
const validatedFields = loginSchema.safeParse({
email: formData.get("email"),
password: formData.get("password"),
});
if (!validatedFields.success) {
return {
success: false,
message: validatedFields.error.errors[0].message,
};
}
const { email, password } = validatedFields.data;
// ... 이후 로직
}References
|
||
|
|
||
| // Mock delay | ||
| await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
|
|
||
| // TODO: 실제 백엔드 API 호출로 교체 필요 | ||
| // const response = await fetch("https://api.comatching.com/login", { | ||
| // method: "POST", | ||
| // body: JSON.stringify({ email, password }), | ||
| // headers: { "Content-Type": "application/json" }, | ||
| // }); | ||
|
|
||
| // Mock logic | ||
| if (email === "test@test.com" && password === "1234") { | ||
| return { success: true, message: "" }; | ||
| } | ||
|
|
||
| return { success: false, message: "이메일 혹은 비밀번호가 틀립니다" }; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.