Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
domdomegg committed May 27, 2024
1 parent ae67270 commit f3aca96
Show file tree
Hide file tree
Showing 21 changed files with 1,095 additions and 574 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ node_modules
/coverage

# production
/build
build

# misc
.DS_Store
Expand Down
983 changes: 722 additions & 261 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"node": ">=14.15.0"
},
"dependencies": {
"@aws-sdk/client-ses": "^3.363.0",
"@aws-sdk/node-http-handler": "^3.127.0",
"@aws-sdk/client-ses": "^3.583.0",
"@smithy/node-http-handler": "^3.0.0",
"ajv": "^8.11.0",
"axios": "^1.6.0",
"http-errors": "^1.8.0",
Expand All @@ -29,7 +29,7 @@
"source-map-support": "^0.5.21"
},
"devDependencies": {
"@serverless/typescript": "^2.61.0",
"@serverless/typescript": "^3.38.0",
"@types/aws-lambda": "^8.10.71",
"@types/http-errors": "^1.8.1",
"@types/jest": "^27.0.2",
Expand All @@ -43,16 +43,16 @@
"eslint-config-blvd": "^1.2.1",
"fork-ts-checker-webpack-plugin": "^7.2.11",
"jest": "^27.3.1",
"serverless": "^3.17.0",
"serverless-offline": "^12.0.3",
"serverless-offline-ses-v2": "^1.0.1",
"serverless-webpack": "^5.7.1",
"serverless": "^3.38.0",
"serverless-offline": "^13.6.0",
"serverless-offline-ses-v2": "^1.0.4",
"serverless-webpack": "^5.14.0",
"shx": "^0.3.4",
"ts-jest": "^27.0.7",
"ts-loader": "^9.2.6",
"ts-node": "^10.2.1",
"typescript": "^4.4.3",
"webpack": "^5.76.0",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"webpack": "^5.91.0",
"webpack-node-externals": "^3.0.0"
},
"jest": {
Expand Down
2 changes: 1 addition & 1 deletion server/src/email.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import nodemailer from 'nodemailer'
import * as aws from '@aws-sdk/client-ses'
import { NodeHttpHandler } from '@aws-sdk/node-http-handler'
import { NodeHttpHandler } from '@smithy/node-http-handler'
import env from './env/env'

const requestHandler = new NodeHttpHandler({
Expand Down
5 changes: 5 additions & 0 deletions web/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
extends: [
'eslint-config-domdomegg',
],
};
15 changes: 5 additions & 10 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@types/styled-components": "^5.1.25",
"eslint-config-domdomegg": "^1.2.3",
"govuk-react": "^0.10.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -22,7 +23,10 @@
"react-scripts": "^5.0.1",
"signature_pad": "^4.0.7",
"styled-components": "^5.3.5",
"typescript": "^4.7.4"
"typescript": "^5.4.5"
},
"devDependencies": {
"shx": "^0.3.4"
},
"scripts": {
"postinstall": "shx cp -n src/env/local.template.ts src/env/local.ts && shx cp -n src/env/local.ts src/env/env.ts",
Expand All @@ -36,12 +40,6 @@
"eject": "react-scripts eject"
},
"homepage": ".",
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
Expand All @@ -53,8 +51,5 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"shx": "^0.3.4"
}
}
94 changes: 61 additions & 33 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,89 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCheckToSlot } from '@fortawesome/free-solid-svg-icons';
import { GlobalStyle, TopNav, Page, PhaseBanner, Link, GridRow, GridCol, Footer } from 'govuk-react';
import {
GlobalStyle, TopNav, Page, PhaseBanner, Link, GridRow, GridCol, Footer,
} from 'govuk-react';
import {
Routes, Route, Link as ReactRouterLink, useNavigate,
} from 'react-router-dom';
import Start from './pages/Start';
import IsRegisteredForm from './pages/IsRegisteredForm';
import NeedsRegistration from './pages/NeedsRegistration';
import PostalVoteForm from './pages/PostalVoteForm';
import { Routes, Route, Link as ReactRouterLink, useNavigate } from 'react-router-dom';
import CountryForm from './pages/CountryForm';
import NorthernIreland from './pages/NorthernIreland';
import env from './env/env';

