From d0439448053ad88f8f5e05e4ed89745636150417 Mon Sep 17 00:00:00 2001 From: Mahdi Date: Sun, 24 May 2026 11:34:52 +0330 Subject: [PATCH] Add business owner service management for price comparison --- src/api/business-services.ts | 47 ++- src/api/service-templates.ts | 10 + src/views/app/AppBusinessDetailView.vue | 2 +- src/views/app/AppOwnerView.vue | 369 +++++++++++++++++++++--- 4 files changed, 387 insertions(+), 41 deletions(-) create mode 100644 src/api/service-templates.ts diff --git a/src/api/business-services.ts b/src/api/business-services.ts index a614f13..2ebf23f 100644 --- a/src/api/business-services.ts +++ b/src/api/business-services.ts @@ -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(`/business-services?${search}`); } + +export function createBusinessService(payload: CreateBusinessServicePayload) { + return api('/business-services', { + method: 'POST', + body: JSON.stringify(payload), + }); +} + +export function updateBusinessService(id: string, payload: UpdateBusinessServicePayload) { + return api(`/business-services/${id}`, { + method: 'PATCH', + body: JSON.stringify(payload), + }); +} + +export function deleteBusinessService(id: string) { + return api<{ success: true }>(`/business-services/${id}`, { + method: 'DELETE', + }); +} diff --git a/src/api/service-templates.ts b/src/api/service-templates.ts new file mode 100644 index 0000000..8fd676f --- /dev/null +++ b/src/api/service-templates.ts @@ -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(`/service-templates?${search}`); +} diff --git a/src/views/app/AppBusinessDetailView.vue b/src/views/app/AppBusinessDetailView.vue index e3144d6..360930b 100644 --- a/src/views/app/AppBusinessDetailView.vue +++ b/src/views/app/AppBusinessDetailView.vue @@ -111,7 +111,7 @@ async function load() { error.value = ''; try { business.value = await fetchBusiness(id); - services.value = await fetchBusinessServices(id); + services.value = await fetchBusinessServices(id, { activeOnly: true }); } catch (e) { error.value = e instanceof ApiError ? e.message : 'بارگذاری اطلاعات ناموفق بود.'; diff --git a/src/views/app/AppOwnerView.vue b/src/views/app/AppOwnerView.vue index d7091a6..2cb3447 100644 --- a/src/views/app/AppOwnerView.vue +++ b/src/views/app/AppOwnerView.vue @@ -17,63 +17,227 @@
در حال بارگذاری…
-
+
کسب‌وکاری به حساب شما وصل نیست.
-
-
-

دسته

-

{{ business.category?.title ?? '—' }}

- - {{ business.isActive ? 'فعال' : 'غیرفعال' }} - -
+
+ +

اطلاعات کسب‌وکار

- +
+

دسته

+

{{ business.category?.title ?? '—' }}

+ + {{ business.isActive ? 'فعال' : 'غیرفعال' }} + +
-
- -