-
Notifications
You must be signed in to change notification settings - Fork 1
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 #545 from depromeet/feat/reaction
[Feat] 리액션 기능 추가
- Loading branch information
Showing
31 changed files
with
786 additions
and
6 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,83 @@ | ||
import getQueryKey from '@/apis/getQueryKey'; | ||
import { type EmojiType } from '@/apis/schema/reaction'; | ||
import useMutationHandleError from '@/hooks/query/useMutationHandleError'; | ||
import { type UseMutationOptions, useQuery } from '@tanstack/react-query'; | ||
|
||
import apiInstance from './instance.api'; | ||
|
||
interface MemberProfileType { | ||
memberId: number; | ||
nickname: string; | ||
profileImageUrl: string; | ||
} | ||
|
||
interface ReactionItemType { | ||
reactionId: number; | ||
createdAt: string; | ||
updatedAt: string; | ||
memberProfile: MemberProfileType; | ||
} | ||
|
||
export interface ReactionType { | ||
emojiType: EmojiType; | ||
count: number; | ||
reactions: ReactionItemType[]; | ||
} | ||
|
||
export type GetReactionsResponse = Array<ReactionType>; | ||
|
||
interface AddReactionRequest { | ||
missionRecordId: number; | ||
emojiType: EmojiType; | ||
} | ||
|
||
interface AddReactionResponse { | ||
reactionId: number; | ||
emojiType: EmojiType; | ||
memberId: number; | ||
missionRecordId: number; | ||
} | ||
|
||
interface ModifyReactionRequest { | ||
reactionId: number; | ||
emojiType: EmojiType; | ||
} | ||
|
||
export const REACTION_API = { | ||
getReactions: async (recordId: number): Promise<GetReactionsResponse> => { | ||
const { data } = await apiInstance.get<GetReactionsResponse>(`/reactions?missionRecordId=${recordId}`); | ||
return data; | ||
}, | ||
addReaction: async (request: AddReactionRequest) => { | ||
const { data } = await apiInstance.post<AddReactionResponse>('/reactions', request); | ||
return data; | ||
}, | ||
modifyReaction: async ({ reactionId, emojiType }: ModifyReactionRequest) => { | ||
console.log('reactionId: ', reactionId); | ||
const { data } = await apiInstance.put<AddReactionResponse>(`/reactions/${reactionId}`, { emojiType }); | ||
return data; | ||
}, | ||
}; | ||
|
||
export const useGetReactions = (recordId: number) => { | ||
return useQuery<GetReactionsResponse>({ | ||
queryKey: getQueryKey('reactions', { recordId }), | ||
queryFn: () => REACTION_API.getReactions(recordId), | ||
}); | ||
}; | ||
|
||
export const useAddReaction = (options?: UseMutationOptions<AddReactionResponse, unknown, AddReactionRequest>) => | ||
useMutationHandleError( | ||
{ mutationFn: REACTION_API.addReaction, ...options }, | ||
{ | ||
offset: 'default', | ||
}, | ||
); | ||
|
||
export const useModifyReaction = (options?: UseMutationOptions<AddReactionResponse, unknown, ModifyReactionRequest>) => | ||
useMutationHandleError( | ||
{ mutationFn: REACTION_API.modifyReaction, ...options }, | ||
{ | ||
offset: 'default', | ||
}, | ||
); |
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,27 @@ | ||
export enum EmojiType { | ||
BLUE_HEART = 'BLUE_HEART', | ||
THUMBS_UP = 'THUMBS_UP', | ||
FIRE = 'FIRE', | ||
PARTY_POPPER = 'PARTY_POPPER', | ||
UNICORN = 'UNICORN', | ||
PARTYING_FACE = 'PARTYING_FACE', | ||
SOMETHING_SPECIAL = 'SOMETHING_SPECIAL', | ||
GLOWING_STAR = 'GLOWING_STAR', | ||
SPARKLING_HEART = 'SPARKLING_HEART', | ||
EYES = 'EYES', | ||
} | ||
|
||
export const REACTION_EMOJI_IMAGE: Record<EmojiType, string> = { | ||
[EmojiType.BLUE_HEART]: '/images/reaction/BLUE_HEART.png', | ||
[EmojiType.GLOWING_STAR]: '/images/reaction/GLOWING_STAR.png', | ||
[EmojiType.SPARKLING_HEART]: '/images/reaction/SPARKLING_HEART.png', | ||
[EmojiType.UNICORN]: '/images/reaction/UNICORN.png', | ||
[EmojiType.EYES]: '/images/reaction/EYES.png', | ||
[EmojiType.FIRE]: '/images/reaction/FIRE.png', | ||
[EmojiType.PARTY_POPPER]: '/images/reaction/PARTY_POPPER.png', | ||
[EmojiType.PARTYING_FACE]: '/images/reaction/PARTYING_FACE.png', | ||
[EmojiType.SOMETHING_SPECIAL]: '/images/reaction/SOMETHING_SPECIAL.png', | ||
[EmojiType.THUMBS_UP]: '/images/reaction/THUMBS_UP.png', | ||
}; | ||
|
||
export const REACTION_EMOJI_LIST = Object.keys(EmojiType) as EmojiType[]; |
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
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.