-
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.
- Loading branch information
Showing
40 changed files
with
602 additions
and
315 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { client, clientBasic } from '@/shared/remotes/axios'; | ||
import type { AccessTokenRes } from '../types/auth.type'; | ||
|
||
export const getAccessToken = async (platform: string, code: string) => { | ||
const { data } = await client.get<AccessTokenRes>(`/login/${platform}`, { | ||
params: { code }, | ||
}); | ||
|
||
return data; | ||
}; | ||
|
||
export const postRefreshAccessToken = async () => { | ||
const { data } = await clientBasic.post<AccessTokenRes>('/reissue'); | ||
|
||
return 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,3 @@ | ||
export interface AccessTokenRes { | ||
accessToken: string; | ||
} |
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,24 @@ | ||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; | ||
import { getComments, postComment } from '../remotes/comments'; | ||
|
||
export const useCommentsQuery = (songId: number, partId: number) => { | ||
const { data: comments, ...queries } = useQuery({ | ||
queryKey: ['comments', songId, partId], | ||
queryFn: () => getComments(songId, partId), | ||
}); | ||
|
||
return { comments, queries }; | ||
}; | ||
|
||
export const usePostCommentMutation = () => { | ||
const client = useQueryClient(); | ||
|
||
const { mutate: postNewComment, ...mutations } = useMutation({ | ||
mutationFn: postComment, | ||
onSuccess: (_, { songId, partId }) => { | ||
client.invalidateQueries({ queryKey: ['comments', songId, partId] }); | ||
}, | ||
}); | ||
|
||
return { postNewComment, mutations }; | ||
}; |
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 { client } from '@/shared/remotes/axios'; | ||
import type { Comment } from '../types/comment.type'; | ||
|
||
export const postComment = async ({ | ||
songId, | ||
partId, | ||
content, | ||
}: { | ||
songId: number; | ||
partId: number; | ||
content: string; | ||
}) => { | ||
await client.post(`/songs/${songId}/parts/${partId}/comments`, { content }); | ||
}; | ||
|
||
export const getComments = async (songId: number, partId: number) => { | ||
const { data } = await client.get<Comment[]>(`/songs/${songId}/parts/${partId}/comments`); | ||
|
||
return 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,6 @@ | ||
export interface Comment { | ||
id: number; | ||
content: string; | ||
createdAt: string; | ||
writerNickname: string; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { client } from '@/shared/remotes/axios'; | ||
import type { KillingPartPostRequest } from '@/shared/types/killingPart'; | ||
import type { SongInfo } from '@/shared/types/song'; | ||
|
||
// PartCollectingPage에 존재하던 remote 함수입니다. | ||
// useFetch<SongInfo>(() => fetcher(`/songs/${songId}`, 'GET')) 로직에서 분리하였습니다. | ||
// SongInfo type에는 killingPart[] 필드가 있는데, 마이파트 수집용 `노래 1개` 조회에서 해당 타입이 사용되고 있습니다. | ||
// 추후 수정되어야 합니다. | ||
|
||
export const getSong = async (songId: number) => { | ||
const { data } = await client.get<SongInfo>(`/songs/${songId}`); | ||
|
||
return data; | ||
}; | ||
|
||
export const postKillingPart = async (songId: number, body: KillingPartPostRequest) => { | ||
await client.post(`/songs/${songId}/member-parts`, body); | ||
}; |
8 changes: 0 additions & 8 deletions
8
frontend/src/features/killingParts/remotes/usePostKillingPart.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.