46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import axios from "../../../config/axios";
|
|
import type {
|
|
CreateCouponType,
|
|
CouponType,
|
|
CouponsResponse,
|
|
GetCouponDetailResponseType,
|
|
} from "../types/Types";
|
|
|
|
export const getCoupons = async (
|
|
page: number = 1,
|
|
search: string
|
|
): Promise<CouponsResponse> => {
|
|
const { data } = await axios.get(
|
|
`/admin/coupon/native?page=${page}&q=${search}`
|
|
);
|
|
return data;
|
|
};
|
|
|
|
export const createCoupon = async (
|
|
couponData: CreateCouponType
|
|
): Promise<CouponType> => {
|
|
const { data } = await axios.post("/admin/coupon", couponData);
|
|
return data;
|
|
};
|
|
|
|
export const deleteCoupon = async (couponId: string): Promise<void> => {
|
|
await axios.delete(`/admin/coupon/${couponId}/delete`);
|
|
};
|
|
|
|
export const getCouponDetail = async (
|
|
couponId: string
|
|
): Promise<GetCouponDetailResponseType> => {
|
|
const { data } = await axios.get(`/admin/coupon/${couponId}`);
|
|
return data;
|
|
};
|
|
|
|
export const updateCoupon = async (
|
|
params: CreateCouponType
|
|
): Promise<CouponType> => {
|
|
const { data } = await axios.patch(
|
|
`/admin/coupon/${params.couponId}`,
|
|
params
|
|
);
|
|
return data;
|
|
};
|