-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #310 from leehj322/Next-이형준-sprint11
[이형준]sprint11
- Loading branch information
Showing
16 changed files
with
265 additions
and
126 deletions.
There are no files selected for viewing
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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 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 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,9 @@ | ||
import Image from "next/image"; | ||
|
||
export default function AuthLogoImg() { | ||
return ( | ||
<div className="relative my-0 mx-auto w-[198px] h-[66px] md:w-[396px] md:h-[132px]"> | ||
<Image fill src="/images/panda_logo_with_typo.png" alt="로고 이미지" /> | ||
</div> | ||
); | ||
} |
This file contains 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,18 @@ | ||
import Link from "next/link"; | ||
|
||
interface AuthLinkProps { | ||
descriptionText: string; | ||
linkText: string; | ||
href: string; | ||
} | ||
|
||
export default function AuthRedirectionLink({ descriptionText, linkText, href }: AuthLinkProps) { | ||
return ( | ||
<div className="flex justify-center gap-[4px] text-[14px] font-medium text-gray-800"> | ||
<p>{descriptionText}</p> | ||
<Link className="underline text-brand-blue" href={href}> | ||
{linkText} | ||
</Link> | ||
</div> | ||
); | ||
} |
This file contains 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,71 @@ | ||
import { logInUser, LogInUserProps } from "@/axios/auth"; | ||
import React from "react"; | ||
import BlueButton from "@/components/@shared/BlueButton"; | ||
import GrayInput from "@/components/@shared/inputs/GrayInput"; | ||
|
||
export default function LoginForm() { | ||
const [logInValues, setLogInValues] = React.useState<LogInUserProps>({ email: "", password: "" }); | ||
|
||
const handleFormKeyDown = (e: React.KeyboardEvent<HTMLFormElement>) => { | ||
if (logInValues.email === "" || logInValues.password === "") { | ||
if (e.key === "Enter") e.preventDefault(); | ||
} | ||
}; | ||
|
||
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
const currentTargetId = e.target.id; | ||
const currentValue = e.target.value; | ||
|
||
setLogInValues((prevLogInValues) => ({ ...prevLogInValues, [currentTargetId]: currentValue })); | ||
}; | ||
|
||
const handleFormSubmit = (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault(); | ||
|
||
const submitLogInForm = async () => { | ||
const data = await logInUser(logInValues); | ||
const { accessToken, refreshToken } = data; | ||
|
||
localStorage.setItem("access_token", accessToken); | ||
localStorage.setItem("refresh_token", refreshToken); | ||
window.location.href = "/"; | ||
}; | ||
|
||
submitLogInForm(); | ||
}; | ||
|
||
return ( | ||
<form | ||
className="flex flex-col gap-[24px] mt-[24px] md:mt-[40px]" | ||
onSubmit={handleFormSubmit} | ||
onKeyDown={handleFormKeyDown} | ||
> | ||
<div className="flex flex-col gap-[8px] md:gap-[16px]"> | ||
<label htmlFor="email" className="text-[14px] font-bold text-gray-800 md:text-[18px]"> | ||
이메일 | ||
</label> | ||
<GrayInput id="email" placeholder="이메일을 입력해주세요" onChange={handleInputChange} /> | ||
</div> | ||
<div className="flex flex-col gap-[8px] md:gap-[16px]"> | ||
<label htmlFor="password" className="text-[14px] font-bold text-gray-800 md:text-[18px]"> | ||
비밀번호 | ||
</label> | ||
<GrayInput | ||
id="password" | ||
placeholder="비밀번호를 입력해주세요" | ||
onChange={handleInputChange} | ||
/> | ||
</div> | ||
<div className="h-[56px]"> | ||
<BlueButton | ||
shape="pill" | ||
type="submit" | ||
disabled={!logInValues.email || !logInValues.password} | ||
customStyle="text-[20px]" | ||
> | ||
로그인 | ||
</BlueButton> | ||
</div> | ||
</form> | ||
); | ||
} |
This file contains 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,91 @@ | ||
import React from "react"; | ||
import { signUpUser, SignUpUserProps } from "@/axios/auth"; | ||
import GrayInput from "../@shared/inputs/GrayInput"; | ||
import BlueButton from "../@shared/BlueButton"; | ||
|
||
export default function SignUpForm() { | ||
const [signUpValues, setSignUpValues] = React.useState<SignUpUserProps>({ | ||
email: "", | ||
nickname: "", | ||
password: "", | ||
passwordConfirmation: "", | ||
}); | ||
|
||
const handleFormKeyDown = (e: React.KeyboardEvent<HTMLFormElement>) => { | ||
if (e.key === "Enter") e.preventDefault(); | ||
}; | ||
|
||
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
const currentTargetId = e.target.id; | ||
const currentValue = e.target.value; | ||
|
||
setSignUpValues((prevSignUpValues) => ({ | ||
...prevSignUpValues, | ||
[currentTargetId]: currentValue, | ||
})); | ||
}; | ||
|
||
const handleSignUpUserSubmit = (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault(); | ||
|
||
const submitSignUpForm = async () => { | ||
const data = await signUpUser(signUpValues); | ||
const { accessToken, refreshToken } = data; | ||
|
||
localStorage.setItem("access_token", accessToken); | ||
localStorage.setItem("refresh_token", refreshToken); | ||
window.location.href = "/"; | ||
}; | ||
|
||
submitSignUpForm(); | ||
}; | ||
|
||
return ( | ||
<form | ||
className="flex flex-col gap-[24px] mt-[24px] md:mt-[40px]" | ||
onSubmit={handleSignUpUserSubmit} | ||
onKeyDown={handleFormKeyDown} | ||
> | ||
<div className="flex flex-col gap-[8px] md:gap-[16px]"> | ||
<label htmlFor="email" className="text-[14px] font-bold text-gray-800 md:text-[18px]"> | ||
이메일 | ||
</label> | ||
<GrayInput id="email" placeholder="이메일을 입력해주세요" onChange={handleInputChange} /> | ||
</div> | ||
<div className="flex flex-col gap-[8px] md:gap-[16px]"> | ||
<label htmlFor="nickname" className="text-[14px] font-bold text-gray-800 md:text-[18px]"> | ||
닉네임 | ||
</label> | ||
<GrayInput id="nickname" placeholder="닉네임을 입력해주세요" onChange={handleInputChange} /> | ||
</div> | ||
<div className="flex flex-col gap-[8px] md:gap-[16px]"> | ||
<label htmlFor="password" className="text-[14px] font-bold text-gray-800 md:text-[18px]"> | ||
비밀번호 | ||
</label> | ||
<GrayInput | ||
id="password" | ||
placeholder="비밀번호를 입력해주세요" | ||
onChange={handleInputChange} | ||
/> | ||
</div> | ||
<div className="flex flex-col gap-[8px] md:gap-[16px]"> | ||
<label | ||
htmlFor="passwordConfirmation" | ||
className="text-[14px] font-bold text-gray-800 md:text-[18px]" | ||
> | ||
비밀번호 확인 | ||
</label> | ||
<GrayInput | ||
id="passwordConfirmation" | ||
placeholder="비밀번호를 다시 한 번 입력해주세요" | ||
onChange={handleInputChange} | ||
/> | ||
</div> | ||
<div className="h-[56px]"> | ||
<BlueButton shape="pill" type="submit" disabled={false} customStyle="text-[20px]"> | ||
회원가입 | ||
</BlueButton> | ||
</div> | ||
</form> | ||
); | ||
} |
This file contains 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,18 @@ | ||
import Link from "next/link"; | ||
import Image from "next/image"; | ||
|
||
export default function SimpleLogin() { | ||
return ( | ||
<div className="flex px-[24px] py-[16px] mt-[24px] mb-[24px] justify-between items-center bg-blue-login rounded-[8px] height-[74px]"> | ||
<p className="font-medium text-[16px] text-gray-800">간편 로그인하기</p> | ||
<div className="flex gap-[16px]"> | ||
<Link href="https://www.google.com"> | ||
<Image width={42} height={42} src="/images/ic_google_login.png" alt="구글로그인" /> | ||
</Link> | ||
<Link href="https://www.kakao.com"> | ||
<Image width={42} height={42} src="/images/ic_kakao_login.png" alt="카카오로그인" /> | ||
</Link> | ||
</div> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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,21 @@ | ||
import AuthLogoImg from "@/components/auth/AuthLogoImg"; | ||
import LoginForm from "@/components/auth/LoginForm"; | ||
import SimpleLogin from "@/components/auth/SimpleLogin"; | ||
import AuthRedirectionLink from "@/components/auth/AuthRedirectionLink"; | ||
|
||
export default function LogIn() { | ||
return ( | ||
<> | ||
<div className="mt-[80px] mx-auto w-[343px] md:mt-[190px] md:w-[640px] xl:mt-[231px]"> | ||
<AuthLogoImg /> | ||
<LoginForm /> | ||
<SimpleLogin /> | ||
<AuthRedirectionLink | ||
descriptionText="판다마켓이 처음이신가요?" | ||
linkText="회원가입" | ||
href="/signup" | ||
/> | ||
</div> | ||
</> | ||
); | ||
} |
Oops, something went wrong.