34 lines
718 B
TypeScript
34 lines
718 B
TypeScript
// imports
|
|
|
|
import { useMutation } from "@tanstack/vue-query";
|
|
import axios from "~/configs/axios.config";
|
|
import { API_ENDPOINTS } from "~/constants";
|
|
|
|
// types
|
|
|
|
export type CreateBranchRequest = {
|
|
name: string;
|
|
description: string;
|
|
};
|
|
|
|
// methods
|
|
|
|
export const handleCreateBranch = async ({ name, description }: CreateBranchRequest) => {
|
|
const payload: CreateBranchRequest = {
|
|
name,
|
|
description,
|
|
};
|
|
|
|
await axios.post<CreateBranchRequest>(API_ENDPOINTS.branch.createBranch, payload);
|
|
};
|
|
|
|
// composable
|
|
|
|
const useCreateBranch = () => {
|
|
return useMutation({
|
|
mutationFn: (data: CreateBranchRequest) => handleCreateBranch(data),
|
|
});
|
|
};
|
|
|
|
export default useCreateBranch;
|