Skip to content

Commit

Permalink
Merge pull request #334 from labzero/develop
Browse files Browse the repository at this point in the history
Merge to master
  • Loading branch information
JeffreyATW authored Jun 29, 2023
2 parents 1f6baa3 + dc47d23 commit 4b6847a
Show file tree
Hide file tree
Showing 37 changed files with 200 additions and 166 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = {
jsx: "never",
mjs: "never",
ts: "never",
json: "always",
},
],

Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@
"passport-google-oauth20": "^2.0.0",
"passport-local": "^1.0.0",
"pg": "^8.9.0",
"preact": "^10.15.1",
"preact-render-to-string": "^6.1.0",
"preact-ssr-prepass": "^1.2.0",
"pretty-error": "^3.0.4",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react": "npm:@preact/compat@*",
"react-autosuggest": "^10.0.2",
"react-bootstrap": "^2.7.0",
"react-dom": "^18.2.0",
"react-dom": "npm:@preact/compat@*",
"react-flip-toolkit": "^7.0.17",
"react-geosuggest": "^2.14.1",
"react-icons": "^4.7.1",
Expand Down
8 changes: 3 additions & 5 deletions src/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* LICENSE.txt file in the root directory of this source tree.
*/

import { hydrate, render } from "preact";
import React, { useEffect } from "react";
import { createRoot, hydrateRoot } from "react-dom/client";
import { Action, createPath, Location } from "history";
import App from "./components/App";
import configureStore from "./store/configureStore";
Expand Down Expand Up @@ -91,8 +91,6 @@ if (subdomain) {

const router = routerCreator(routes);

const root = createRoot(container!);

// Re-render the app when window.location changes
const onLocationChange = async ({
action,
Expand Down Expand Up @@ -197,9 +195,9 @@ const onLocationChange = async ({
};

if (isInitialRender) {
hydrateRoot(container!, <AppWithCallbackAfterRender />);
hydrate(<AppWithCallbackAfterRender />, container!);
} else {
root.render(<AppWithCallbackAfterRender />);
render(<AppWithCallbackAfterRender />, container!);
}
} catch (error) {
if (__DEV__) {
Expand Down
6 changes: 3 additions & 3 deletions src/components/AddUserForm/AddUserForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ChangeEvent, Component, FormEvent } from "react";
import React, { ChangeEvent, Component, TargetedEvent } from "react";
import Button from "react-bootstrap/Button";
import Col from "react-bootstrap/Col";
import Form from "react-bootstrap/Form";
Expand Down Expand Up @@ -38,9 +38,9 @@ class AddUserForm extends Component<AddUserFormProps, AddUserFormState> {
HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement
>
) =>
this.setState({ [field]: event.target.value });
this.setState({ [field]: event.currentTarget.value });

handleSubmit = (event: FormEvent) => {
handleSubmit = (event: TargetedEvent) => {
event.preventDefault();
this.props.addUserToTeam(this.state);
this.setState({ ...AddUserForm.defaultState });
Expand Down
11 changes: 8 additions & 3 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

import StyleContext, { InsertCSS } from "isomorphic-style-loader/StyleContext";
import PropTypes from "prop-types";
import React, { Children, ReactNode } from "react";
import React from "react";
import { ComponentChildren } from "preact";
import { Provider as ReduxProvider } from "react-redux";
import { Libraries, Loader } from "@googlemaps/js-api-loader";
import { AppContext } from "../interfaces";
Expand All @@ -26,7 +27,7 @@ const ContextType = {
};

interface AppProps {
children: ReactNode;
children?: ComponentChildren;
context: AppContext;
}

Expand Down Expand Up @@ -63,6 +64,10 @@ class App extends React.PureComponent<AppProps> {

static childContextTypes = ContextType;

static defaultProps = {
children: null,
};

constructor(props: AppProps) {
super(props);

Expand All @@ -88,7 +93,7 @@ class App extends React.PureComponent<AppProps> {
<StyleContext.Provider value={this.styleContextValue}>
<ReduxProvider store={this.props.context.store}>
<GoogleMapsLoaderContext.Provider value={this.loaderContextValue}>
{Children.only(this.props.children)}
{this.props.children}
</GoogleMapsLoaderContext.Provider>
</ReduxProvider>
</StyleContext.Provider>
Expand Down
4 changes: 2 additions & 2 deletions src/components/ChangeTeamURLModal/ChangeTeamURLModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class ChangeTeamURLModal extends Component<

handleChange =
(field: keyof ChangeTeamURLModalState) =>
(event: ChangeEvent<HTMLInputElement>) =>
(event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) =>
this.setState({
[field]: event.target.value,
[field]: event.currentTarget.value,
});

handleSubmit = () => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/ConfirmModal/ConfirmModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { ReactNode } from "react";
import React from "react";
import { ComponentChildren } from "preact";
import Modal from "react-bootstrap/Modal";
import ModalBody from "react-bootstrap/ModalBody";
import ModalFooter from "react-bootstrap/ModalFooter";
Expand All @@ -8,7 +9,7 @@ export interface ConfirmModalProps {
actionLabel: string;
shown: boolean;
hideModal: () => void;
body: ReactNode;
body: ComponentChildren;
handleSubmit: () => void;
}

Expand Down
6 changes: 4 additions & 2 deletions src/components/DeleteTeamModal/DeleteTeamModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ class DeleteTeamModal extends Component<
};
}

handleChange = (event: ChangeEvent<HTMLInputElement>) => {
handleChange = (
event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
) => {
this.setState({
confirmSlug: event.target.value,
confirmSlug: event.currentTarget.value,
});
};

Expand Down
5 changes: 3 additions & 2 deletions src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
* LICENSE.txt file in the root directory of this source tree.
*/

import React, { Component, ReactNode } from "react";
import React, { Component } from "react";
import { VNode } from "preact";
import PropTypes from "prop-types";
import { InsertCSS } from "isomorphic-style-loader/StyleContext";
// eslint-disable-next-line css-modules/no-unused-class, no-unused-vars
Expand All @@ -22,7 +23,7 @@ import s from "./Layout.scss";
const emptyFunction = () => undefined;

export interface LayoutProps {
children: ReactNode;
children: VNode;
isHome?: boolean;
path: string;
shouldScrollToTop: boolean;
Expand Down
7 changes: 4 additions & 3 deletions src/components/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
* LICENSE.txt file in the root directory of this source tree.
*/

import React, { Component, MouseEvent, ReactNode } from "react";
import React, { Component, HTMLAttributes } from "react";
import { ComponentChildren } from "preact";
import history from "../../history";

function isLeftClickEvent(event: MouseEvent) {
Expand All @@ -18,9 +19,9 @@ function isModifiedEvent(event: MouseEvent) {
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
}

interface LinkProps extends React.HTMLProps<HTMLAnchorElement> {
interface LinkProps extends HTMLAttributes<HTMLAnchorElement> {
to: string;
children: ReactNode;
children: ComponentChildren;
onClick?: (event: MouseEvent) => void;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/NameFilterForm/NameFilterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class NameFilterForm extends Component<
};

setNameFilterValue = (event: ChangeEvent<HTMLInputElement>) => {
this.props.setNameFilter(event.target.value);
this.props.setNameFilter(event.currentTarget.value);
};

hideForm = () => {
Expand Down
1 change: 1 addition & 0 deletions src/components/NotificationList/NotificationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface NotificationListProps {

const NotificationList = ({ notifications }: NotificationListProps) => (
<ul className={s.notifications}>
{/* @ts-expect-error: expects component instead of children */}
<TransitionGroup>
{notifications.map((notification) => (
<CSSTransition
Expand Down
2 changes: 1 addition & 1 deletion src/components/PastDecisionsModal/PastDecisionsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PastDecisionsModal extends Component<

handleChange = (event: ChangeEvent<HTMLSelectElement>) =>
this.setState({
daysAgo: Number(event.target.value),
daysAgo: Number(event.currentTarget.value),
});

handleSubmit = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/RestaurantAddForm/RestaurantAddForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class RestaurantAddForm extends Component<RestaurantAddFormProps> {
return (
<form>
{this.maps ? (
<Suspense>
<Suspense fallback={null}>
<Geosuggest
autoActivateFirstSuggest
bounds={
Expand Down
8 changes: 4 additions & 4 deletions src/components/RestaurantAddTagForm/RestaurantAddTagForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component, FormEvent, RefObject, createRef } from "react";
import React, { Component, RefObject, TargetedEvent, createRef } from "react";
import Autosuggest, {
ChangeEvent,
SuggestionSelectedEventData,
Expand Down Expand Up @@ -54,7 +54,7 @@ export class _RestaurantAddTagForm extends Component<
}

setAddTagAutosuggestValue = (
event: FormEvent,
event: TargetedEvent,
{ newValue, method }: ChangeEvent
) => {
if (method === "up" || method === "down") {
Expand All @@ -65,7 +65,7 @@ export class _RestaurantAddTagForm extends Component<
}));
};

handleSubmit = (event: FormEvent) => {
handleSubmit = (event: TargetedEvent) => {
event.preventDefault();
this.props.addNewTagToRestaurant(this.state.autosuggestValue);
this.setState(() => ({
Expand All @@ -74,7 +74,7 @@ export class _RestaurantAddTagForm extends Component<
};

handleSuggestionSelected = (
event: FormEvent,
event: TargetedEvent,
{ suggestion, method }: SuggestionSelectedEventData<Tag>
) => {
if (method === "enter") {
Expand Down
9 changes: 5 additions & 4 deletions src/components/RestaurantMap/RestaurantMap.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable max-classes-per-file */

import PropTypes from "prop-types";
import React, { Component, ReactNode, Suspense, lazy } from "react";
import React, { Component, Suspense, lazy } from "react";
import { VNode } from "preact";
import withStyles from "isomorphic-style-loader/withStyles";
import { GOOGLE_MAP_ZOOM } from "../../constants";
import googleMapOptions from "../../helpers/googleMapOptions";
Expand Down Expand Up @@ -94,12 +95,12 @@ class RestaurantMap extends Component<RestaurantMapProps> {
tempMarker,
} = this.props;

let tempMarkerComponent: ReactNode;
let tempMarkerComponent: VNode;
if (tempMarker !== undefined) {
tempMarkerComponent = <TempMarker {...tempMarker.latLng} />;
}

let googleInfoWindow: ReactNode;
let googleInfoWindow: VNode;
if ("placeId" in infoWindow && infoWindow.placeId && infoWindow.latLng) {
googleInfoWindow = (
<GoogleInfoWindowContainer
Expand All @@ -115,7 +116,7 @@ class RestaurantMap extends Component<RestaurantMapProps> {
<GoogleMapsLoaderContext.Consumer>
{({ loader }) =>
loader ? (
<Suspense>
<Suspense fallback={null}>
<GoogleMap
defaultZoom={defaultZoom || GOOGLE_MAP_ZOOM}
defaultCenter={latLng}
Expand Down
2 changes: 1 addition & 1 deletion src/components/RestaurantMap/RestaurantMapContainer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { connect } from "react-redux";
import { ClickEventValue } from "google-map-react";
import {
clearCenter,
clearNewlyAdded,
Expand All @@ -13,7 +14,6 @@ import { getMapUi } from "../../selectors/mapUi";
import { getCurrentUser } from "../../selectors/user";
import { getMapItems } from "../../selectors";
import RestaurantMap from "./RestaurantMap";
import { ClickEventValue } from "google-map-react";

const mapStateToProps = (state: State) => {
const mapUi = getMapUi(state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const mapDispatchToProps = (
dispatch(flashSuccess("Default zoom level set for team."))
),
setShowUnvoted: (event: ChangeEvent<HTMLInputElement>) =>
dispatch(setShowUnvoted(event.target.checked)),
dispatch(setShowUnvoted(event.currentTarget.checked)),
setShowPOIs: (event: ChangeEvent<HTMLInputElement>) =>
dispatch(setShowPOIs(event.target.checked)),
dispatch(setShowPOIs(event.currentTarget.checked)),
});

export default connect(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { MouseEvent } from "react";
import { connect } from "react-redux";
import { Dispatch, State } from "../../interfaces";
import { getRestaurantById } from "../../selectors/restaurants";
Expand Down
Loading

0 comments on commit 4b6847a

Please sign in to comment.