diff --git a/index.html b/index.html index b1d11ad..5d72d04 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - مون‌تایم + منتایم diff --git a/src/api/business-registrations.ts b/src/api/business-registrations.ts new file mode 100644 index 0000000..5ccc366 --- /dev/null +++ b/src/api/business-registrations.ts @@ -0,0 +1,16 @@ +import { api } from './client'; +import type { + BusinessRegistrationRequest, + CreateBusinessRegistrationPayload, +} from './types'; + +export function fetchMyBusinessRegistrations() { + return api('/business-registration-requests/mine'); +} + +export function submitBusinessRegistration(payload: CreateBusinessRegistrationPayload) { + return api('/business-registration-requests', { + method: 'POST', + body: JSON.stringify(payload), + }); +} diff --git a/src/api/businesses.ts b/src/api/businesses.ts index d19fcf5..3dacb0f 100644 --- a/src/api/businesses.ts +++ b/src/api/businesses.ts @@ -1,5 +1,5 @@ import { api } from './client'; -import type { Business } from './types'; +import type { Business, UpdateBusinessPayload } from './types'; export function fetchBusinesses(params?: { categoryId?: string; @@ -19,3 +19,14 @@ export function fetchBusinesses(params?: { export function fetchBusiness(id: string) { return api(`/businesses/${id}`); } + +export function fetchMyBusinesses() { + return api('/businesses/mine'); +} + +export function updateBusiness(id: string, payload: UpdateBusinessPayload) { + return api(`/businesses/${id}`, { + method: 'PATCH', + body: JSON.stringify(payload), + }); +} diff --git a/src/api/types.ts b/src/api/types.ts index 8d4c0b5..c02b29d 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -23,10 +23,47 @@ export type Business = { longitude: number | null; isActive: boolean; categoryId: string; + ownerId?: string | null; category?: BusinessCategory; images?: BusinessImage[]; }; +export type BusinessRegistrationStatus = 'pending' | 'approved' | 'rejected'; + +export type BusinessRegistrationRequest = { + id: string; + applicantId: string; + status: BusinessRegistrationStatus; + title: string; + slug: string; + categoryId: string; + description: string | null; + contactPhone: string | null; + address: string | null; + adminNote: string | null; + businessId: string | null; + createdAt: string; + category?: BusinessCategory; + applicant?: { id: string; mobile: string; fullName: string | null }; +}; + +export type CreateBusinessRegistrationPayload = { + title: string; + categoryId: string; + description?: string; + contactPhone?: string; + address?: string; +}; + +export type UpdateBusinessPayload = { + title?: string; + description?: string | null; + contactPhone?: string | null; + address?: string | null; + latitude?: number | null; + longitude?: number | null; +}; + export type ServiceTemplate = { id: string; title: string; diff --git a/src/layouts/WebAppLayout.vue b/src/layouts/WebAppLayout.vue index 449e9ba..1c1ccc1 100644 --- a/src/layouts/WebAppLayout.vue +++ b/src/layouts/WebAppLayout.vue @@ -4,7 +4,7 @@ class="sticky top-0 z-10 flex items-center justify-between border-b border-border bg-surface/95 px-4 py-3 backdrop-blur" >
-

مون‌تایم

+

منتایم

{{ auth.user.mobile }}

@@ -28,7 +28,7 @@ >
{ label: 'کسب‌وکار', icon: '🏪', }); + } else if (auth.isCustomer) { + items.splice(2, 0, { + to: '/app/register-business', + name: 'app-register-business', + label: 'ثبت کسب‌وکار', + icon: '➕', + }); } return items; }); diff --git a/src/router/index.ts b/src/router/index.ts index 72720a1..71edce4 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -41,6 +41,12 @@ const router = createRouter({ component: () => import('@/views/app/AppProfileView.vue'), meta: { requiresAuth: true }, }, + { + path: '/app/register-business', + name: 'app-register-business', + component: () => import('@/views/app/AppRegisterBusinessView.vue'), + meta: { requiresAuth: true, requiresCustomer: true }, + }, { path: '/app/owner', name: 'app-owner', @@ -54,7 +60,7 @@ const router = createRouter({ router.beforeEach(async (to) => { const auth = useAuthStore(); - if (auth.token && !auth.user) { + if (auth.token) { await auth.loadUser(); } @@ -66,6 +72,10 @@ router.beforeEach(async (to) => { return { name: 'app-home' }; } + if (to.meta.requiresCustomer && !auth.isCustomer) { + return auth.isBusinessOwner ? { name: 'app-owner' } : { name: 'app-home' }; + } + if (to.meta.guest && auth.isLoggedIn) { return { name: 'app-home' }; } diff --git a/src/views/app/AppOwnerView.vue b/src/views/app/AppOwnerView.vue index 2a5f246..d7091a6 100644 --- a/src/views/app/AppOwnerView.vue +++ b/src/views/app/AppOwnerView.vue @@ -1,13 +1,125 @@