2026-05-26 15:48:01 +05:30
|
|
|
import apiClient from '@/api/client';
|
|
|
|
|
import toast from 'react-hot-toast';
|
2026-05-15 17:58:25 +05:30
|
|
|
|
2026-05-26 11:56:22 +05:30
|
|
|
export interface SeoData {
|
|
|
|
|
seoTitle?: string;
|
|
|
|
|
metaDescription?: string;
|
|
|
|
|
focusKeyphrase?: string;
|
|
|
|
|
tags?: string[];
|
|
|
|
|
ogTitle?: string;
|
|
|
|
|
ogDescription?: string;
|
|
|
|
|
ogImage?: string;
|
|
|
|
|
}
|
2026-05-15 17:58:25 +05:30
|
|
|
export interface HealthPackage {
|
|
|
|
|
id?: number;
|
|
|
|
|
name: string;
|
|
|
|
|
slug: string;
|
|
|
|
|
description?: string;
|
2026-05-25 11:37:51 +05:30
|
|
|
price?: number;
|
2026-05-18 11:55:55 +05:30
|
|
|
image?: string;
|
2026-05-15 17:58:25 +05:30
|
|
|
discountedPrice?: number;
|
|
|
|
|
inclusions: Record<string, string[]>;
|
|
|
|
|
categoryId: number;
|
|
|
|
|
isActive: boolean;
|
|
|
|
|
isFeatured: boolean;
|
|
|
|
|
sortOrder: number;
|
2026-05-26 11:56:22 +05:30
|
|
|
seo?: SeoData | null;
|
2026-05-15 17:58:25 +05:30
|
|
|
category?: {
|
|
|
|
|
name: string;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface HealthCategory {
|
|
|
|
|
id: number;
|
|
|
|
|
name: string;
|
|
|
|
|
slug: string;
|
|
|
|
|
sortOrder: number;
|
|
|
|
|
isActive: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface HealthInquiry {
|
|
|
|
|
id: number;
|
|
|
|
|
fullName: string;
|
|
|
|
|
mobileNumber: string;
|
|
|
|
|
email?: string;
|
|
|
|
|
age: string;
|
|
|
|
|
gender: string;
|
|
|
|
|
preferredDate: string;
|
|
|
|
|
message?: string;
|
|
|
|
|
createdAt: string;
|
|
|
|
|
healthPackage?: {
|
|
|
|
|
name: string;
|
|
|
|
|
category?: {
|
|
|
|
|
name: string;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getHealthCategoriesApi = async () => {
|
2026-05-26 15:48:01 +05:30
|
|
|
const res = await apiClient.get('/health-check/categories?admin=true');
|
2026-05-15 17:58:25 +05:30
|
|
|
return res.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getHealthPackagesApi = async () => {
|
2026-05-26 15:48:01 +05:30
|
|
|
const res = await apiClient.get('/health-check/packages?admin=true');
|
2026-05-15 17:58:25 +05:30
|
|
|
return res.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createHealthPackageApi = async (data: Partial<HealthPackage>) => {
|
|
|
|
|
try {
|
2026-05-26 15:48:01 +05:30
|
|
|
const res = await apiClient.post('/health-check', data);
|
|
|
|
|
toast.success('Package created successfully');
|
2026-05-15 17:58:25 +05:30
|
|
|
return res.data;
|
|
|
|
|
} catch (error: any) {
|
2026-05-26 15:48:01 +05:30
|
|
|
toast.error(error?.response?.data?.message || 'Failed to create package');
|
2026-05-15 17:58:25 +05:30
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-26 15:48:01 +05:30
|
|
|
export const updateHealthPackageApi = async (id: number, data: Partial<HealthPackage>) => {
|
2026-05-15 17:58:25 +05:30
|
|
|
try {
|
|
|
|
|
const res = await apiClient.patch(`/health-check/${id}`, data);
|
2026-05-26 15:48:01 +05:30
|
|
|
toast.success('Package updated successfully');
|
2026-05-15 17:58:25 +05:30
|
|
|
return res.data;
|
|
|
|
|
} catch (error: any) {
|
2026-05-26 15:48:01 +05:30
|
|
|
toast.error(error?.response?.data?.message || 'Failed to update package');
|
2026-05-15 17:58:25 +05:30
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const deleteHealthPackageApi = async (id: number) => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await apiClient.delete(`/health-check/${id}`);
|
2026-05-26 15:48:01 +05:30
|
|
|
toast.success('Package deleted successfully');
|
2026-05-15 17:58:25 +05:30
|
|
|
return res.data;
|
|
|
|
|
} catch (error: any) {
|
2026-05-26 15:48:01 +05:30
|
|
|
toast.error(error?.response?.data?.message || 'Failed to delete package');
|
2026-05-15 17:58:25 +05:30
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-26 15:48:01 +05:30
|
|
|
export const createCategoryApi = async (data: { name: string; slug: string; sortOrder: number }) => {
|
2026-05-18 10:58:24 +05:30
|
|
|
try {
|
2026-05-26 15:48:01 +05:30
|
|
|
const res = await apiClient.post('/health-check/categories', data);
|
2026-05-18 10:58:24 +05:30
|
|
|
|
2026-05-26 15:48:01 +05:30
|
|
|
toast.success('Category created successfully');
|
2026-05-18 10:58:24 +05:30
|
|
|
|
|
|
|
|
return res.data;
|
|
|
|
|
} catch (error: any) {
|
2026-05-26 15:48:01 +05:30
|
|
|
toast.error(error?.response?.data?.message || 'Failed to create category');
|
2026-05-18 10:58:24 +05:30
|
|
|
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
2026-05-15 17:58:25 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const updateCategoryApi = async (id: number, data: any) => {
|
2026-05-18 10:58:24 +05:30
|
|
|
try {
|
|
|
|
|
const res = await apiClient.patch(`/health-check/categories/${id}`, data);
|
|
|
|
|
|
2026-05-26 15:48:01 +05:30
|
|
|
toast.success('Category updated successfully');
|
2026-05-18 10:58:24 +05:30
|
|
|
|
|
|
|
|
return res.data;
|
|
|
|
|
} catch (error: any) {
|
2026-05-26 15:48:01 +05:30
|
|
|
toast.error(error?.response?.data?.message || 'Failed to update category');
|
2026-05-18 10:58:24 +05:30
|
|
|
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
2026-05-15 17:58:25 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const deleteCategoryApi = async (id: number) => {
|
2026-05-18 10:58:24 +05:30
|
|
|
try {
|
|
|
|
|
const res = await apiClient.delete(`/health-check/categories/${id}`);
|
|
|
|
|
|
2026-05-26 15:48:01 +05:30
|
|
|
toast.success('Category deleted successfully');
|
2026-05-18 10:58:24 +05:30
|
|
|
|
|
|
|
|
return res.data;
|
|
|
|
|
} catch (error: any) {
|
2026-05-26 15:48:01 +05:30
|
|
|
toast.error(error?.response?.data?.message || 'Failed to delete category');
|
2026-05-18 10:58:24 +05:30
|
|
|
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
2026-05-15 17:58:25 +05:30
|
|
|
};
|
|
|
|
|
|
2026-07-02 16:48:25 +05:30
|
|
|
export const getAllInquiriesApi = async (
|
|
|
|
|
page = 1,
|
|
|
|
|
limit = 10,
|
|
|
|
|
filterDate = '',
|
|
|
|
|
startDate = '',
|
|
|
|
|
endDate = '',
|
|
|
|
|
createdDate = '',
|
|
|
|
|
createdStartDate = '',
|
|
|
|
|
createdEndDate = '',
|
|
|
|
|
search = ''
|
|
|
|
|
) => {
|
2026-05-15 17:58:25 +05:30
|
|
|
const params = new URLSearchParams({
|
|
|
|
|
page: page.toString(),
|
|
|
|
|
limit: limit.toString(),
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-26 15:48:01 +05:30
|
|
|
if (filterDate) params.append('filterDate', filterDate);
|
|
|
|
|
if (startDate) params.append('startDate', startDate);
|
|
|
|
|
if (endDate) params.append('endDate', endDate);
|
2026-07-02 16:48:25 +05:30
|
|
|
if (createdDate) params.append('createdDate', createdDate);
|
|
|
|
|
if (createdStartDate) params.append('createdStartDate', createdStartDate);
|
|
|
|
|
if (createdEndDate) params.append('createdEndDate', createdEndDate);
|
|
|
|
|
if (search) params.append('search', search);
|
2026-05-15 17:58:25 +05:30
|
|
|
|
2026-05-26 15:48:01 +05:30
|
|
|
const res = await apiClient.get(`/health-check/inquiries?${params.toString()}`);
|
2026-05-15 17:58:25 +05:30
|
|
|
return res.data;
|
|
|
|
|
};
|