From 43574068a3bf1c02c308b3b6d1c66872442a187e Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 25 Feb 2026 10:06:07 -0300 Subject: [PATCH 1/3] fix: Adiciona indicador individual de campo incompleto no resumo --- src/components/CitizenSummaryViewer.vue | 13 ++- .../InternalComponents/SummarySection.vue | 24 ++++-- src/models/Address.ts | 10 +++ src/models/Citizen.ts | 84 +++++++++++++++---- src/types.ts | 1 + 5 files changed, 109 insertions(+), 23 deletions(-) diff --git a/src/components/CitizenSummaryViewer.vue b/src/components/CitizenSummaryViewer.vue index 6fbb762..73a5e2c 100644 --- a/src/components/CitizenSummaryViewer.vue +++ b/src/components/CitizenSummaryViewer.vue @@ -98,12 +98,12 @@ @@ -142,6 +142,15 @@ const emits = defineEmits(['create', 'edit', 'close']); const internalCitizen = ref(); const emptyStateImage = emptyState; const hasMissingFields = ref(false); +const requiredFields = [ + 'cpf', + 'cns', + 'address', + 'gender', + 'race', + 'mother_name', + 'birth_date', +]; onMounted(() => { checkMissingRequiredFields(props.citizen); diff --git a/src/components/InternalComponents/SummarySection.vue b/src/components/InternalComponents/SummarySection.vue index 0901999..3b1883f 100644 --- a/src/components/InternalComponents/SummarySection.vue +++ b/src/components/InternalComponents/SummarySection.vue @@ -20,13 +20,22 @@ :key="item.label" :col-span="item.fill ? 3 : 1" > - - {{ item.label }} - + + + {{ item.label }} + + + , fill?: boolean, + incomplete?: boolean, }>, }>() diff --git a/src/models/Address.ts b/src/models/Address.ts index 1a6e585..f644c81 100644 --- a/src/models/Address.ts +++ b/src/models/Address.ts @@ -132,6 +132,16 @@ export class Address { ${resolveFancyField(this.city?.value)} - ${resolveFancyField(this.uf?.shortName)}`; } + get isIncomplete(): boolean { + return ( + !this.street || + !this.number || + !this.neighborhood || + !this.city || + !this.uf + ); + } + get asFormData() { return { street: this.street, diff --git a/src/models/Citizen.ts b/src/models/Citizen.ts index 485c71d..bccd0fa 100644 --- a/src/models/Citizen.ts +++ b/src/models/Citizen.ts @@ -136,27 +136,83 @@ export class Citizen { return this._gender; } - getPersonalInfo(fieldsToHide?: string[]): { label: string; value: string; fill?: boolean, field?: string }[] { + getPersonalInfo(fieldsToHide?: string[], requiredFields: string[] = []): { label: string; value: string; fill?: boolean, field?: string }[] { const fields = [ - { label: 'CPF', value: this.cpf ? maskCpf(this.cpf) : 'Não informado', field: 'cpf' }, - { label: 'CNS', value: this.cns ? maskCns(this.cns) : 'Não informado', field: 'cns' }, - { label: 'RG', value: this.identification_document || 'Não informado', field: 'identification_document' }, - { label: 'Data de nascimento', value: this.birth_date - ? DateTime.fromISO(this.birth_date).toFormat('dd/MM/yyyy') - : 'Não informada', field: 'birth_date' }, - { label: 'Sexo', value: this._gender ? this._gender.name : 'Não informado', field: 'gender' }, - { label: 'Raça/Cor', value: this.race?.name || 'Não informado', field: 'race' }, + { + label: 'CPF', + value: this.cpf ? maskCpf(this.cpf) : 'Não informado', + field: 'cpf', + incomplete: !this.cpf && requiredFields?.includes('cpf') + }, + { + label: 'CNS', + value: this.cns ? maskCns(this.cns) : 'Não informado', + field: 'cns', + incomplete: !this.cns && requiredFields?.includes('cns') + }, + { + label: 'RG', + value: this.identification_document || 'Não informado', + field: 'identification_document', + incomplete: !this.identification_document && requiredFields?.includes('identification_document') + }, + { + label: 'Data de nascimento', + value: this.birth_date ? DateTime.fromISO(this.birth_date).toFormat('dd/MM/yyyy') : 'Não informada', + field: 'birth_date', + incomplete: !this.birth_date && requiredFields?.includes('birth_date') + }, + { + label: 'Sexo', + value: this._gender ? this._gender.name : 'Não informado', + field: 'gender', + incomplete: !this._gender && requiredFields?.includes('gender') + }, + { + label: 'Raça/Cor', + value: this.race?.name || 'Não informado', + field: 'race', + incomplete: !this.race && requiredFields?.includes('race') + }, + { + label: 'Nome da mãe', + value: this.mother_name || 'Não informado', + fill: true, + field: 'mother_name', + incomplete: !this.mother_name && requiredFields?.includes('mother_name') + }, ]; return fields.filter(({ field }) => !fieldsToHide?.includes(field)); } - getContactInfo(fieldsToHide?: string[]): { label: string; value: Nullable; fill?: boolean, field?: string }[] { + getContactInfo(fieldsToHide?: string[], requiredFields: string[] = []): { label: string; value: Nullable; fill?: boolean, field?: string }[] { const fields = [ - { label: 'Telefone', value: this.phone ? maskPhone(this.phone) : 'Não informado', field: 'phone' }, - { label: 'Celular', value: this.cellphone ? maskPhone(this.cellphone) : 'Não informado', field: 'cellphone' }, - { label: 'E-mail', value: this.email || 'Não informado', field: 'email' }, - { label: 'Endereço', value: this.fancyAddress, fill: true, field: 'address' }, + { + label: 'Telefone', + value: this.phone ? maskPhone(this.phone) : 'Não informado', + field: 'phone', + incomplete: !this.phone && requiredFields?.includes('phone') + }, + { + label: 'Celular', + value: this.cellphone ? maskPhone(this.cellphone) : 'Não informado', + field: 'cellphone', + incomplete: !this.cellphone && requiredFields?.includes('cellphone') + }, + { + label: 'E-mail', + value: this.email || 'Não informado', + field: 'email', + incomplete: !this.email && requiredFields?.includes('email') + }, + { + label: 'Endereço', + value: this.fancyAddress, + fill: true, + field: 'address', + incomplete: this.address?.isIncomplete && requiredFields?.includes('address') + }, ]; return fields.filter(({ field }) => !fieldsToHide?.includes(field)); diff --git a/src/types.ts b/src/types.ts index 51ce0b4..54f5aec 100644 --- a/src/types.ts +++ b/src/types.ts @@ -73,6 +73,7 @@ export interface Address { shortName: string; id: string; }; + isIncomplete: boolean; asFormData?: any; asRequestPayload?: any; fancyAddress: string; From 3ac36dfd3926e327c7756baed681407fc7d70a88 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 25 Feb 2026 10:06:14 -0300 Subject: [PATCH 2/3] fix: Atualiza snapshot --- src/components/__snapshots__/CitizenSummaryViewer.test.ts.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/__snapshots__/CitizenSummaryViewer.test.ts.snap b/src/components/__snapshots__/CitizenSummaryViewer.test.ts.snap index f49d480..d1fa036 100644 --- a/src/components/__snapshots__/CitizenSummaryViewer.test.ts.snap +++ b/src/components/__snapshots__/CitizenSummaryViewer.test.ts.snap @@ -17,7 +17,7 @@ exports[`CitizenSummaryViewer > is rendered correctly 1`] = ` - + From 31f3e58dd7497f14a9fdbd89ad644cf0026361a5 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 25 Feb 2026 10:06:22 -0300 Subject: [PATCH 3/3] fix: Ajusta testes --- src/models/Citizen.test.ts | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/models/Citizen.test.ts b/src/models/Citizen.test.ts index 57ba69b..a05c724 100644 --- a/src/models/Citizen.test.ts +++ b/src/models/Citizen.test.ts @@ -36,32 +36,33 @@ describe('Citizen model', () => { const fancyGender = genderFromType(citizenFixture.gender as string).name; const fancyRace = raceByValue(citizenFixture.race).name; - const fieldsToHide = ['race']; + const fieldsToHide = ['race', 'mother_name']; expect(citizen.getPersonalInfo()).toEqual([ - { label: 'CPF', value: maskCpf(citizenFixture.cpf), field: 'cpf' }, - { label: 'CNS', value: maskCns(citizenFixture.cns), field: 'cns' }, - { label: 'RG', value: 'Não informado', field: 'identification_document' }, - { label: 'Data de nascimento', value: DateTime.fromISO(citizenFixture.birth_date).toFormat('dd/MM/yyyy'), field: 'birth_date' }, - { label: 'Sexo', value: fancyGender, field: 'gender' }, - { label: 'Raça/Cor', value: fancyRace, field: 'race' }, + { label: 'CPF', value: maskCpf(citizenFixture.cpf), field: 'cpf', incomplete: false }, + { label: 'CNS', value: maskCns(citizenFixture.cns), field: 'cns', incomplete: false }, + { label: 'RG', value: 'Não informado', field: 'identification_document', incomplete: false }, + { label: 'Data de nascimento', value: DateTime.fromISO(citizenFixture.birth_date).toFormat('dd/MM/yyyy'), field: 'birth_date', incomplete: false }, + { label: 'Sexo', value: fancyGender, field: 'gender', incomplete: false }, + { label: 'Raça/Cor', value: fancyRace, field: 'race', incomplete: false }, + { label: 'Nome da mãe', value: citizenFixture.mother_name, field: 'mother_name', fill: true, incomplete: false }, ]); expect(citizen.getPersonalInfo(fieldsToHide)).toEqual([ - { label: 'CPF', value: maskCpf(citizenFixture.cpf), field: 'cpf' }, - { label: 'CNS', value: maskCns(citizenFixture.cns), field: 'cns' }, - { label: 'RG', value: 'Não informado', field: 'identification_document' }, - { label: 'Data de nascimento', value: DateTime.fromISO(citizenFixture.birth_date).toFormat('dd/MM/yyyy'), field: 'birth_date' }, - { label: 'Sexo', value: fancyGender, field: 'gender' }, + { label: 'CPF', value: maskCpf(citizenFixture.cpf), field: 'cpf', incomplete: false }, + { label: 'CNS', value: maskCns(citizenFixture.cns), field: 'cns', incomplete: false }, + { label: 'RG', value: 'Não informado', field: 'identification_document', incomplete: false }, + { label: 'Data de nascimento', value: DateTime.fromISO(citizenFixture.birth_date).toFormat('dd/MM/yyyy'), field: 'birth_date', incomplete: false }, + { label: 'Sexo', value: fancyGender, field: 'gender', incomplete: false }, ]); }); test('contactInfo is resolved correctly', () => { expect(citizen.getContactInfo()).toEqual([ - { label: 'Telefone', value: 'Não informado', field: 'phone' }, - { label: 'Celular', value: maskPhone(citizenFixture.cellphone), field: 'cellphone' }, - { label: 'E-mail', value: 'Não informado', field: 'email' }, - { label: 'Endereço', value: citizen.fancyAddress, fill: true, field: 'address' }, + { label: 'Telefone', value: 'Não informado', field: 'phone', incomplete: false }, + { label: 'Celular', value: maskPhone(citizenFixture.cellphone), field: 'cellphone', incomplete: false }, + { label: 'E-mail', value: 'Não informado', field: 'email', incomplete: false }, + { label: 'Endereço', value: citizen.fancyAddress, fill: true, field: 'address', incomplete: false }, ]); });