Skip to content

Commit

Permalink
Merge pull request #345 from labzero/develop
Browse files Browse the repository at this point in the history
Merge to master
  • Loading branch information
JeffreyATW authored Nov 12, 2023
2 parents 03d2050 + f00cc43 commit 482b6bd
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 77 deletions.
6 changes: 0 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ jobs:
environment:
MOCHA_FILE: junit/unit-test-results.xml

# set up for integration tests
# set up the database
- run:
name: database-setup
command: NODE_ENV=test npm run integration-setup

- run:
name: setup /etc/hosts
command: |
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@reduxjs/toolkit": "^1.9.2",
"@sendgrid/helpers": "^7.7.0",
"@sendgrid/mail": "^7.7.0",
"@ubilabs/react-geosuggest": "^2.16.1",
"bcrypt": "^5.1.0",
"body-parser": "^1.18.3",
"bootstrap": "^5.2.3",
Expand Down Expand Up @@ -59,7 +60,6 @@
"react-bootstrap": "^2.7.0",
"react-dom": "npm:@preact/compat@*",
"react-flip-toolkit": "^7.0.17",
"react-geosuggest": "^2.14.1",
"react-icons": "^4.7.1",
"react-redux": "^8.0.5",
"react-scroll": "^1.8.9",
Expand Down Expand Up @@ -148,7 +148,7 @@
"null-loader": "^4.0.1",
"nyc": "^15.1.0",
"open-cli": "^7.1.0",
"postcss": "^8.4.21",
"postcss": "^8.4.31",
"postcss-loader": "^7.0.2",
"prettier": "2.8.8",
"proxyquire": "^1.7.11",
Expand Down
21 changes: 10 additions & 11 deletions src/components/RestaurantAddForm/RestaurantAddForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable max-classes-per-file */

