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 });
|
let cursoAtual = $state({ descricao: "", data: "", arquivo: null as File | null });
|
||||||
|
|
||||||
// Dependentes
|
// 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 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: "",
|
parentesco: "",
|
||||||
nome: "",
|
nome: "",
|
||||||
cpf: "",
|
cpf: "",
|
||||||
nascimento: "",
|
nascimento: "",
|
||||||
arquivo: null,
|
arquivo: null,
|
||||||
documentoId: undefined,
|
documentoId: undefined,
|
||||||
|
salarioFamilia: false,
|
||||||
|
impostoRenda: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
function adicionarCurso() {
|
function adicionarCurso() {
|
||||||
@@ -176,8 +178,10 @@
|
|||||||
cpf: onlyDigits(dependenteAtual.cpf),
|
cpf: onlyDigits(dependenteAtual.cpf),
|
||||||
nascimento: dependenteAtual.nascimento,
|
nascimento: dependenteAtual.nascimento,
|
||||||
documentoId: dependenteAtual.documentoId,
|
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) {
|
function removerDependente(id: string) {
|
||||||
@@ -330,6 +334,8 @@
|
|||||||
cpf: d.cpf,
|
cpf: d.cpf,
|
||||||
nascimento: d.nascimento,
|
nascimento: d.nascimento,
|
||||||
documentoId: d.documentoId as any,
|
documentoId: d.documentoId as any,
|
||||||
|
salarioFamilia: !!d.salarioFamilia,
|
||||||
|
impostoRenda: !!d.impostoRenda,
|
||||||
}))
|
}))
|
||||||
: undefined,
|
: undefined,
|
||||||
};
|
};
|
||||||
@@ -1143,6 +1149,16 @@
|
|||||||
<div class="flex-1 text-sm">
|
<div class="flex-1 text-sm">
|
||||||
<p class="font-semibold">{dep.nome} — {dep.parentesco}</p>
|
<p class="font-semibold">{dep.nome} — {dep.parentesco}</p>
|
||||||
<p class="text-xs text-base-content/70">CPF: {dep.cpf} • Nasc.: {dep.nascimento}</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>
|
</div>
|
||||||
<button type="button" class="btn btn-sm btn-error btn-square" aria-label="Remover dependente" onclick={() => removerDependente(dep.id)}>
|
<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>
|
<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"); } } }} />
|
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>
|
</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">
|
<div class="lg:col-span-3">
|
||||||
<button type="button" class="btn btn-primary btn-sm gap-2" onclick={adicionarDependente}>
|
<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>
|
<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(),
|
cpf: v.string(),
|
||||||
nascimento: v.string(),
|
nascimento: v.string(),
|
||||||
documentoId: v.optional(v.id("_storage")),
|
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(),
|
cpf: v.string(),
|
||||||
nascimento: v.string(),
|
nascimento: v.string(),
|
||||||
documentoId: v.optional(v.id("_storage")),
|
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(),
|
cpf: v.string(),
|
||||||
nascimento: v.string(),
|
nascimento: v.string(),
|
||||||
documentoId: v.optional(v.id("_storage")),
|
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