-
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
31 changed files
with
974 additions
and
617 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,32 @@ | ||
import type { | ||
GetMessageRoomsReq, | ||
GetMessageRoomsRes, | ||
GetMessageReq, | ||
GetMessageRes, | ||
CreateMessageReq, | ||
CreateMessageRes, | ||
CreateMessageRoomReq, | ||
CreateMessageRoomRes | ||
} from './types' | ||
import { http } from '@utils/http' | ||
|
||
export const getMessageRooms = (params: GetMessageRoomsReq) => | ||
http.get<GetMessageRoomsReq, GetMessageRoomsRes>('/msgrooms', params) | ||
|
||
export const getMessage = (params: GetMessageReq) => | ||
http.get<GetMessageReq, GetMessageRes>( | ||
`/msgrooms/${params.msgRoomId}/msgs`, | ||
params | ||
) | ||
|
||
export const createMessage = ({ messageRoomId, ...params }: CreateMessageReq) => | ||
http.post<Omit<CreateMessageReq, 'messageRoomId'>, CreateMessageRes>( | ||
`/msgrooms/${messageRoomId}/msgs`, | ||
params | ||
) | ||
|
||
export const deleteMessageRoom = (messageRoomId: number) => | ||
http.delete<null>(`/msgrooms/${messageRoomId}`) | ||
|
||
export const createMessageRoom = (params: CreateMessageRoomReq) => | ||
http.post<CreateMessageRoomReq, CreateMessageRoomRes>('/msgrooms', params) |
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 +1,2 @@ | ||
export * from './types' | ||
export * from './queries' |
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,42 @@ | ||
import { useMutation, useQuery } from '@tanstack/react-query' | ||
import { | ||
getMessageRooms, | ||
getMessage, | ||
createMessage, | ||
deleteMessageRoom, | ||
createMessageRoom | ||
} from './apis' | ||
import type { | ||
CreateMessageReq, | ||
GetMessageReq, | ||
GetMessageRoomsReq, | ||
CreateMessageRoomReq | ||
} from './types' | ||
|
||
export const useGetMessageRoomsQuery = (params: GetMessageRoomsReq) => | ||
useQuery({ | ||
queryKey: ['getMessageRooms', params], | ||
queryFn: () => getMessageRooms(params) | ||
}) | ||
|
||
export const useGetMessageQuery = (params: GetMessageReq) => | ||
useQuery({ | ||
queryKey: ['getMessage', params], | ||
queryFn: () => getMessage(params), | ||
enabled: typeof params.msgRoomId === 'number' | ||
}) | ||
|
||
export const useCreateMessageMutation = () => | ||
useMutation({ | ||
mutationFn: (params: CreateMessageReq) => createMessage(params) | ||
}) | ||
|
||
export const useDeleteMessageRoomMutation = (messageRoomId: number) => | ||
useMutation({ | ||
mutationFn: () => deleteMessageRoom(messageRoomId) | ||
}) | ||
|
||
export const useCreateMessageRoomMutation = () => | ||
useMutation({ | ||
mutationFn: (params: CreateMessageRoomReq) => createMessageRoom(params) | ||
}) |
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
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
Oops, something went wrong.