-
Notifications
You must be signed in to change notification settings - Fork 0
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 #52 from Kakaotech-10/feature/Login
✨ 카카오 회원가입 추가 정보 입력
- Loading branch information
Showing
4 changed files
with
170 additions
and
115 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,30 @@ | ||
// useGetCourse.jsx | ||
import { useState, useEffect } from "react"; | ||
import api from "../api/config"; | ||
|
||
export const useGetCourse = () => { | ||
const [courses, setCourses] = useState([]); | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [error, setError] = useState(null); | ||
|
||
useEffect(() => { | ||
const fetchCourses = async () => { | ||
setIsLoading(true); | ||
try { | ||
const response = await api.get("/api/v1/members/course"); | ||
setCourses(response.data.courses); | ||
setError(null); | ||
} catch (error) { | ||
console.error("Error fetching courses:", error); | ||
setError("코스 목록을 불러오는데 실패했습니다."); | ||
setCourses([]); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
fetchCourses(); | ||
}, []); | ||
|
||
return { courses, isLoading, error }; | ||
}; |
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,32 @@ | ||
// usePatchMember.jsx | ||
import { useState } from "react"; | ||
import api from "../api/config"; | ||
|
||
export const usePatchMember = () => { | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [error, setError] = useState(null); | ||
|
||
const updateMember = async (memberId, memberData) => { | ||
setIsLoading(true); | ||
setError(null); | ||
|
||
try { | ||
const response = await api.patch(`/api/v1/members/${memberId}`, { | ||
name: memberData.memberName, | ||
nameEnglish: memberData.memberNameEnglish, | ||
course: memberData.course, | ||
}); | ||
|
||
return response.data; | ||
} catch (err) { | ||
setError( | ||
err.response?.data?.message || "회원 정보 수정 중 오류가 발생했습니다." | ||
); | ||
throw err; | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
return { updateMember, isLoading, error }; | ||
}; |
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