const App = () => {
const navigate = useNavigate()
const navigate = useNavigate();

return (
<div style={{ display: 'flex', flexDirection: 'column', minHeight: '100vh' }}>
<GlobalStyle />
<TopNav
company={<TopNav.Anchor as={ReactRouterLink} to="/">
<TopNav.IconTitle icon={<FontAwesomeIcon icon={faCheckToSlot} height={32} />}>
postal-vote
</TopNav.IconTitle>
</TopNav.Anchor>}
serviceTitle={<TopNav.NavLink as={ReactRouterLink} to="/">
Apply for a postal vote
</TopNav.NavLink>}
company={(
<TopNav.Anchor as={ReactRouterLink} to="/">
<TopNav.IconTitle icon={<FontAwesomeIcon icon={faCheckToSlot} height={32} />}>
postal-vote
</TopNav.IconTitle>
</TopNav.Anchor>
)}
serviceTitle={(
<TopNav.NavLink as={ReactRouterLink} to="/">
Apply for a postal vote
</TopNav.NavLink>
)}
/>
<div style={{ flex: '1' }}>
<Page.WidthContainer>
<PhaseBanner level="alpha">
This is a new service – your <Link href="https://github.com/domdomegg/postal-vote/issues/new" target="_blank" rel="noreferrer">feedback</Link> will help us to improve it.
</PhaseBanner>
{env.STAGE !== "prod" && <PhaseBanner level={env.STAGE}>
{env.STAGE !== 'prod' && (
<PhaseBanner level={env.STAGE}>
This is the {env.STAGE} version of postal-vote.
</PhaseBanner>}
</PhaseBanner>
)}
<Page.Main>
<GridRow>
<GridCol setDesktopWidth="two-thirds">
<Routes>
<Route path="/" element={
<Start onStart={() => navigate('/is-registered')} />
} />
<Route path="/is-registered" element={
<IsRegisteredForm onRegistered={() => navigate('/country')} onNotRegistered={() => navigate('/needs-registration')} />
} />
<Route path="/needs-registration" element={
<NeedsRegistration />
} />
<Route path="/country" element={
<CountryForm onNonNI={() => navigate('/postal-vote-form/your-details')} onNI={() => navigate('/northern-ireland')} />
} />
<Route path="/northern-ireland" element={
<NorthernIreland />
} />
<Route path="/postal-vote-form/*" element={
<PostalVoteForm />
} />
<Route
path="/"
element={
<Start onStart={() => navigate('/is-registered')} />
}
/>
<Route
path="/is-registered"
element={
<IsRegisteredForm onRegistered={() => navigate('/country')} onNotRegistered={() => navigate('/needs-registration')} />
}
/>
<Route
path="/needs-registration"
element={
<NeedsRegistration />
}
/>
<Route
path="/country"
element={
<CountryForm onNonNI={() => navigate('/postal-vote-form/your-details')} onNI={() => navigate('/northern-ireland')} />
}
/>
<Route
path="/northern-ireland"
element={
<NorthernIreland />
}
/>
<Route
path="/postal-vote-form/*"
element={
<PostalVoteForm />
}
/>
</Routes>
</GridCol>
</GridRow>
Expand All @@ -64,7 +92,7 @@ const App = () => {
</div>
<Footer meta={<Footer.MetaCustom>Built by Adam Jones with source code available on <Footer.Link href="https://github.com/domdomegg/postal-vote">GitHub</Footer.Link></Footer.MetaCustom>} />
</div>
)
}
);
};

export default App;
12 changes: 6 additions & 6 deletions web/src/components/rhfDateField.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { DateField } from 'govuk-react'
import { DateFieldProps } from "@govuk-react/date-field";
import React from 'react';
import { DateField } from 'govuk-react';
import type { DateFieldProps } from '@govuk-react/date-field';

const RHFDateField: React.FC<{
input: {
Expand Down Expand Up @@ -41,13 +41,13 @@ const RHFDateField: React.FC<{
setValue({ ...value, ...newValue });
onChange({ target: { value: { ...value, ...newValue }, name: input.name } });
},
onBlur: (newValue) => onBlur({ target: { value, name: input.name } }),
onBlur: () => onBlur({ target: { value, name: input.name } }),
...input,
}}
>
{children}
</DateField >
</DateField>
);
};

export default RHFDateField;
export default RHFDateField;
12 changes: 6 additions & 6 deletions web/src/env/dev.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Env } from "../types"
import type { Env } from '../types';

