feat: facility and google review crud
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import apiClient from '@/api/client';
|
||||
import toast from 'react-hot-toast';
|
||||
|
||||
export interface GoogleReview {
|
||||
id?: number;
|
||||
reviewerName: string;
|
||||
reviewerImage?: string;
|
||||
rating: number;
|
||||
review: string;
|
||||
reviewDate?: string | null;
|
||||
googleReviewUrl?: string;
|
||||
isFeatured: boolean;
|
||||
isActive: boolean;
|
||||
sortOrder: number;
|
||||
}
|
||||
|
||||
export const getGoogleReviewsApi = async () => {
|
||||
const res = await apiClient.get('/google-reviews/getAll');
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const getActiveGoogleReviewsApi = async () => {
|
||||
const res = await apiClient.get('/google-reviews/active');
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const createGoogleReviewApi = async (data: GoogleReview) => {
|
||||
try {
|
||||
const res = await apiClient.post('/google-reviews', data);
|
||||
toast.success('Google review created successfully');
|
||||
return res.data;
|
||||
} catch (error: any) {
|
||||
toast.error(error?.response?.data?.message || 'Failed to create review');
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const updateGoogleReviewApi = async (id: number, data: Partial<GoogleReview>) => {
|
||||
try {
|
||||
const res = await apiClient.put(`/google-reviews/${id}`, data);
|
||||
toast.success('Google review updated successfully');
|
||||
return res.data;
|
||||
} catch (error: any) {
|
||||
toast.error(error?.response?.data?.message || 'Failed to update review');
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteGoogleReviewApi = async (id: number) => {
|
||||
try {
|
||||
const res = await apiClient.delete(`/google-reviews/${id}`);
|
||||
toast.success('Google review deleted successfully');
|
||||
return res.data;
|
||||
} catch (error: any) {
|
||||
toast.error(error?.response?.data?.message || 'Failed to delete review');
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user