feat: tela de cadastro /register e configurações com perfil completo
- register.vue: cadastro PF/PJ com nome fantasia, razão social, CPF/CNPJ, slug - auto-gera slug a partir do nome fantasia - toggle PF/PJ muda label dos campos dinamicamente - configuracoes.vue: exibe e edita todos os campos do perfil do tenant - auth.global.ts: /register liberado sem autenticação - login.vue: link para /register + remove erro duplicado Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,9 @@ interface ApiTenant {
|
||||
ID: string
|
||||
Slug: string
|
||||
Name: string
|
||||
LegalName: string
|
||||
DocumentType: string
|
||||
Document: string
|
||||
Plan: string
|
||||
MaxUsers: number
|
||||
IsActive: boolean
|
||||
@@ -15,19 +18,35 @@ const { data: tenant, refresh } = await useAsyncData('tenant-me', () =>
|
||||
apiFetch<ApiTenant>('/tenant/me')
|
||||
)
|
||||
|
||||
const nome = ref(tenant.value?.Name ?? '')
|
||||
const form = reactive({
|
||||
name: tenant.value?.Name ?? '',
|
||||
legalName: tenant.value?.LegalName ?? '',
|
||||
documentType: tenant.value?.DocumentType ?? 'pj',
|
||||
document: tenant.value?.Document ?? '',
|
||||
})
|
||||
|
||||
const saving = ref(false)
|
||||
const saved = ref(false)
|
||||
|
||||
async function salvar() {
|
||||
saving.value = true
|
||||
saved.value = false
|
||||
await apiFetch('/tenant/me', { method: 'PUT', body: { name: nome.value } })
|
||||
await apiFetch('/tenant/me', {
|
||||
method: 'PUT',
|
||||
body: {
|
||||
name: form.name,
|
||||
legal_name: form.legalName,
|
||||
document_type: form.documentType,
|
||||
document: form.document,
|
||||
},
|
||||
})
|
||||
await refresh()
|
||||
saving.value = false
|
||||
saved.value = true
|
||||
setTimeout(() => { saved.value = false }, 3000)
|
||||
}
|
||||
|
||||
const documentLabel = computed(() => form.documentType === 'pj' ? 'CNPJ' : 'CPF')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -36,8 +55,24 @@ async function salvar() {
|
||||
<div class="content">
|
||||
<div class="card pad">
|
||||
<h2 class="section-title">Dados da Empresa</h2>
|
||||
<UFormField label="Nome da Empresa" class="field">
|
||||
<UInput v-model="nome" />
|
||||
|
||||
<div class="type-toggle">
|
||||
<button type="button" :class="['type-btn', form.documentType === 'pj' && 'active']" @click="form.documentType = 'pj'">
|
||||
Pessoa Jurídica
|
||||
</button>
|
||||
<button type="button" :class="['type-btn', form.documentType === 'pf' && 'active']" @click="form.documentType = 'pf'">
|
||||
Pessoa Física
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<UFormField label="Nome Fantasia / Apelido" class="field">
|
||||
<UInput v-model="form.name" />
|
||||
</UFormField>
|
||||
<UFormField :label="form.documentType === 'pj' ? 'Razão Social' : 'Nome Completo'" class="field">
|
||||
<UInput v-model="form.legalName" />
|
||||
</UFormField>
|
||||
<UFormField :label="documentLabel" class="field">
|
||||
<UInput v-model="form.document" />
|
||||
</UFormField>
|
||||
<UFormField label="Slug" class="field">
|
||||
<UInput :model-value="tenant?.Slug ?? ''" disabled />
|
||||
@@ -45,6 +80,7 @@ async function salvar() {
|
||||
<UFormField label="Plano Atual" class="field">
|
||||
<UInput :model-value="tenant?.Plan ?? ''" disabled />
|
||||
</UFormField>
|
||||
|
||||
<div class="actions">
|
||||
<UButton class="btn-primary" size="sm" :loading="saving" @click="salvar">Salvar Alterações</UButton>
|
||||
<span v-if="saved" class="saved-msg">Salvo!</span>
|
||||
@@ -59,9 +95,16 @@ async function salvar() {
|
||||
.content { padding: 20px 22px; flex: 1; overflow-y: auto; }
|
||||
.card { background: white; border-radius: 11px; border: 1px solid #e2e8f0; }
|
||||
.pad { padding: 24px; }
|
||||
.section-title { font-size: 15px; font-weight: 700; color: #0f172a; margin-bottom: 20px; }
|
||||
.field { margin-bottom: 16px; }
|
||||
.actions { display: flex; align-items: center; gap: 12px; }
|
||||
.section-title { font-size: 15px; font-weight: 700; color: #0f172a; margin-bottom: 16px; }
|
||||
.type-toggle { display: flex; gap: 8px; margin-bottom: 18px; }
|
||||
.type-btn {
|
||||
flex: 1; padding: 7px; border-radius: 8px; border: 1.5px solid #e2e8f0;
|
||||
font-size: 13px; font-weight: 500; color: #64748b; cursor: pointer; background: white;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
.type-btn.active { border-color: #667eea; color: #667eea; background: #f0f3ff; }
|
||||
.field { margin-bottom: 14px; }
|
||||
.actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
|
||||
.btn-primary { background: linear-gradient(135deg, #667eea, #764ba2) !important; }
|
||||
.saved-msg { font-size: 13px; color: #10b981; font-weight: 500; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user