Add business services management in admin edit form
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { api } from './client';
|
||||
|
||||
export type BusinessService = {
|
||||
id: string;
|
||||
businessId: string;
|
||||
serviceTemplateId: string;
|
||||
price: string;
|
||||
durationMinutes: number | null;
|
||||
isActive: boolean;
|
||||
serviceTemplate?: {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string | null;
|
||||
defaultDurationMinutes: number;
|
||||
};
|
||||
};
|
||||
|
||||
export function fetchBusinessServices(businessId: string) {
|
||||
const search = new URLSearchParams({ businessId });
|
||||
return api<BusinessService[]>(`/business-services?${search}`);
|
||||
}
|
||||
|
||||
export function createBusinessService(payload: {
|
||||
businessId: string;
|
||||
serviceTemplateId: string;
|
||||
price: number;
|
||||
durationMinutes?: number | null;
|
||||
isActive?: boolean;
|
||||
}) {
|
||||
return api<BusinessService>('/business-services', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export function updateBusinessService(
|
||||
id: string,
|
||||
payload: { price?: number; durationMinutes?: number | null; isActive?: boolean },
|
||||
) {
|
||||
return api<BusinessService>(`/business-services/${id}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export function deleteBusinessService(id: string) {
|
||||
return api<{ success: true }>(`/business-services/${id}`, { method: 'DELETE' });
|
||||
}
|
||||
Reference in New Issue
Block a user