Skip to content

Commit

Permalink
feat: typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
ob6160 committed Jun 27, 2021
1 parent dfb7dbb commit abc64e2
Show file tree
Hide file tree
Showing 40 changed files with 129 additions and 51 deletions.
10 changes: 0 additions & 10 deletions .babelrc

This file was deleted.

3 changes: 3 additions & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"react-hook-form": "6.15.8",
"react-leaflet": "2.8.0",
"react-leaflet-control": "2.1.2",
"react-router-hash-link": "2.4.3",
"react-simple-maps": "2.3.0",
"react-tooltip": "4.2.21",
"resize-observer-polyfill": "1.5.1",
Expand All @@ -98,7 +97,11 @@
"@mapbox/geojson-area": "0.2.2",
"@mapbox/geojson-rewind": "0.5.1",
"@shelf/jest-mongodb": "1.2.5",
"@types/jest": "26.0.23",
"@types/node": "15.12.4",
"@types/puppeteer": "5.4.3",
"@types/react": "17.0.11",
"@types/react-dom": "17.0.8",
"apollo-server-testing": "2.24.1",
"cli-progress": "3.9.0",
"customize-cra": "1.0.0",
Expand All @@ -121,6 +124,7 @@
"stylelint-config-standard": "22.0.0",
"topojson-server": "3.0.1",
"topojson-simplify": "3.0.3",
"typescript": "4.3.4",
"uuid": "8.3.2"
},
"browserslist": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/EntryForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { useForm, Controller } from 'react-hook-form';
import { Link } from 'react-router-dom';
import { Link } from 'next/link';
import isFunction from 'lodash/isFunction';
import omit from 'lodash/omit';
import pick from 'lodash/pick';
Expand Down
7 changes: 3 additions & 4 deletions src/components/Footer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { HashLink } from 'react-router-hash-link';
import { Link } from 'next/link';
import styled from '@emotion/styled';

