Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/CitizenSummaryViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ function checkMissingRequiredFields(value: Partial<Citizen> | null) {
uf: citizen['uf'],
};

const missingCpfAndCnsFields = ['cpf', 'cns'].some(
field => isEmptyValue(citizen[field]) && !props.hiddenFields.includes(field)
);
const missingCpfField = isEmptyValue(citizen['cpf']) && !props.hiddenFields.includes('cpf');
const missingCnsField = isEmptyValue(citizen['cns']) && !props.hiddenFields.includes('cns');
const missingCpfAndCnsFields = missingCpfField && missingCnsField;

const missingCitizenFields = ['name', 'birth_date', 'mother_name', 'race'].some(
field => isEmptyValue(citizen[field]) && !props.hiddenFields.includes(field)
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditCitizenSidesheet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async function updateCitizen(formData: UpdateCitizenParams) {
return;
}

citizenService.update(formData)
citizenService.update(formData, props.citizen)
.then((citizen) => {
emits('success', citizen);
// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion src/components/InternalComponents/CitizenForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ async function handleCitySelect(cityName: string) {
async function handleNeighborhoodSelect(neighborhood: { id: string, value: string }) {
isLoadingStreets.value = true;
const neighborhoodCityUfObject = {
neighborhood_name: neighborhood.value.toLowerCase(),
neighborhood_name: neighborhood.value,
city: formRef.value?.values.city.value,
uf: formRef.value?.values.uf.shortName,
}
Expand Down
9 changes: 8 additions & 1 deletion src/models/Citizen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ export class Citizen {
this.issuing_agency = args.issuing_agency;

if (!args.address) {
this.address = new AddressModel({});
this.address = {
city: args.city,
uf: args.uf,
street: args.street,
neighborhood: args.neighborhood,
number: args.number,
complement: args.complement,
};
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/services/citizen/citizen.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class CitizenService {
}
}

async update(data: UpdateCitizenParams): Promise<CreateCitizenResponse> {
async update(data: UpdateCitizenParams, document?: string): Promise<CreateCitizenResponse> {
if (!isCustomEndpointSet('update')) {
await this.delay(1000);
return this.citizenUpdateMock(data);
Expand All @@ -87,7 +87,7 @@ export class CitizenService {
const response = await this.apiCall('update', {
data,
method: 'put',
id: resolvedDocument,
id: document ?? resolvedDocument,
});

return response;
Expand Down