const env: Env = {
STAGE: "dev",
STAGE: 'dev',

API_BASE_URL: "https://1vti3u2qk1.execute-api.eu-west-1.amazonaws.com",
API_BASE_URL: 'https://1vti3u2qk1.execute-api.eu-west-1.amazonaws.com',

RECAPTCHA_V3_SITE_KEY: "6LfZqq0fAAAAAIxbz8FaOa4SKQeefeISd6TCN6AN",
}
RECAPTCHA_V3_SITE_KEY: '6LfZqq0fAAAAAIxbz8FaOa4SKQeefeISd6TCN6AN',
};

export default env
export default env;
12 changes: 6 additions & 6 deletions web/src/env/local.template.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Env } from "../types"
import type { Env } from '../types';

const env: Env = {
STAGE: "local",
STAGE: 'local',

API_BASE_URL: "http://localhost:8001",
API_BASE_URL: 'http://localhost:8001',

RECAPTCHA_V3_SITE_KEY: "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI",
}
RECAPTCHA_V3_SITE_KEY: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI',
};

export default env
export default env;
12 changes: 6 additions & 6 deletions web/src/env/prod.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Env } from "../types"
import type { Env } from '../types';

const env: Env = {
STAGE: "prod",
STAGE: 'prod',

API_BASE_URL: "https://6j0yoseuwi.execute-api.eu-west-1.amazonaws.com",
API_BASE_URL: 'https://6j0yoseuwi.execute-api.eu-west-1.amazonaws.com',

RECAPTCHA_V3_SITE_KEY: "6LdLmK0fAAAAAFiQ8edy697yN4jhpl1K33I8Bv-M",
}
RECAPTCHA_V3_SITE_KEY: '6LdLmK0fAAAAAFiQ8edy697yN4jhpl1K33I8Bv-M',
};

export default env
export default env;
12 changes: 6 additions & 6 deletions web/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import App from './App';
import env from './env/env';

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
document.getElementById('root') as HTMLElement,
);

root.render(
<React.StrictMode>
<HashRouter>
<App />
</HashRouter>
</React.StrictMode>
</React.StrictMode>,
);

const recaptchaScript = document.createElement('script')
recaptchaScript.src = `https://www.google.com/recaptcha/api.js?render=${env.RECAPTCHA_V3_SITE_KEY}`
recaptchaScript.async = true
document.body.appendChild(recaptchaScript)
const recaptchaScript = document.createElement('script');
recaptchaScript.src = `https://www.google.com/recaptcha/api.js?render=${env.RECAPTCHA_V3_SITE_KEY}`;
recaptchaScript.async = true;
document.body.appendChild(recaptchaScript);
24 changes: 13 additions & 11 deletions web/src/pages/CountryForm.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import { Button, Fieldset, MultiChoice, Radio } from "govuk-react";
import { SubmitHandler, useForm } from "react-hook-form";
import {
Button, Fieldset, MultiChoice, Radio,
} from 'govuk-react';
import { SubmitHandler, useForm } from 'react-hook-form';

const CountryForm = ({ onNonNI, onNI }: { onNonNI: () => void, onNI: () => void }) => {
type TFieldValues = {
country: 'England' | 'Scotland' | 'Wales' | 'Northern Ireland'
}
};

const {
register,
handleSubmit,
formState: { errors, submitCount, isSubmitting },
} = useForm<TFieldValues>({
reValidateMode: 'onSubmit',
})
});

const validateAnswered = (value?: string): string | undefined => value?.length ? undefined : 'Please select an option';
const validateAnswered = (value?: string): string | undefined => (value?.length ? undefined : 'Please select an option');

const onSubmit: SubmitHandler<TFieldValues> = ({ country }) => {
if (country === 'Northern Ireland') return onNI()
return onNonNI()
}
if (country === 'Northern Ireland') return onNI();
return onNonNI();
};

return (
<form onSubmit={handleSubmit(onSubmit)}>
Expand Down Expand Up @@ -71,7 +73,7 @@ const CountryForm = ({ onNonNI, onNI }: { onNonNI: () => void, onNI: () => void
</Button>
</Fieldset>
</form>
)
}
);
};

export default CountryForm
export default CountryForm;
Loading

0 comments on commit f3aca96

Please sign in to comment.