49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
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' });
|
|
}
|