2026-03-24 14:35:23 +05:30
|
|
|
import apiClient from "@/api/client";
|
2026-05-11 10:51:34 +05:30
|
|
|
import toast from "react-hot-toast";
|
2026-03-24 14:35:23 +05:30
|
|
|
|
|
|
|
|
export const getCareersApi = async () => {
|
2026-05-11 00:04:22 +05:30
|
|
|
const res = await apiClient.get("/careers/getAll?admin=true");
|
2026-03-24 14:35:23 +05:30
|
|
|
return res.data;
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-11 10:51:34 +05:30
|
|
|
export const createCareerApi = async (data: any) => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await apiClient.post("/careers", data);
|
|
|
|
|
|
|
|
|
|
toast.success("Career created successfully");
|
|
|
|
|
|
|
|
|
|
return res.data;
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
toast.error(error?.response?.data?.message || "Failed to create career");
|
|
|
|
|
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const updateCareerApi = async (id: number, data: any) => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await apiClient.patch(`/careers/${id}`, data);
|
|
|
|
|
|
|
|
|
|
toast.success("Career updated successfully");
|
|
|
|
|
|
|
|
|
|
return res.data;
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
toast.error(error?.response?.data?.message || "Failed to update career");
|
|
|
|
|
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-24 14:35:23 +05:30
|
|
|
export const deleteCareerApi = async (id: number) => {
|
2026-05-11 10:51:34 +05:30
|
|
|
try {
|
|
|
|
|
const res = await apiClient.delete(`/careers/${id}`);
|
|
|
|
|
|
|
|
|
|
toast.success("Career deleted successfully");
|
|
|
|
|
|
|
|
|
|
return res.data;
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
toast.error(error?.response?.data?.message || "Failed to delete career");
|
|
|
|
|
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
2026-03-24 14:35:23 +05:30
|
|
|
};
|