Skip to content

Commit

Permalink
Merge pull request aws-geospatial#209 from aws-geospatial/enhancement…
Browse files Browse the repository at this point in the history
…_ALS-1791_automatic-unit-system

[Enhancement] [ALS-1791] Automatic unit system
  • Loading branch information
wadhawh authored Jul 23, 2024
2 parents 059f210 + d3db542 commit aa53997
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ Cypress.Commands.add("connectAwsAccount", isResponsive => {
cy.get('[placeholder="Enter WebSocketUrl"]').type(`${Cypress.env("WEB_SOCKET_URL")}`);
cy.get('[data-testid="connect-button"]').click();
cy.get('[data-testid="connect-aws-account-modal-container"]').should("contain", "Your AWS account is now connected.");
cy.get('[data-testid="sign-in-button"]').click();
isResponsive
? cy.get('[data-testid="sign-in-button"]').first().click()
: cy.get('[data-testid="sign-in-button"]').click();
cy.wait(5000);
cy.origin(`${Cypress.env("USER_DOMAIN")}`, { args: { isResponsive } }, ({ isResponsive }) => {
isResponsive
Expand Down
5 changes: 3 additions & 2 deletions cypress/support/trackerAndGeofenceSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Cypress.Commands.add("addTrackerAndGeofenceEnterExit", (isResponsive, geofenceNa
cy.get("div").should("contain", `${geofenceName}`);
if (isResponsive) {
cy.get('[data-testid="bottomsheet-header-close-icon"]').click();
cy.openResponsiveMenu('[data-testid="bottomsheet"]');
} else {
cy.get('[data-testid="auth-geofence-box-close-button"]').click();
cy.get('[data-testid="hamburger-menu"]').click();
Expand All @@ -50,7 +49,9 @@ Cypress.Commands.add("addTrackerAndGeofenceEnterExit", (isResponsive, geofenceNa
cy.wait(5000);
cy.get('[class="mapboxgl-canvas"]').click("left", { force: true });
cy.wait(5000);
cy.get('[class="mapboxgl-canvas"]').click("right", { force: true });
isResponsive
? cy.get('[class="mapboxgl-canvas"]').click(200, 200, { force: true })
: cy.get('[class="mapboxgl-canvas"]').click("right", { force: true });
cy.wait(5000);
cy.get('[class="mapboxgl-canvas"]').click("right", { force: true });
cy.wait(5000);
Expand Down
8 changes: 5 additions & 3 deletions src/hooks/useAmplifyMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from "@demo/types";

import { OpenDataMapEnum } from "@demo/types/Enums";
import { getCountryCode } from "@demo/utils/countryUtil";
import { errorHandler } from "@demo/utils/errorHandler";
import { useTranslation } from "react-i18next";

Expand Down Expand Up @@ -59,9 +60,10 @@ const useAmplifyMap = () => {
setIsAutomaticMapUnit: (selected: boolean) => {
setState(s => ({ autoMapUnit: { ...s.autoMapUnit, selected } }));
},
setAutomaticMapUnit: () => {
const isMetric = !IMPERIAL_COUNTRIES.includes(navigator.language.split("-")[1]);
const mapUnit = isMetric ? METRIC : IMPERIAL;
setAutomaticMapUnit: async () => {
const countryCode = await getCountryCode();
const isImperial = !!countryCode && IMPERIAL_COUNTRIES.includes(countryCode);
const mapUnit = isImperial ? IMPERIAL : METRIC;
setState(s => ({ autoMapUnit: { ...s.autoMapUnit, system: mapUnit }, mapUnit }));
},
setMapUnit: (mapUnit: MapUnitEnum) => {
Expand Down

0 comments on commit aa53997

Please sign in to comment.