import React, { Component, RefObject, Suspense, createRef, lazy } from "react";
import GeosuggestClass, { GeosuggestProps, Suggest } from "react-geosuggest";
import GeosuggestClass, { Location, Suggest } from "@ubilabs/react-geosuggest";
import withStyles from "isomorphic-style-loader/withStyles";
import canUseDOM from "../../helpers/canUseDOM";
import { LatLng } from "../../interfaces";
Expand All @@ -11,17 +11,16 @@ import GoogleMapsLoaderContext, {
import s from "./RestaurantAddForm.scss";

const Geosuggest = lazy(
() => import(/* webpackChunkName: 'geosuggest' */ "react-geosuggest")
() => import(/* webpackChunkName: 'geosuggest' */ "@ubilabs/react-geosuggest")
);

interface RestaurantAddFormProps
extends Pick<GeosuggestProps, "getSuggestLabel"> {
interface RestaurantAddFormProps {
createTempMarker: (result: google.maps.GeocoderResult) => void;
clearTempMarker: () => void;
handleSuggestSelect: (
suggestion: Suggest,
geosuggest: GeosuggestClass
) => void;
getSuggestLabel: (
suggest: google.maps.places.AutocompletePrediction
) => string;
handleSuggestSelect: (suggestion?: Location) => void;
latLng: LatLng;
}

Expand Down Expand Up @@ -51,7 +50,7 @@ class RestaurantAddForm extends Component<RestaurantAddFormProps> {
}
}

getCoordsForMarker = (suggest: Suggest) => {
getCoordsForMarker = (suggest: Suggest | null) => {
if (suggest !== null) {
if (this.geocoder === undefined) {
this.geocoder = new this.maps.Geocoder();
Expand All @@ -64,8 +63,8 @@ class RestaurantAddForm extends Component<RestaurantAddFormProps> {
}
};

handleSuggestSelect = (suggestion: Suggest) => {
this.props.handleSuggestSelect(suggestion, this.geosuggest!.current!);
handleSuggestSelect = (suggestion?: Location) => {
this.props.handleSuggestSelect(suggestion);
this.geosuggest.current?.clear();
this.geosuggest.current?.focus();
};
Expand Down
12 changes: 4 additions & 8 deletions src/components/RestaurantAddForm/RestaurantAddFormContainer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Geosuggest, { Suggest } from "react-geosuggest";
import { Location, Suggest } from "@ubilabs/react-geosuggest";
import { connect } from "react-redux";
import { scroller } from "react-scroll";
import { Dispatch, State } from "../../interfaces";
Expand Down Expand Up @@ -47,10 +47,7 @@ const mergeProps = (
) => ({
...stateProps,
...dispatchProps,
handleSuggestSelect: (
suggestion: Suggest | undefined,
geosuggest: Geosuggest
) => {
handleSuggestSelect: (suggestion: Location | undefined) => {
if (suggestion) {
let name = suggestion.label;
let address = "";
Expand All @@ -60,18 +57,17 @@ const mergeProps = (
} = suggestion;
const isEstablishment =
suggestion.gmaps &&
suggestion.gmaps.types &&
suggestion.gmaps.types.indexOf("establishment") > -1;
if (suggestCache[placeId] !== undefined && isEstablishment) {
name = suggestCache[placeId];
} else if (!isEstablishment) {
name = name.split(",")[0];
}
if (suggestion.gmaps !== undefined) {
address = suggestion.gmaps.formatted_address;
address = suggestion.gmaps.formatted_address || "";
}
suggestCache = {};
geosuggest.update("");
geosuggest.showSuggests();
const existingRestaurant = stateProps.restaurants.find(
(r) => r.placeId === placeId
);
Expand Down
10 changes: 5 additions & 5 deletions src/components/TeamGeosuggest/TeamGeosuggest.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { Component, Suspense, lazy } from "react";
import { Suggest } from "react-geosuggest";
import { Suggest } from "@ubilabs/react-geosuggest";
import canUseDOM from "../../helpers/canUseDOM";
import { LatLng } from "../../interfaces";
import GoogleMapsLoaderContext, {
IGoogleMapsLoaderContext,
} from "../GoogleMapsLoaderContext/GoogleMapsLoaderContext";

const Geosuggest = lazy(
() => import(/* webpackChunkName: 'geosuggest' */ "react-geosuggest")
() => import(/* webpackChunkName: 'geosuggest' */ "@ubilabs/react-geosuggest")
);

export interface TeamGeosuggestProps {
Expand Down Expand Up @@ -40,7 +40,7 @@ class TeamGeosuggest extends Component<TeamGeosuggestProps> {
}
}

getCoordsForMarker = (suggest: Suggest) => {
getCoordsForMarker = (suggest: Suggest | null) => {
if (suggest !== null) {
if (this.geocoder === undefined) {
this.geocoder = new this.maps.Geocoder();
Expand All @@ -58,8 +58,8 @@ class TeamGeosuggest extends Component<TeamGeosuggestProps> {
}
};

handleSuggestSelect = (suggestion: Suggest) => {
if (suggestion) {
handleSuggestSelect = (suggestion?: Suggest) => {
if (suggestion?.location) {
this.props.setCenter(suggestion.location);
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/styles/globalCss.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* stylelint-disable selector-class-pattern */

@import "~react-geosuggest/module/geosuggest.css";
@import "~@ubilabs/react-geosuggest/module/geosuggest.css";
@import "./variables";
@import "~bootstrap/scss/functions";
@import "~bootstrap/scss/variables";
Expand All @@ -19,6 +19,7 @@
@import "~bootstrap/scss/nav";
@import "~bootstrap/scss/list-group";
@import "~bootstrap/scss/modal";
@import "~bootstrap/scss/popover";
@import "~bootstrap/scss/helpers/visually-hidden";
@import "~bootstrap/scss/utilities/api";

Expand Down
4 changes: 2 additions & 2 deletions typings/react-geosuggest.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "react-geosuggest";
import "@ubilabs/react-geosuggest";

declare module "react-geosuggest" {
declare module "@ubilabs/react-geosuggest" {
export interface Suggest {
description: string;
place_id: string;
Expand Down
Loading

0 comments on commit 482b6bd

Please sign in to comment.