Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAPA-529] fix(geolocation): returns "not_found" when city/state/zipcode is falsy #158

Merged
merged 2 commits into from
Aug 5, 2024
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 packages/components/src/lib/geolocation/geolocation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ describe("geolocation tests", () => {
latitude: null,
longitude: null,
address: `Endereço não encontrado - ${validOutput.address}`,
state: null,
city: "ZERO_RESULTS",
cep: null
state: "not_found",
city: "not_found",
cep: "not_found"
};

it("should return valid output if there are results", () => {
Expand Down
14 changes: 7 additions & 7 deletions packages/components/src/lib/geolocation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const log = logger.child({ module: "geolocation" });
const getCityStateAndZipcode = (
addressComponents: AddressComponent
): Array<string> => {
let state = "";
let city = "";
let zipcode = "";
let country = "";
let state = "not_found";
let city = "not_found";
let zipcode = "not_found";
let country = "BR";

addressComponents.forEach(({ types, short_name: shortName }) => {
if (types.includes("postal_code")) {
Expand Down Expand Up @@ -59,9 +59,9 @@ const geolocationUnkown = ({
latitude: null,
longitude: null,
address: `Endereço não encontrado - ${address || zipcode}`,
state: null,
city: "ZERO_RESULTS",
cep: zipcode || null
state: "not_found",
city: "not_found",
cep: zipcode || "not_found"
});

const parseZipcode = (zipcode: string): string => {
Expand Down
Loading