-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
368 additions
and
15 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
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,117 @@ | ||
import { | ||
CrewGalleryDetailResponse, | ||
CrewGalleryRequest, | ||
CrewGalleryResponse, | ||
CrewJoinResponse, | ||
CrewMemberResponse, | ||
CrewNoticeDetailResponse, | ||
CrewNoticeRequest, | ||
CrewNoticeResponse, | ||
CrewResponse, | ||
} from "@/types/crew"; | ||
import { api } from "."; | ||
|
||
export const getCrewNotice = async ( | ||
crewId: number | ||
): Promise<CrewNoticeResponse> => { | ||
const response = await api.get(`/crew/${crewId}/notice`); | ||
return response.data; | ||
}; | ||
|
||
export const postCrewNotice = async ({ | ||
crewId, | ||
data, | ||
}: { | ||
crewId: number; | ||
data: CrewNoticeRequest; | ||
}) => { | ||
const response = await api.post(`/crew/${crewId}/notice`, { data }); | ||
return response.data; | ||
}; | ||
|
||
export const getCrewNoticeDetail = async ({ | ||
crewId, | ||
crewPostId, | ||
}: { | ||
crewId: number; | ||
crewPostId: number; | ||
}): Promise<CrewNoticeDetailResponse> => { | ||
const response = await api.get(`/crew/${crewId}/notice/${crewPostId}`); | ||
return response.data; | ||
}; | ||
|
||
export const JoinCrew = async (crewId: number): Promise<CrewJoinResponse> => { | ||
const response = await api.post(`/crew/${crewId}/join`); | ||
return response.data; | ||
}; | ||
|
||
export const CreateCrew = async (data: number) => { | ||
const response = await api.post(`/crew/create`, { data }); | ||
return response.data; | ||
}; | ||
|
||
// 다른 크루 조회 api | ||
export const getCrew = async (): Promise<CrewResponse> => { | ||
const response = await api.get(`/crew`); | ||
return response.data; | ||
}; | ||
|
||
// 크루 멤버, 크루명, 포스팅 수 api | ||
export const getCrewMember = async ( | ||
crewId: number | ||
): Promise<CrewMemberResponse> => { | ||
const response = await api.get(`/crew/${crewId}/member`); | ||
return response.data; | ||
}; | ||
|
||
export const getCrewGallery = async ( | ||
crewId: number | ||
): Promise<CrewGalleryResponse> => { | ||
const response = await api.get(`/crew/${crewId}/gallery`); | ||
return response.data; | ||
}; | ||
|
||
export const getCrewGalleryDetail = async ( | ||
crewId: number, | ||
postId: number | ||
): Promise<CrewGalleryDetailResponse> => { | ||
const response = await api.get(`/crew/${crewId}/gallery/${postId}`); | ||
return response.data; | ||
}; | ||
|
||
export const getCrewGalleryDetailComments = async ( | ||
crewId: number, | ||
postId: number | ||
): Promise<CrewGalleryDetailResponse> => { | ||
const response = await api.get(`/crew/${crewId}/gallery/${postId}/comments`); | ||
return response.data; | ||
}; | ||
|
||
// 백엔드 확인 필요(multipart?) | ||
export const postCrewGallery = async ({ | ||
crewId, | ||
data, | ||
}: { | ||
crewId: number; | ||
data: CrewGalleryRequest; | ||
}) => { | ||
const response = await api.post(`/crew/${crewId}/gallery`, { data }); | ||
return response.data; | ||
}; | ||
|
||
export const postCrewGalleryComments = async ( | ||
crewId: number, | ||
postId: number, | ||
content: string | ||
) => { | ||
const response = await api.post( | ||
`/crew/${crewId}/gallery/${postId}/comments`, | ||
{ content } | ||
); | ||
return response.data; | ||
}; | ||
|
||
export const postCrewGalleryLike = async (crewId: number, postId: number) => { | ||
const response = await api.post(`/crew/${crewId}/gallery/${postId}/like`); | ||
return response.data; | ||
}; |
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,15 @@ | ||
import { reviewRequest, runningRequest } from "@/types/running"; | ||
import { api } from "."; | ||
|
||
export const postCourseReview = async ( | ||
userCourseId: number, | ||
data: reviewRequest | ||
) => { | ||
const response = await api.post(`/running/review/${userCourseId}`, { data }); | ||
return response.data; | ||
}; | ||
|
||
export const postRunningRecord = async (data: runningRequest) => { | ||
const response = await api.post(`/running/record`, { data }); | ||
return response.data; | ||
}; |
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,10 +1,54 @@ | ||
import { getRecommendCourseData } from "@/apis/course"; | ||
import { | ||
getAllCourseData, | ||
getLikesCourseData, | ||
getRecommendCourseData, | ||
postCourseBookmark, | ||
uploadGpx, | ||
} from "@/apis/course"; | ||
import { courseResponseParams } from "@/types/course"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { useMutation, useQuery } from "@tanstack/react-query"; | ||
|
||
export const useCourseBookmarkPost = (courseId: number) => { | ||
return useMutation({ | ||
mutationFn: () => postCourseBookmark(courseId), | ||
onSuccess: () => { | ||
console.log("즐겨찾기 등록 성공"); | ||
}, | ||
onError: () => { | ||
console.log("즐겨찾기 등록 실패"); | ||
}, | ||
}); | ||
}; | ||
|
||
export const useUploadGpx = (data: number) => { | ||
return useMutation({ | ||
mutationFn: () => uploadGpx(data), | ||
onSuccess: () => { | ||
console.log("GPX 등록 성공"); | ||
}, | ||
onError: () => { | ||
console.log("GPX 등록 실패"); | ||
}, | ||
}); | ||
}; | ||
|
||
export const useRecommendCourseGet = ({ lat, lon }: courseResponseParams) => { | ||
return useQuery({ | ||
queryKey: ["course", lat, lon], | ||
queryFn: () => getRecommendCourseData({ lat, lon }), | ||
}); | ||
}; | ||
|
||
export const useLikesCourseGet = () => { | ||
return useQuery({ | ||
queryKey: ["like", "course"], | ||
queryFn: getLikesCourseData, | ||
}); | ||
}; | ||
|
||
export const useAllCourseCourseGet = () => { | ||
return useQuery({ | ||
queryKey: ["all", "course"], | ||
queryFn: getAllCourseData, | ||
}); | ||
}; |
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 { postCourseReview, postRunningRecord } from "@/apis/running"; | ||
import { reviewRequest, runningRequest } from "@/types/running"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
|
||
export const useCourseReviewPost = ( | ||
userCourseId: number, | ||
data: reviewRequest | ||
) => { | ||
return useMutation({ | ||
mutationFn: () => postCourseReview(userCourseId, data), | ||
onSuccess: () => { | ||
console.log("리뷰 등록 성공"); | ||
}, | ||
onError: () => { | ||
console.log("리뷰 등록 실패"); | ||
}, | ||
}); | ||
}; | ||
|
||
export const useRunningRecordPost = (data: runningRequest) => { | ||
return useMutation({ | ||
mutationFn: () => postRunningRecord(data), | ||
onSuccess: () => { | ||
console.log("러닝 코스 등록 성공"); | ||
}, | ||
onError: () => { | ||
console.log("러닝 코스 등록 실패"); | ||
}, | ||
}); | ||
}; |
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.