-
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.
[feat] 회원가입 페이지 API 연동 (추가 정보 페이지 미 포함) (#36)
* [feat] initial setting up for Tanstack-query * [style] added fill props "gray" of ProfileEditButton Component * [feat] added useTimer hook * [feat] added FieldTimerButton in Field Component * [feat] update for email confirmation retry in Field Component and useSignUpState logic * [feat] update Field Component Naming * [feat] complete first sign up step page * [feat] added logic of request server api for additional Info page * [feat] modify error message for username duplicate * [refact] refactored sign up page (included github sign up) * [feat] add login login after being successful sign up step * [feat] added login login after being successfule sign up step at Github page
- Loading branch information
1 parent
94e89e7
commit 5e59603
Showing
21 changed files
with
1,085 additions
and
368 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { defaultInstance } from './httpRequest'; | ||
|
||
interface AuthTokenType { | ||
accessToken: string; | ||
refreshToken: string; | ||
} | ||
|
||
const postLogin = async (loginInfo: { email: string; password: string }) => { | ||
const result = await defaultInstance<AuthTokenType>({ | ||
method: 'POST', | ||
url: '/login', | ||
data: loginInfo, | ||
}); | ||
|
||
return result; | ||
}; | ||
|
||
const requestLogout = async () => { | ||
const result = await defaultInstance<AuthTokenType>({ | ||
method: 'GET', | ||
url: '/logout/success', | ||
}); | ||
|
||
return result; | ||
}; | ||
|
||
export { postLogin, requestLogout }; |
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,33 @@ | ||
import { defaultInstance } from './httpRequest'; | ||
|
||
const postSocialAccount = async (account: { socialAccountUrl: string }) => { | ||
const url = `/social-accounts`; | ||
|
||
const result = await defaultInstance({ | ||
method: 'POST', | ||
url, | ||
data: account, | ||
}); | ||
|
||
return result; | ||
}; | ||
|
||
const postInterest = async ({ | ||
userId, | ||
interestName, | ||
}: { | ||
userId: number; | ||
interestName: string; | ||
}) => { | ||
const url = `/users/${userId}/interests`; | ||
|
||
const result = await defaultInstance({ | ||
method: 'POST', | ||
url, | ||
data: { userId, interestName }, | ||
}); | ||
|
||
return result; | ||
}; | ||
|
||
export { postSocialAccount, postInterest }; |
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 { UseMutationOptions, useMutation } from '@tanstack/react-query'; | ||
import { postLogin } from '../auth'; | ||
import { HttpSuccessType, ResponseError } from '../httpRequest'; | ||
|
||
const useLogin = async ( | ||
options: UseMutationOptions< | ||
HttpSuccessType<{ accessToken: string; refreshToken: string }>, | ||
ResponseError, | ||
{ email: string; password: string } | ||
>, | ||
) => { | ||
return useMutation({ | ||
mutationFn: (loginInfo) => postLogin(loginInfo), | ||
...options, | ||
}); | ||
}; | ||
|
||
export { useLogin }; |
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,31 @@ | ||
import { UseMutationOptions, useMutation } from '@tanstack/react-query'; | ||
import { HttpSuccessType, ResponseError } from '../httpRequest'; | ||
import { postInterest, postSocialAccount } from '../info'; | ||
|
||
const useAddSocialAccountMutation = ( | ||
options: UseMutationOptions< | ||
HttpSuccessType<unknown>, | ||
ResponseError, | ||
{ socialAccountUrl: string } | ||
>, | ||
) => { | ||
return useMutation({ | ||
mutationFn: postSocialAccount, | ||
...options, | ||
}); | ||
}; | ||
|
||
const useAddInterest = ( | ||
options: UseMutationOptions< | ||
HttpSuccessType<unknown>, | ||
ResponseError, | ||
{ userId: number; interestName: string } | ||
>, | ||
) => { | ||
return useMutation({ | ||
mutationFn: postInterest, | ||
...options, | ||
}); | ||
}; | ||
|
||
export { useAddSocialAccountMutation, useAddInterest }; |
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,56 @@ | ||
import { UseMutationOptions, useMutation } from '@tanstack/react-query'; | ||
import { | ||
UserSignUpType, | ||
postConfirmCode, | ||
postConfirmCodeByEamil, | ||
postConfirmUsernameDuplicate, | ||
postSignupUser, | ||
} from '../sign-up'; | ||
import { HttpSuccessType, ResponseError } from '../httpRequest'; | ||
|
||
export const useSelfSignUpMutation = ( | ||
options: UseMutationOptions<HttpSuccessType<unknown>, ResponseError, string>, | ||
) => | ||
useMutation({ | ||
mutationFn: postConfirmCodeByEamil, | ||
...options, | ||
}); | ||
|
||
export const useEamilConfirmMutation = ( | ||
options: UseMutationOptions< | ||
HttpSuccessType<{ emailToken: string }>, | ||
ResponseError, | ||
{ email: string; code: string } | ||
> = {}, | ||
) => { | ||
return useMutation({ | ||
mutationFn: postConfirmCode, | ||
...options, | ||
}); | ||
}; | ||
|
||
export const useConfirmUsernameDuplicate = ( | ||
options: UseMutationOptions< | ||
HttpSuccessType<{ usernameToken: string }>, | ||
ResponseError, | ||
string | ||
> = {}, | ||
) => { | ||
return useMutation({ | ||
mutationFn: postConfirmUsernameDuplicate, | ||
...options, | ||
}); | ||
}; | ||
|
||
export const useSignupUser = ( | ||
options: UseMutationOptions< | ||
HttpSuccessType<unknown>, | ||
ResponseError, | ||
UserSignUpType | ||
> = {}, | ||
) => { | ||
return useMutation({ | ||
mutationFn: postSignupUser, | ||
...options, | ||
}); | ||
}; |
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,69 @@ | ||
import { defaultInstance } from './httpRequest'; | ||
|
||
type UserSignUpType = { | ||
email: string; | ||
password: string; | ||
username: string; | ||
emailToken: string; | ||
usernameToken: string; | ||
}; | ||
|
||
const postConfirmCodeByEamil = async (email: string) => { | ||
const url = `/verification/email?email=${email}`; | ||
|
||
const result = await defaultInstance({ | ||
method: 'POST', | ||
url, | ||
}); | ||
|
||
return result; | ||
}; | ||
|
||
const postConfirmCode = async ({ | ||
email, | ||
code, | ||
}: { | ||
email: string; | ||
code: string; | ||
}) => { | ||
const url = `/verification/email/${email}?code=${code}`; | ||
|
||
const result = await defaultInstance<{ emailToken: string }>({ | ||
method: 'POST', | ||
url, | ||
}); | ||
|
||
return result; | ||
}; | ||
|
||
const postConfirmUsernameDuplicate = async (username: string) => { | ||
const url = `/verification/username?username=${username}`; | ||
|
||
const result = await defaultInstance<{ usernameToken: string }>({ | ||
method: 'POST', | ||
url, | ||
}); | ||
|
||
return result; | ||
}; | ||
|
||
const postSignupUser = async (userInfo: UserSignUpType) => { | ||
const url = `/users`; | ||
|
||
const result = await defaultInstance({ | ||
method: 'POST', | ||
url, | ||
data: userInfo, | ||
}); | ||
|
||
return result; | ||
}; | ||
|
||
export { | ||
postConfirmCodeByEamil, | ||
postConfirmCode, | ||
postConfirmUsernameDuplicate, | ||
postSignupUser, | ||
}; | ||
|
||
export type { UserSignUpType }; |
Oops, something went wrong.