-
Notifications
You must be signed in to change notification settings - Fork 2
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 #108 from Goldchae/apiTest
Api test
- Loading branch information
Showing
9 changed files
with
174 additions
and
113 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 @@ | ||
VITE_BASE_URL = https://api.kaboo.site:8081 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,61 @@ | ||
import React from "react"; | ||
import React, { useEffect, useState } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
import Layout from "../../components/Common/Layout.jsx"; | ||
import MiniLayout from "../../components/Common/miniLayout.jsx"; | ||
import PeopleCard from "../../components/PeopleListComponents/PeopleCard/peopleCard.jsx"; | ||
import fetchMembersList from "../../services/fetchMembersList.js"; | ||
import dummyImages1 from "../../assets/dummyImages/peopleList.jpeg" | ||
|
||
export const PeopleListPage = () => { | ||
const navigate = useNavigate(); | ||
const handleCardClick = () => { | ||
navigate('/details'); | ||
}; | ||
const navigate = useNavigate(); | ||
const [members, setMembers] = useState([]); | ||
const [isLoading, setIsLoading] = useState(true); | ||
const [error, setError] = useState(null); | ||
|
||
return ( | ||
<Layout> | ||
<MiniLayout text="카부인 전당" layerWidth="80%"> | ||
<PeopleCard | ||
image="src/assets/dummyImages/peopleList.jpeg" // 더미이미지 | ||
name="celina.jung (정은체)" // 임시 하드코딩 | ||
affiliation="카카오 부트캠프 1기 : AI" | ||
onClick={handleCardClick} | ||
/> | ||
<PeopleCard | ||
image="src/assets/dummyImages/peopleList2.png" // 더미이미지 | ||
name="celina.jung (정은체)" // 임시 하드코딩 | ||
affiliation="카카오 부트캠프 1기 : AI" | ||
onClick={handleCardClick} | ||
/> | ||
<PeopleCard | ||
image="src/assets/dummyImages/peopleList.jpeg" // 더미이미지 | ||
name="celina.jung (정은체)" // 임시 하드코딩 | ||
affiliation="카카오 부트캠프 1기 : AI" | ||
onClick={handleCardClick} | ||
/> | ||
<PeopleCard | ||
image="src/assets/dummyImages/peopleList2.png" // 더미이미지 | ||
name="celina.jung (정은체)" // 임시 하드코딩 | ||
affiliation="카카오 부트캠프 1기 : AI" | ||
onClick={handleCardClick} | ||
/> | ||
<PeopleCard | ||
image="src/assets/dummyImages/peopleList.jpeg" // 더미이미지 | ||
name="celina.jung (정은체)" // 임시 하드코딩 | ||
affiliation="카카오 부트캠프 1기 : AI" | ||
onClick={handleCardClick} | ||
/> | ||
<PeopleCard | ||
image="src/assets/dummyImages/peopleList2.png" // 더미이미지 | ||
name="celina.jung (정은체)" // 임시 하드코딩 | ||
affiliation="카카오 부트캠프 1기 : AI" | ||
onClick={handleCardClick} | ||
/> | ||
<PeopleCard | ||
image="src/assets/dummyImages/peopleList.jpeg" // 더미이미지 | ||
name="celina.jung (정은체)" // 임시 하드코딩 | ||
affiliation="카카오 부트캠프 1기 : AI" | ||
onClick={handleCardClick} | ||
/> | ||
<PeopleCard | ||
image="src/assets/dummyImages/peopleList2.png" // 더미이미지 | ||
name="celina.jung (정은체)" // 임시 하드코딩 | ||
affiliation="카카오 부트캠프 1기 : AI" | ||
onClick={handleCardClick} | ||
/> | ||
<PeopleCard | ||
image="src/assets/dummyImages/peopleList.jpeg" // 더미이미지 | ||
name="celina.jung (정은체)" // 임시 하드코딩 | ||
affiliation="카카오 부트캠프 1기 : AI" | ||
onClick={handleCardClick} | ||
/> | ||
<PeopleCard | ||
image="src/assets/dummyImages/peopleList2.png" // 더미이미지 | ||
name="celina.jung (정은체)" // 임시 하드코딩 | ||
affiliation="카카오 부트캠프 1기 : AI" | ||
onClick={handleCardClick} | ||
/> | ||
<PeopleCard | ||
image="src/assets/dummyImages/peopleList.jpeg" // 더미이미지 | ||
name="celina.jung (정은체)" // 임시 하드코딩 | ||
affiliation="카카오 부트캠프 1기 : AI" | ||
onClick={handleCardClick} | ||
/> | ||
<PeopleCard | ||
image="src/assets/dummyImages/peopleList2.png" // 더미이미지 | ||
name="celina.jung (정은체)" // 임시 하드코딩 | ||
affiliation="카카오 부트캠프 1기 : AI" | ||
onClick={handleCardClick} | ||
/> | ||
</MiniLayout> | ||
</Layout> | ||
); | ||
useEffect(() => { | ||
const displayMembers = async () => { | ||
setIsLoading(true); | ||
try { | ||
const membersData = await fetchMembersList(); | ||
console.log('Fetched Members:', membersData.data); // 데이터 구조를 확인하기 위해 콘솔에 출력 | ||
if (membersData && membersData.data && membersData.data.memberList) { | ||
setMembers(membersData.data.memberList); | ||
} else { | ||
console.error('Invalid data structure:', membersData); | ||
setMembers([]); // 데이터 구조가 올바르지 않을 경우 빈 배열 설정 | ||
} | ||
setIsLoading(false); | ||
} catch (error) { | ||
console.error('Failed to fetch members:', error); | ||
setError(error); | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
displayMembers(); | ||
}, []); | ||
; | ||
|
||
const handleCardClick = () => { | ||
navigate('/details'); | ||
}; | ||
|
||
if (isLoading) return <div>로딩 중...</div>; | ||
if (error) return <div>에러 발생: {error.message}</div>; | ||
|
||
return ( | ||
<Layout> | ||
<MiniLayout text="카부인 전당" layerWidth="80%"> | ||
{members.map((member, index) => ( | ||
<PeopleCard | ||
key={index} | ||
image={dummyImages1} // 임시 이미지 | ||
name={`${member.englishName} (${member.koreaName})`} | ||
affiliation={`카카오 부트캠프 1기 : ${member.course}`} | ||
onClick={handleCardClick} | ||
/> | ||
))} | ||
</MiniLayout> | ||
</Layout> | ||
); | ||
}; |
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,30 @@ | ||
import React from 'react'; | ||
|
||
function LoginPage() { | ||
const handleLogin = () => { | ||
try { | ||
console.log('Attempting to redirect to OAuth provider...'); | ||
|
||
// Redirection URL 로그 추가 | ||
// const redirectUrl = `https://kauth.kakao.com/oauth/authorize?client_id=${kakaoClientId}&redirect_uri=${redirectUri}&response_type=code`; | ||
const redirectUrl = "http://localhost:8081/oauth2/authorization/kakao"; | ||
console.log('Redirect URL:', redirectUrl); | ||
|
||
window.location.href = redirectUrl; | ||
console.log('Redirection triggered.'); | ||
} catch (error) { | ||
console.error('Error during redirection:', error); | ||
} | ||
}; | ||
|
||
|
||
|
||
return ( | ||
<div> | ||
<h2>Login Page</h2> | ||
<button onClick={handleLogin}>Login with kakao</button> | ||
</div> | ||
); | ||
} | ||
|
||
export default LoginPage; |
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,20 @@ | ||
import { instance } from './../api/instance.js'; | ||
|
||
const fetchMemberByName = async (koreanName) => { | ||
try { | ||
const encodedName = encodeURIComponent(koreanName); | ||
const response = await instance.get(`/api/auth/member?name=${encodedName}`); | ||
console.log('Received response:', response); | ||
|
||
if (response.data.success) { | ||
return response.data.data; | ||
} else { | ||
throw new Error(response.data.message || "Failed to fetch member data"); | ||
} | ||
} catch (error) { | ||
console.error("Error fetching member data:", error.message); | ||
throw error; | ||
} | ||
}; | ||
|
||
export default fetchMemberByName; |
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 {instance} from './../api/instance.js'; | ||
|
||
const fetchMembersList = async () => { | ||
try { | ||
const cookies = document.cookie; | ||
console.log('Sending cookies:', cookies); | ||
|
||
const response = await instance.get('api/auth/member/all', { | ||
}); | ||
console.log('들어오는 응답',response); | ||
return response; | ||
} catch (error) { | ||
console.error("Error fetching chat list!:", error.message); | ||
throw error; | ||
} | ||
}; | ||
|
||
export default fetchMembersList; |