import Box from './Box';
Expand Down Expand Up @@ -34,7 +33,7 @@ const Footer = ({ children }) => (
color="primary"
height={['auto', 60]}
>
<HashLink
<Link
to="/use-our-loos"
title="Domestos: Use Our Loos Campaign"
scroll={(el) => el.scrollIntoView(true)}
Expand All @@ -51,7 +50,7 @@ const Footer = ({ children }) => (
</Box>
</Box>
</Box>
</HashLink>
</Link>

<Box order={[-1, 0]} mb={[4, 0]}>
<Text fontSize={[12, 16]}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Link } from 'react-router-dom';
import Link from 'next/link';
import { faBars, faTimes } from '@fortawesome/free-solid-svg-icons';

import Box from '../Box';
Expand Down Expand Up @@ -70,7 +70,7 @@ const Header = ({ mapCenter, children }) => {
minHeight={60}
>
<Box flexShrink={0}>
<Link to="/">
<Link href="/">
<Logo />
</Link>
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { NavLink, useHistory } from 'react-router-dom';
import NavLink from 'next/link';
import {useRouter} from 'next/router';
import styled from '@emotion/styled';

import Box from '../Box';
Expand All @@ -18,16 +19,16 @@ const StyledNavLink = styled(NavLink)`
// Todo: Contact link
const MainMenu = ({
mapCenter,
onMenuItemClick = Function.prototype,
onMenuItemClick,
children,
}) => {
const { isAuthenticated, logout } = useAuth();
const history = useHistory();
const router = useRouter();

const handleLogout = () => {
logout();
onMenuItemClick();
history.push('/');
router.push('/');
};

return (
Expand Down Expand Up @@ -58,7 +59,7 @@ const MainMenu = ({
</Box>
<Box as="li" mt={[3, 0]} ml={[0, 4]}>
<StyledNavLink
to={
href={
mapCenter
? `/loos/add?lat=${mapCenter.lat}&lng=${mapCenter.lng}`
: `/loos/add`
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/LooMap/LooMap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { useHistory } from 'react-router-dom';
import { useHistory } from 'next/link';
import { css } from '@emotion/core';
import { Map, TileLayer, ZoomControl } from 'react-leaflet';
import 'focus-visible';
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/ProtectedRoute.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Route, Redirect } from 'react-router-dom';
import { Route, Redirect } from 'next/link';

import { useAuth } from '../Auth';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
faPlusCircle,
faMapMarkerAlt,
} from '@fortawesome/free-solid-svg-icons';
import { NavLink } from 'react-router-dom';
import { NavLink } from 'next/link';

import { Media } from '../components/Media';
import VisuallyHidden from './VisuallyHidden';
Expand Down
2 changes: 1 addition & 1 deletion src/components/ToiletDetailsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import lightFormat from 'date-fns/lightFormat';
import getISODay from 'date-fns/getISODay';
import parseISO from 'date-fns/parseISO';
import add from 'date-fns/add';
import { Link } from 'react-router-dom';
import { Link } from 'next/link';
import useComponentSize from '@rehooks/component-size';
import L from 'leaflet';
import { mutate } from 'swr';
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/explorer/Areas/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import useSWR from 'swr';
import { Link } from 'react-router-dom';
import { Link } from 'next/link';
import get from 'lodash/get';
import { loader } from 'graphql.macro';
import { print } from 'graphql/language/printer';
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/Home/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Link as InternalLink, useRouteMatch } from 'react-router-dom';
import { Link as InternalLink, useRouteMatch } from 'next/link';
import Paper from '@material-ui/core/Paper';
import ExternalLink from '@material-ui/core/Link';
import Typography from '@material-ui/core/Typography';
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/Layout.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Link, useRouteMatch, useHistory } from 'react-router-dom';
import { Link, useRouteMatch, useHistory } from 'next/link';

import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/Loo/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import useSWR from 'swr';
import { useParams } from 'react-router-dom';
import { useParams } from 'next/link';
import { loader } from 'graphql.macro';
import { print } from 'graphql/language/printer';

Expand Down
2 changes: 1 addition & 1 deletion src/explorer/Search/Results/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import uniq from 'lodash/uniq';
import TableRow from '@material-ui/core/TableRow';
import TableCell from '@material-ui/core/TableCell';
import { Link } from 'react-router-dom';
import { Link } from 'next/link';
import Chip from '@material-ui/core/Chip';
import Avatar from '@material-ui/core/Avatar';

Expand Down
2 changes: 1 addition & 1 deletion src/explorer/Search/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import useSWR from 'swr';
import { useLocation, useHistory, useRouteMatch } from 'react-router-dom';
import { useLocation, useHistory, useRouteMatch } from 'next/link';
import { parse, stringify } from 'query-string';
import { loader } from 'graphql.macro';
import { print } from 'graphql/language/printer';
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Switch, Route, useRouteMatch } from 'react-router-dom';
import { Switch, Route, useRouteMatch } from 'next/link';

import Layout from './Layout';
import Home from './Home';
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/index.js → src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'resize-observer-polyfill';

import React, { Suspense, lazy } from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, Switch, Redirect } from 'react-router-dom';
import { Router, Route, Switch, Redirect } from 'next/link';
import { createBrowserHistory } from 'history';
import { SWRConfig } from 'swr';

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pages/404.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'next/link';

import PageLayout from '../components/PageLayout';
import Box from '../components/Box';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/AboutPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'next/link';
import { Helmet } from 'react-helmet';
import styled from '@emotion/styled';

Expand Down
2 changes: 1 addition & 1 deletion src/pages/AddPage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Helmet } from 'react-helmet';
import queryString from 'query-string';
import { Redirect } from 'react-router-dom';
import { Redirect } from 'next/link';
import { mutate } from 'swr';
import { loader } from 'graphql.macro';
import { print } from 'graphql/language/printer';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/AuthCallback.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import { useHistory, useLocation } from 'next/link';

import { useAuth } from '../Auth';
import PageLayout from '../components/PageLayout';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/CookiesPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'next/link';
import { Helmet } from 'react-helmet';

import PageLayout from '../components/PageLayout';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/EditPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react';
import { Helmet } from 'react-helmet';
import { Link, Redirect } from 'react-router-dom';
import { Link, Redirect } from 'next/link';
import merge from 'lodash/merge';
import cloneDeep from 'lodash/cloneDeep';
import uniqBy from 'lodash/uniqBy';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/HomePage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { useParams, useRouteMatch } from 'react-router-dom';
import { useParams, useRouteMatch } from 'next/link';
import queryString from 'query-string';
import { Helmet } from 'react-helmet';
import useSWR from 'swr';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RemovePage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { Helmet } from 'react-helmet';
import useSWR from 'swr';
import { Redirect, useParams, useHistory } from 'react-router-dom';
import { Redirect, useParams, useHistory } from 'next/link';
import { loader } from 'graphql.macro';
import { print } from 'graphql/language/printer';

Expand Down
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
]
}

0 comments on commit abc64e2

Please sign in to comment.