-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor : 모달 포커스 기능 제거 * Refactor : 패스 비교로직 개선 * New : 회원가입 Mutation 추가 * Refactor : Login 컴포넌트 분리 * New : 회원가입 서버통신 연결 * Refactor : 로그인 이후 라우트 캐시 제거
- Loading branch information
1 parent
122ae9f
commit 1946422
Showing
9 changed files
with
152 additions
and
43 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
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,16 @@ | ||
import LogoutOnlyLayout from "@/app/(logoutOnly)/layout"; | ||
import ModalWrapper from "@/components/ModalWrapper"; | ||
import LoginPage from "@/app/(logoutOnly)/auth/login/page"; | ||
|
||
const LoginModalPage = () => { | ||
return ( | ||
<LogoutOnlyLayout> | ||
<ModalWrapper> | ||
<LoginPage.SigninForm /> | ||
<LoginPage.CTA /> | ||
</ModalWrapper> | ||
</LogoutOnlyLayout> | ||
); | ||
}; | ||
|
||
export default LoginModalPage; |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import AuthProtectorlayout from "@/app/(protectedRoute)/layout"; | ||
import ModalWrapper from "@/components/ModalWrapper"; | ||
import React, { ReactNode } from "react"; | ||
|
||
type Props = { | ||
children: ReactNode; | ||
}; | ||
|
||
const NewPostPage = ({ children }: Props) => { | ||
return <ModalWrapper>{children}</ModalWrapper>; | ||
const NewPostPage = () => { | ||
return ( | ||
<AuthProtectorlayout> | ||
<ModalWrapper>{"페이지"}</ModalWrapper> | ||
</AuthProtectorlayout> | ||
); | ||
}; | ||
|
||
export default NewPostPage; |
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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
"use client"; | ||
|
||
import { NEW_POST, SIGNIN } from "@/const/clientPath"; | ||
import { usePathname } from "next/navigation"; | ||
|
||
export default function Layout({ children }: any) { | ||
const pathname = usePathname(); | ||
return pathname.startsWith("/post/") ? children : null; | ||
const allowedPath = ["/post/", NEW_POST, SIGNIN]; | ||
|
||
return allowedPath.some((path) => pathname.startsWith(path)) | ||
? children | ||
: null; | ||
} |
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,40 @@ | ||
// import { SIGNIN } from "@/const/clientPath"; | ||
import { SIGNUP_API_PATH } from "@/const/serverPath"; | ||
import axios from "@/libs/axios"; | ||
import { SignupRequirement } from "@/types/auth/signupRequirement"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { useRouter } from "next/navigation"; | ||
import useLoginMutation from "./useLoginMutation"; | ||
|
||
const useSignupMutation = () => { | ||
const router = useRouter(); | ||
const { mutate: loginHandler } = useLoginMutation(); | ||
|
||
return useMutation({ | ||
mutationKey: signupMuataionKey.all, | ||
mutationFn: async (formData: SignupRequirement) => { | ||
const { id, password } = formData; | ||
await signupHandler(formData); | ||
return { id, password }; | ||
}, | ||
onSuccess: async ({ id, password }) => { | ||
loginHandler({ id, password }); | ||
}, | ||
}); | ||
}; | ||
|
||
export const signupHandler = async (props: SignupRequirement) => { | ||
const { data } = await axios.post<{ userNo: number }>(SIGNUP_API_PATH, { | ||
...props, | ||
}); | ||
return data; | ||
}; | ||
|
||
export const signupMuataionKey = { | ||
/** | ||
* 모든 회원가입 관련 키 | ||
*/ | ||
all: ["signup"] as const, | ||
}; | ||
|
||
export default useSignupMutation; |