-
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.
- Loading branch information
Showing
11 changed files
with
256 additions
and
21 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
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
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,3 +1,4 @@ | ||
export { default as useBottomSheetState } from './useBottomSheetState'; | ||
export { useIsMounted } from './useIsMounted'; | ||
export { default as useToast } from './useToast'; | ||
export { default as useUploadImage } from './useUploadImage'; |
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,17 @@ | ||
import { useState } from 'react'; | ||
|
||
const useBottomSheetState = <TBottomSheetType>() => { | ||
const [openedSheet, setOpenedSheet] = useState<TBottomSheetType | null>(); | ||
|
||
const onOpenSheet = (bottomSheetType: TBottomSheetType) => { | ||
setOpenedSheet(bottomSheetType); | ||
}; | ||
|
||
const onCloseSheet = () => { | ||
setOpenedSheet(null); | ||
}; | ||
|
||
return { onOpenSheet, openedSheet, onCloseSheet }; | ||
}; | ||
|
||
export default useBottomSheetState; |
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,11 +1,13 @@ | ||
export { default as useCreateVoteMutation } from './useCreateVoteMutation'; | ||
export { default as useCreateVoteReplyMutation } from './useCreateVoteReplyMutation'; | ||
export { default as useDeleteVoteMutation } from './useDeleteVoteMutation'; | ||
export { default as useDeleteVoteReplyMutation } from './useDeleteVoteReplyMutation'; | ||
export { useGetAllVotes } from './useGetAllVotes'; | ||
export { default as useGetMyVote } from './useGetMyVote'; | ||
export { useGetVoteById } from './useGetVoteById'; | ||
export { useGetVoteBySearch } from './useGetVoteBySearch'; | ||
export { default as useGetVoteReplies } from './useGetVoteReplies'; | ||
export { default as useLikeVoteMutation } from './useLikeVoteMutation'; | ||
export { default as useLikeVoteReplyMutation } from './useLikeVoteReplyMutation'; | ||
export { default as useUpdateVoteReplyMutation } from './useUpdateVoteReplyMutation'; | ||
export { default as useVotingMutation } from './useVotingMutation'; | ||
|
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,32 @@ | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
|
||
import { useToast } from '@/hooks'; | ||
import { del } from '@/lib/axios'; | ||
import { SuccessResponse } from '@/types/response'; | ||
|
||
type DeleteVoteRequest = { | ||
voteId: number; | ||
}; | ||
|
||
const deleteVote = async ({ voteId }: DeleteVoteRequest) => { | ||
const response = await del<SuccessResponse<undefined>>(`/vote/${voteId}`); | ||
return response.data; | ||
}; | ||
|
||
const useDeleteVoteMutation = () => { | ||
const toast = useToast(); | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: deleteVote, | ||
onSuccess: async () => { | ||
await queryClient.invalidateQueries({ queryKey: ['votes'], refetchType: 'all' }); | ||
toast({ message: 'VOTE_DELETE_SUCCESS' }); | ||
}, | ||
onError: () => { | ||
toast({ message: 'VOTE_DELETE_FAIL' }); | ||
}, | ||
}); | ||
}; | ||
|
||
export default useDeleteVoteMutation; |
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,22 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { get } from '@/lib/axios'; | ||
import { SuccessResponse } from '@/types/response'; | ||
import { VoteType } from '@/types/vote'; | ||
|
||
const getMyVote = async () => { | ||
const response = await get<SuccessResponse<VoteType[]>>('/vote/mine'); | ||
return response.data.data; | ||
}; | ||
|
||
const useGetMyVote = () => { | ||
return useQuery({ | ||
queryFn: getMyVote, | ||
queryKey: ['votes', 'mine'], | ||
retry: 1, | ||
staleTime: Infinity, | ||
gcTime: Infinity, | ||
}); | ||
}; | ||
|
||
export default useGetMyVote; |