-
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.
Merge pull request #59 from Beside-Potenday/seungbeom
로그인 페이지 및 마이 페이지 추가
- Loading branch information
Showing
24 changed files
with
302 additions
and
65 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { AuthContextType, AuthInfo } from '@/types'; | ||
import { createContext, useContext, useState, ReactNode } from 'react'; | ||
|
||
export const AuthContext = createContext<AuthContextType | undefined>(undefined); | ||
|
||
export const AuthProvider = ({ children }: { children: ReactNode }) => { | ||
const [authInfo, setAuthInfo] = useState<AuthInfo | undefined>(undefined); | ||
|
||
const updateAuthInfo = (auth: AuthInfo) => { | ||
if (auth) { | ||
setAuthInfo(auth); | ||
} | ||
}; | ||
|
||
return ( | ||
<AuthContext.Provider value={{ authInfo, updateAuthInfo }}>{children}</AuthContext.Provider> | ||
); | ||
}; | ||
|
||
export const useAuth = () => { | ||
const context = useContext(AuthContext); | ||
if (!context) { | ||
throw new Error('useAuth must be used within an AuthProvider'); | ||
} | ||
return context; | ||
}; |
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,22 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { LoginResponse } from '@/types'; | ||
import { BASE_URL } from '..'; | ||
import axios from 'axios'; | ||
|
||
export type AuthResponse = { | ||
code: string; | ||
}; | ||
|
||
export const getLoginPath = (code: string) => `${BASE_URL}/google/login/redirect?code=${code}`; | ||
|
||
export const getLogin = async ({ code }: AuthResponse): Promise<LoginResponse> => { | ||
const response = await axios.get<LoginResponse>(getLoginPath(code)); | ||
return response.data; | ||
}; | ||
|
||
export const useGetLogin = (params: AuthResponse) => { | ||
return useQuery<LoginResponse, Error, LoginResponse, [string, string]>({ | ||
queryKey: ['getLogin', params.code], | ||
queryFn: () => getLogin(params), | ||
}); | ||
}; |
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 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
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
Oops, something went wrong.