Add business owner service management for price comparison
This commit is contained in:
@@ -1,10 +1,47 @@
|
||||
import { api } from './client';
|
||||
import type { BusinessService } from './types';
|
||||
|
||||
export function fetchBusinessServices(businessId: string) {
|
||||
const search = new URLSearchParams({
|
||||
businessId,
|
||||
isActive: 'true',
|
||||
});
|
||||
export type CreateBusinessServicePayload = {
|
||||
businessId: string;
|
||||
serviceTemplateId: string;
|
||||
price: number;
|
||||
durationMinutes?: number | null;
|
||||
isActive?: boolean;
|
||||
};
|
||||
|
||||
export type UpdateBusinessServicePayload = {
|
||||
price?: number;
|
||||
durationMinutes?: number | null;
|
||||
isActive?: boolean;
|
||||
};
|
||||
|
||||
export function fetchBusinessServices(
|
||||
businessId: string,
|
||||
options?: { activeOnly?: boolean },
|
||||
) {
|
||||
const search = new URLSearchParams({ businessId });
|
||||
if (options?.activeOnly) {
|
||||
search.set('isActive', 'true');
|
||||
}
|
||||
return api<BusinessService[]>(`/business-services?${search}`);
|
||||
}
|
||||
|
||||
export function createBusinessService(payload: CreateBusinessServicePayload) {
|
||||
return api<BusinessService>('/business-services', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export function updateBusinessService(id: string, payload: UpdateBusinessServicePayload) {
|
||||
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',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { api } from './client';
|
||||
import type { ServiceTemplate } from './types';
|
||||
|
||||
export function fetchServiceTemplates(categoryId: string) {
|
||||
const search = new URLSearchParams({
|
||||
categoryId,
|
||||
isActive: 'true',
|
||||
});
|
||||
return api<ServiceTemplate[]>(`/service-templates?${search}`);
|
||||
}
|
||||
Reference in New Issue
Block a user