Initial commit: fabric-trade-user Vue 3 app with mobile and desktop layouts

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-03 09:57:24 +02:00
co-authored by Cursor
commit fd3e5e5126
142 changed files with 19798 additions and 0 deletions
+110
View File
@@ -0,0 +1,110 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
import BaseInput from '@/components/ui/BaseInput.vue'
import FormErrorBanner from '@/components/ui/FormErrorBanner.vue'
import BaseButton from '@/components/ui/BaseButton.vue'
import { normalizePhone } from '@/utils/format'
import {
FORM_VALIDATION_SUMMARY,
clearFieldError,
hasFieldErrors,
type FieldErrors,
} from '@/utils/formErrors'
const router = useRouter()
const auth = useAuthStore()
const phone = ref('')
const fieldErrors = ref<FieldErrors>({})
const formError = ref('')
function clearPhoneError() {
fieldErrors.value = clearFieldError(fieldErrors.value, 'phone')
if (!hasFieldErrors(fieldErrors.value)) formError.value = ''
}
async function submit() {
fieldErrors.value = {}
formError.value = ''
const normalized = normalizePhone(phone.value)
const errors: FieldErrors = {}
if (!/^09\d{9}$/.test(normalized)) {
errors.phone = 'شماره موبایل معتبر نیست.'
}
if (hasFieldErrors(errors)) {
fieldErrors.value = errors
formError.value = FORM_VALIDATION_SUMMARY
return
}
const result = await auth.requestOtp(normalized, { isRegister: false })
if (result.success) {
router.push({ name: 'otp', query: { phone: normalized, mode: 'login' } })
} else {
formError.value = result.message ?? 'خطا در ارسال کد تأیید.'
}
}
</script>
<template>
<div class="page auth-page">
<div class="page__scroll auth-page__scroll">
<div class="auth-header">
<div class="logo">🧵</div>
<h1 class="page-title">ورود به سامانه</h1>
<p class="page-subtitle">سامانه سفارش عمده پارچه</p>
</div>
<div class="card">
<FormErrorBanner :message="formError" />
<BaseInput
v-model="phone"
label="شماره موبایل"
type="tel"
placeholder="۰۹۱۲۳۴۵۶۷۸۹"
:error="fieldErrors.phone"
hint="کد تأیید به این شماره ارسال می‌شود"
@update:model-value="clearPhoneError"
/>
<BaseButton block :loading="auth.loading" @click="submit">دریافت کد تأیید</BaseButton>
</div>
<p class="auth-footer text-center text-sm">
حساب کاربری ندارید؟
<router-link to="/register">ثبت‌نام</router-link>
</p>
</div>
</div>
</template>
<style scoped>
.auth-page {
overflow: hidden;
}
.auth-page__scroll {
padding-top: 36px;
padding-bottom: 24px;
}
.auth-header {
text-align: center;
margin-bottom: 32px;
}
.logo {
font-size: 3rem;
margin-bottom: 12px;
}
.auth-footer {
margin-top: 24px;
color: var(--color-text-muted);
}
</style>