-
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 #12 from NewMillenniumWorkout/dev/backend-sync
[DEV] login 테스트 추가
- Loading branch information
Showing
5 changed files
with
169 additions
and
22 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
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,35 @@ | ||
import React, { createContext, ReactNode, useContext, useState } from "react"; | ||
|
||
interface DataContextType { | ||
userToken: string | null; | ||
setUserToken: React.Dispatch<React.SetStateAction<string | null>>; | ||
} | ||
|
||
const DataContext = createContext<DataContextType | undefined>(undefined); | ||
|
||
export const useDataContext = () => { | ||
const context = useContext(DataContext); | ||
if (!context) { | ||
throw new Error("useDataContext must be used within DataProvider"); | ||
} | ||
return context; | ||
}; | ||
|
||
interface DataProviderProps { | ||
children: ReactNode; | ||
} | ||
|
||
export const DataProvider: React.FC<DataProviderProps> = ({ children }) => { | ||
const [userToken, setUserToken] = useState<string | null>(null); | ||
|
||
return ( | ||
<DataContext.Provider | ||
value={{ | ||
userToken, | ||
setUserToken, | ||
}} | ||
> | ||
{children} | ||
</DataContext.Provider> | ||
); | ||
}; |
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,57 @@ | ||
import React, { useState } from "react"; | ||
import IconButton from "../IconButton"; | ||
import axios from "axios"; | ||
import { IconProvider } from "../../utils/IconProvider"; | ||
|
||
const LoginPage = () => { | ||
const path = "http://10.210.60.64:7010"; | ||
const sendGetRequest = async () => { | ||
try { | ||
const response = await axios.get(`${path}/login/oauth2/code/naver`); | ||
|
||
console.log("응답 데이터:", response.data); | ||
} catch (error) { | ||
console.error("API 요청 실패:", error); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="flex flex-col justify-center items-center w-full h-full p-8"> | ||
<div className="flex flex-col w-full space-y-2"> | ||
<button | ||
className="bg-green-500 text-white w-full h-11 rounded-lg" | ||
onClick={sendGetRequest} | ||
> | ||
네이버 로그인 | ||
</button> | ||
|
||
<button className="bg-yellow-400 text-amber-950 w-full h-10 rounded-xl"> | ||
카카오 로그인 | ||
</button> | ||
|
||
<button className="bg-white border-2 w-full h-10 rounded-xl"> | ||
구글 로그인 | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
interface SocialLoginButtonProps { | ||
handleLogin: () => void; | ||
} | ||
|
||
const SocialLoginButton: React.FC<SocialLoginButtonProps> = ({ | ||
handleLogin, | ||
}) => { | ||
return ( | ||
<button | ||
className="bg-green-500 text-white w-full h-11 rounded-lg" | ||
onClick={handleLogin} | ||
> | ||
네이버 로그인 | ||
</button> | ||
); | ||
}; | ||
|
||
export default LoginPage; |