2026-05-23 18:13:25 +03:30
|
|
|
|
<template>
|
2026-06-12 20:16:14 +03:30
|
|
|
|
<ResponsiveAppLayout>
|
|
|
|
|
|
<h1 class="mb-1 text-xl font-bold text-text">ثبت کسبوکار</h1>
|
|
|
|
|
|
<p class="mb-6 text-sm text-muted">درخواست شما پس از بررسی ادمین تأیید میشود.</p>
|
2026-05-23 18:13:25 +03:30
|
|
|
|
|
2026-06-12 20:16:14 +03:30
|
|
|
|
<form class="mx-auto max-w-lg space-y-4" @submit.prevent="onSubmit">
|
|
|
|
|
|
<p
|
|
|
|
|
|
v-if="message"
|
|
|
|
|
|
class="rounded-xl border border-brand-500/40 bg-brand-500/10 px-4 py-3 text-sm text-brand-700 dark:text-brand-500"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ message }}
|
2026-05-23 18:13:25 +03:30
|
|
|
|
</p>
|
2026-06-12 20:16:14 +03:30
|
|
|
|
<p
|
|
|
|
|
|
v-if="error"
|
|
|
|
|
|
class="rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-600 dark:text-red-400"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ error }}
|
2026-05-23 18:13:25 +03:30
|
|
|
|
</p>
|
|
|
|
|
|
|
2026-06-12 20:16:14 +03:30
|
|
|
|
<AppInput id="bizTitle" v-model="form.businessTitle" label="نام کسبوکار" required />
|
|
|
|
|
|
<AppSelect
|
|
|
|
|
|
id="bizCategory"
|
|
|
|
|
|
v-model="form.categoryId"
|
|
|
|
|
|
label="دستهبندی"
|
|
|
|
|
|
:options="categoryOptions"
|
|
|
|
|
|
required
|
2026-05-23 18:13:25 +03:30
|
|
|
|
/>
|
2026-06-12 20:16:14 +03:30
|
|
|
|
<AppTextarea id="bizDescription" v-model="form.description" label="توضیحات" />
|
2026-05-23 18:13:25 +03:30
|
|
|
|
<AppInput id="bizAddress" v-model="form.address" label="آدرس" />
|
2026-06-12 20:16:14 +03:30
|
|
|
|
<AppInput id="bizPhone" v-model="form.phone" label="تلفن" ltr />
|
2026-05-23 18:13:25 +03:30
|
|
|
|
|
2026-06-12 20:16:14 +03:30
|
|
|
|
<AppButton type="submit" :loading="loading">ارسال درخواست</AppButton>
|
2026-05-23 18:13:25 +03:30
|
|
|
|
</form>
|
2026-06-12 20:16:14 +03:30
|
|
|
|
</ResponsiveAppLayout>
|
2026-05-23 18:13:25 +03:30
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import { computed, onMounted, ref } from 'vue';
|
|
|
|
|
|
import { fetchBusinessCategories } from '@/api/business-categories';
|
2026-06-12 20:16:14 +03:30
|
|
|
|
import { submitBusinessRegistration } from '@/api/business-registrations';
|
2026-05-23 18:13:25 +03:30
|
|
|
|
import { ApiError } from '@/api/client';
|
2026-06-12 20:16:14 +03:30
|
|
|
|
import type { BusinessCategory } from '@/api/types';
|
2026-05-23 18:13:25 +03:30
|
|
|
|
import AppButton from '@/components/ui/AppButton.vue';
|
|
|
|
|
|
import AppInput from '@/components/ui/AppInput.vue';
|
2026-06-12 20:16:14 +03:30
|
|
|
|
import AppSelect from '@/components/ui/AppSelect.vue';
|
|
|
|
|
|
import AppTextarea from '@/components/ui/AppTextarea.vue';
|
|
|
|
|
|
import ResponsiveAppLayout from '@/layouts/ResponsiveAppLayout.vue';
|
2026-05-23 18:13:25 +03:30
|
|
|
|
|
|
|
|
|
|
const categories = ref<BusinessCategory[]>([]);
|
2026-06-12 20:16:14 +03:30
|
|
|
|
const loading = ref(false);
|
|
|
|
|
|
const error = ref('');
|
|
|
|
|
|
const message = ref('');
|
2026-05-23 18:13:25 +03:30
|
|
|
|
const form = ref({
|
2026-06-12 20:16:14 +03:30
|
|
|
|
businessTitle: '',
|
2026-05-23 18:13:25 +03:30
|
|
|
|
categoryId: '',
|
|
|
|
|
|
description: '',
|
|
|
|
|
|
address: '',
|
2026-06-12 20:16:14 +03:30
|
|
|
|
phone: '',
|
2026-05-23 18:13:25 +03:30
|
|
|
|
});
|
|
|
|
|
|
|
2026-06-12 20:16:14 +03:30
|
|
|
|
const categoryOptions = computed(() =>
|
|
|
|
|
|
categories.value
|
|
|
|
|
|
.filter((category) => category.isActive)
|
|
|
|
|
|
.map((category) => ({ value: category.id, label: category.title })),
|
2026-05-23 18:13:25 +03:30
|
|
|
|
);
|
|
|
|
|
|
|
2026-06-12 20:16:14 +03:30
|
|
|
|
async function onSubmit() {
|
2026-05-23 18:13:25 +03:30
|
|
|
|
error.value = '';
|
2026-06-12 20:16:14 +03:30
|
|
|
|
message.value = '';
|
|
|
|
|
|
loading.value = true;
|
2026-05-23 18:13:25 +03:30
|
|
|
|
try {
|
2026-06-12 20:16:14 +03:30
|
|
|
|
await submitBusinessRegistration({
|
|
|
|
|
|
businessTitle: form.value.businessTitle.trim(),
|
|
|
|
|
|
categoryId: form.value.categoryId,
|
|
|
|
|
|
description: form.value.description.trim() || undefined,
|
|
|
|
|
|
address: form.value.address.trim() || undefined,
|
|
|
|
|
|
phone: form.value.phone.trim() || undefined,
|
|
|
|
|
|
});
|
|
|
|
|
|
message.value = 'درخواست شما ثبت شد. پس از بررسی نتیجه اعلام میشود.';
|
|
|
|
|
|
form.value = {
|
|
|
|
|
|
businessTitle: '',
|
|
|
|
|
|
categoryId: '',
|
|
|
|
|
|
description: '',
|
|
|
|
|
|
address: '',
|
|
|
|
|
|
phone: '',
|
|
|
|
|
|
};
|
2026-05-23 18:13:25 +03:30
|
|
|
|
} catch (e) {
|
2026-06-12 20:16:14 +03:30
|
|
|
|
error.value = e instanceof ApiError ? e.message : 'ثبت درخواست ناموفق بود.';
|
2026-05-23 18:13:25 +03:30
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false;
|
|
|
|
|
|
}
|
2026-05-24 15:58:52 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-12 20:16:14 +03:30
|
|
|
|
onMounted(async () => {
|
2026-05-23 18:13:25 +03:30
|
|
|
|
try {
|
2026-06-12 20:16:14 +03:30
|
|
|
|
categories.value = await fetchBusinessCategories();
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
error.value = 'بارگذاری دستهبندیها ناموفق بود.';
|
2026-05-23 18:13:25 +03:30
|
|
|
|
}
|
2026-06-12 20:16:14 +03:30
|
|
|
|
});
|
2026-05-23 18:13:25 +03:30
|
|
|
|
</script>
|