@@ -0,0 +1,33 @@
|
||||
import axios from "@/config/axios";
|
||||
import type {
|
||||
CampaignResponse,
|
||||
CampaignsResponse,
|
||||
CreateDiscountCampaignType,
|
||||
GetCampaignsParams,
|
||||
} from "../types/Types";
|
||||
|
||||
export const getCampaigns = async (
|
||||
params?: GetCampaignsParams
|
||||
): Promise<CampaignsResponse> => {
|
||||
const { data } = await axios.get<CampaignsResponse>("/admin/campaigns", {
|
||||
params,
|
||||
});
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getCampaignById = async (id: string): Promise<CampaignResponse> => {
|
||||
const { data } = await axios.get<CampaignResponse>(`/admin/campaigns/${id}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const createDiscountCampaign = async (
|
||||
params: CreateDiscountCampaignType
|
||||
) => {
|
||||
const { data } = await axios.post("/admin/campaigns/discount", params);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const deleteCampaign = async (id: string) => {
|
||||
const { data } = await axios.delete(`/admin/campaigns/${id}`);
|
||||
return data;
|
||||
};
|
||||
Reference in New Issue
Block a user