Files
negareh-admin/src/pages/chat/hooks/useChatData.ts
T
morteza c01f1a32dc
deploy to danak / build_and_deploy (push) Has been cancelled
chat composer
2026-07-17 23:58:18 +03:30

30 lines
770 B
TypeScript

import { useMutation, useQuery } from '@tanstack/react-query'
import * as api from '../service/ChatService'
import type { AddChatMessageType } from '../type/Types'
export const useGetChatMessages = (refId: string) => {
return useQuery({
queryKey: ['chat', refId],
queryFn: () => api.getChatMessages(refId),
enabled: !!refId,
})
}
export const useAddChatMessage = () => {
return useMutation({
mutationFn: ({
refId,
params,
}: {
refId: string
params: AddChatMessageType
}) => api.addChatMessage(refId, params),
})
}
export const useDeleteChatMessage = () => {
return useMutation({
mutationFn: (id: string) => api.deleteChatMessage(id),
})
}