feat: add salary family and income tax options for dependents in employee registration
- Enhanced the employee registration form by adding checkboxes for "Salário Família" and "Imposto de Renda" for each dependent. - Updated the backend schema and mutations to include optional fields for salary family and income tax benefits. - Improved the handling of dependent data to accommodate the new fields, enhancing the overall functionality of the dependents management section.
This commit is contained in:
@@ -100,15 +100,17 @@
|
||||
let cursoAtual = $state({ descricao: "", data: "", arquivo: null as File | null });
|
||||
|
||||
// Dependentes
|
||||
let dependentes = $state<Array<{ id: string; parentesco: string; nome: string; cpf: string; nascimento: string; documentoId?: string }>>([]);
|
||||
let dependentes = $state<Array<{ id: string; parentesco: string; nome: string; cpf: string; nascimento: string; documentoId?: string; salarioFamilia?: boolean; impostoRenda?: boolean }>>([]);
|
||||
let mostrarFormularioDependente = $state(false);
|
||||
let dependenteAtual = $state<{ parentesco: string; nome: string; cpf: string; nascimento: string; arquivo: File | null; documentoId?: string }>({
|
||||
let dependenteAtual = $state<{ parentesco: string; nome: string; cpf: string; nascimento: string; arquivo: File | null; documentoId?: string; salarioFamilia?: boolean; impostoRenda?: boolean }>({
|
||||
parentesco: "",
|
||||
nome: "",
|
||||
cpf: "",
|
||||
nascimento: "",
|
||||
arquivo: null,
|
||||
documentoId: undefined,
|
||||
salarioFamilia: false,
|
||||
impostoRenda: false,
|
||||
});
|
||||
|
||||
function adicionarCurso() {
|
||||
@@ -176,8 +178,10 @@
|
||||
cpf: onlyDigits(dependenteAtual.cpf),
|
||||
nascimento: dependenteAtual.nascimento,
|
||||
documentoId: dependenteAtual.documentoId,
|
||||
salarioFamilia: !!dependenteAtual.salarioFamilia,
|
||||
impostoRenda: !!dependenteAtual.impostoRenda,
|
||||
});
|
||||
dependenteAtual = { parentesco: "", nome: "", cpf: "", nascimento: "", arquivo: null, documentoId: undefined };
|
||||
dependenteAtual = { parentesco: "", nome: "", cpf: "", nascimento: "", arquivo: null, documentoId: undefined, salarioFamilia: false, impostoRenda: false };
|
||||
}
|
||||
|
||||
function removerDependente(id: string) {
|
||||
@@ -330,6 +334,8 @@
|
||||
cpf: d.cpf,
|
||||
nascimento: d.nascimento,
|
||||
documentoId: d.documentoId as any,
|
||||
salarioFamilia: !!d.salarioFamilia,
|
||||
impostoRenda: !!d.impostoRenda,
|
||||
}))
|
||||
: undefined,
|
||||
};
|
||||
@@ -1143,6 +1149,16 @@
|
||||
<div class="flex-1 text-sm">
|
||||
<p class="font-semibold">{dep.nome} — {dep.parentesco}</p>
|
||||
<p class="text-xs text-base-content/70">CPF: {dep.cpf} • Nasc.: {dep.nascimento}</p>
|
||||
<div class="flex flex-wrap gap-4 mt-2">
|
||||
<label class="label cursor-pointer gap-2">
|
||||
<input type="checkbox" class="checkbox checkbox-xs checkbox-primary" bind:checked={dep.salarioFamilia} />
|
||||
<span class="label-text text-xs">Salário Família</span>
|
||||
</label>
|
||||
<label class="label cursor-pointer gap-2">
|
||||
<input type="checkbox" class="checkbox checkbox-xs checkbox-primary" bind:checked={dep.impostoRenda} />
|
||||
<span class="label-text text-xs">Imposto de Renda</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-sm btn-error btn-square" aria-label="Remover dependente" onclick={() => removerDependente(dep.id)}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg>
|
||||
@@ -1202,6 +1218,20 @@
|
||||
onchange={async (e) => { const file = e.currentTarget.files?.[0]; dependenteAtual.arquivo = file || null; if (file) { try { dependenteAtual.documentoId = await uploadDocumentoDependente(file); } catch { alert("Falha no upload do documento do dependente"); } } }} />
|
||||
</div>
|
||||
|
||||
<!-- Checkboxes de benefícios por dependente -->
|
||||
<div class="form-control">
|
||||
<label class="label cursor-pointer justify-start gap-3">
|
||||
<input type="checkbox" class="checkbox checkbox-primary" bind:checked={dependenteAtual.salarioFamilia} />
|
||||
<span class="label-text">Salário Família</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-control">
|
||||
<label class="label cursor-pointer justify-start gap-3">
|
||||
<input type="checkbox" class="checkbox checkbox-primary" bind:checked={dependenteAtual.impostoRenda} />
|
||||
<span class="label-text">Imposto de Renda</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="lg:col-span-3">
|
||||
<button type="button" class="btn btn-primary btn-sm gap-2" onclick={adicionarDependente}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" /></svg>
|
||||
|
||||
@@ -188,6 +188,8 @@ export const create = mutation({
|
||||
cpf: v.string(),
|
||||
nascimento: v.string(),
|
||||
documentoId: v.optional(v.id("_storage")),
|
||||
salarioFamilia: v.optional(v.boolean()),
|
||||
impostoRenda: v.optional(v.boolean()),
|
||||
})
|
||||
)
|
||||
),
|
||||
@@ -334,6 +336,8 @@ export const update = mutation({
|
||||
cpf: v.string(),
|
||||
nascimento: v.string(),
|
||||
documentoId: v.optional(v.id("_storage")),
|
||||
salarioFamilia: v.optional(v.boolean()),
|
||||
impostoRenda: v.optional(v.boolean()),
|
||||
})
|
||||
)
|
||||
),
|
||||
|
||||
@@ -148,6 +148,9 @@ export default defineSchema({
|
||||
cpf: v.string(),
|
||||
nascimento: v.string(),
|
||||
documentoId: v.optional(v.id("_storage")),
|
||||
// Benefícios/declarações por dependente
|
||||
salarioFamilia: v.optional(v.boolean()),
|
||||
impostoRenda: v.optional(v.boolean()),
|
||||
})
|
||||
)
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user