qna
This commit is contained in:
29
src/entities/support/api/use-qna-save-mutation.ts
Normal file
29
src/entities/support/api/use-qna-save-mutation.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import axios from 'axios';
|
||||
import { API_URL } from '@/shared/api/urls';
|
||||
import { resultify } from '@/shared/lib/resultify';
|
||||
import { CBDCAxiosError } from '@/shared/@types/error';
|
||||
import {
|
||||
QnaSaveParams,
|
||||
QnaSaveResponse
|
||||
} from '../model/types';
|
||||
import {
|
||||
useMutation,
|
||||
UseMutationOptions
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
export const qnaSave = (params: QnaSaveParams) => {
|
||||
return resultify(
|
||||
axios.post<QnaSaveResponse>(API_URL.qnaSave(), params),
|
||||
);
|
||||
};
|
||||
|
||||
export const useQnaSaveMutation = (options?: UseMutationOptions<QnaSaveResponse, CBDCAxiosError, QnaSaveParams>) => {
|
||||
const mutation = useMutation<QnaSaveResponse, CBDCAxiosError, QnaSaveParams>({
|
||||
...options,
|
||||
mutationFn: (params: QnaSaveParams) => qnaSave(params),
|
||||
});
|
||||
|
||||
return {
|
||||
...mutation,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user