ajustes
This commit is contained in:
@@ -8,28 +8,24 @@ const refreshToken = useCookie<string | null>('refresh_token', { maxAge: 60 * 60
|
||||
|
||||
const documentType = ref<'pf' | 'pj'>('pj')
|
||||
const form = reactive({
|
||||
companyName: '',
|
||||
legalName: '',
|
||||
document: '',
|
||||
slug: '',
|
||||
adminName: '',
|
||||
adminEmail: '',
|
||||
adminPassword: '',
|
||||
})
|
||||
|
||||
const documentLabel = computed(() => documentType.value === 'pj' ? 'CNPJ' : 'CPF')
|
||||
const documentPlaceholder = computed(() => documentType.value === 'pj' ? '00.000.000/0001-00' : '000.000.000-00')
|
||||
const nameLabel = computed(() => documentType.value === 'pj' ? 'Razão Social' : 'Nome Completo')
|
||||
const isPJ = computed(() => documentType.value === 'pj')
|
||||
const documentLabel = computed(() => isPJ.value ? 'CNPJ' : 'CPF')
|
||||
const documentPlaceholder = computed(() => isPJ.value ? '00.000.000/0001-00' : '000.000.000-00')
|
||||
|
||||
// Auto-gera slug a partir do nome fantasia
|
||||
watch(() => form.companyName, (val) => {
|
||||
form.slug = val.toLowerCase()
|
||||
function toSlug(val: string) {
|
||||
return val.toLowerCase()
|
||||
.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
|
||||
.replace(/[^a-z0-9\s-]/g, '')
|
||||
.trim()
|
||||
.replace(/\s+/g, '-')
|
||||
.slice(0, 50)
|
||||
})
|
||||
}
|
||||
|
||||
const error = ref('')
|
||||
const loading = ref(false)
|
||||
@@ -41,12 +37,12 @@ async function handleSubmit() {
|
||||
const res = await $fetch<{ access_token: string; refresh_token: string }>(`${apiBase}/auth/register`, {
|
||||
method: 'POST',
|
||||
body: {
|
||||
company_name: form.companyName,
|
||||
company_name: form.legalName,
|
||||
legal_name: form.legalName,
|
||||
document_type: documentType.value,
|
||||
document: form.document,
|
||||
slug: form.slug,
|
||||
admin_name: form.adminName,
|
||||
slug: toSlug(form.legalName),
|
||||
admin_name: form.legalName,
|
||||
admin_email: form.adminEmail,
|
||||
admin_password: form.adminPassword,
|
||||
},
|
||||
@@ -88,33 +84,14 @@ async function handleSubmit() {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="section-label">Dados da Empresa</div>
|
||||
|
||||
<UFormField label="Nome Fantasia / Apelido" class="field">
|
||||
<UInput v-model="form.companyName" placeholder="Ex: Tech Gov" class="w-full" required />
|
||||
</UFormField>
|
||||
|
||||
<UFormField :label="nameLabel" class="field">
|
||||
<UInput v-model="form.legalName" :placeholder="documentType === 'pj' ? 'Razão Social completa' : 'Nome completo'" class="w-full" required />
|
||||
<UFormField :label="isPJ ? 'Razão Social' : 'Nome Completo'" class="field">
|
||||
<UInput v-model="form.legalName" :placeholder="isPJ ? 'Razão Social completa' : 'Nome completo'" class="w-full" required />
|
||||
</UFormField>
|
||||
|
||||
<UFormField :label="documentLabel" class="field">
|
||||
<UInput v-model="form.document" :placeholder="documentPlaceholder" class="w-full" required />
|
||||
</UFormField>
|
||||
|
||||
<UFormField label="Identificador único (slug)" class="field">
|
||||
<UInput v-model="form.slug" placeholder="minha-empresa" class="w-full" required />
|
||||
<template #hint>
|
||||
<span class="slug-hint">Usado para fazer login. Ex: <strong>{{ form.slug || 'minha-empresa' }}</strong></span>
|
||||
</template>
|
||||
</UFormField>
|
||||
|
||||
<div class="section-label">Dados de Acesso</div>
|
||||
|
||||
<UFormField label="Seu nome" class="field">
|
||||
<UInput v-model="form.adminName" placeholder="Nome do responsável" class="w-full" required />
|
||||
</UFormField>
|
||||
|
||||
<UFormField label="E-mail" class="field">
|
||||
<UInput v-model="form.adminEmail" type="email" placeholder="voce@empresa.com.br" class="w-full" required />
|
||||
</UFormField>
|
||||
|
||||
Reference in New Issue
Block a user