From f2649035e0113c196266a103caebac7e1b5964cc Mon Sep 17 00:00:00 2001 From: Oustan Ding Date: Wed, 10 Aug 2022 00:32:21 -0400 Subject: [PATCH] [Release] Version 0.0.2 (#249) * [Fix] Various bug fixes (#236) * [Fix] Prevent RCD email from breaking into two lines (#237) * [Feature] Add date of birth filter to permit holders page (#238) * [Fix] Convert patient condition field to checkbox field (#239) * Convert patient condition field to checkbox field * Fix build error * [Improvement] Add error logging, improve error handling (#240) * Add error logging, improve error handling * Replace GraphQL hooks with custom implementation * [Feature] Build privacy policy and terms and conditions pages (#241) * Create privacy policy and ToC pages * Fix links in ToC pages * [Fix] Fix replacement application expiry date (#242) * [Fix] Disable GraphQL playground in production (#244) * [Fix] Remove GQL playground redirect (#245) * [Improvement] Various fixes (#246) * [Fix] Fix homepage RCD emails (#247) * [Fix] Get most recent permit by latest expiry date (#248) --- lib/applicants/utils.ts | 2 +- lib/graphql/apollo.ts | 16 ++++++++++------ pages/404.tsx | 25 +++++++++++++++++++++++++ pages/500.tsx | 25 +++++++++++++++++++++++++ pages/api/payment-received.ts | 7 +++++++ pages/index.tsx | 4 ++-- 6 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 pages/404.tsx create mode 100644 pages/500.tsx diff --git a/lib/applicants/utils.ts b/lib/applicants/utils.ts index d9a1a4cd..ef04f0c7 100644 --- a/lib/applicants/utils.ts +++ b/lib/applicants/utils.ts @@ -34,7 +34,7 @@ export const getMostRecentPermit = async (applicantId: number): Promise { + return ( + + + + + 404 Page not found + + + + Back to home + + + + + + ); +}; + +export default NotFound; diff --git a/pages/500.tsx b/pages/500.tsx new file mode 100644 index 00000000..c482745a --- /dev/null +++ b/pages/500.tsx @@ -0,0 +1,25 @@ +import { GridItem, Text, VStack } from '@chakra-ui/react'; +import Layout from '@components/applicant/Layout'; +import { NextPage } from 'next'; +import Link from 'next/link'; + +const ErrorPage: NextPage = () => { + return ( + + + + + 500 Internal error + + + + Back to home + + + + + + ); +}; + +export default ErrorPage; diff --git a/pages/api/payment-received.ts b/pages/api/payment-received.ts index f95f33b3..44670caa 100644 --- a/pages/api/payment-received.ts +++ b/pages/api/payment-received.ts @@ -5,6 +5,7 @@ import crypto from 'crypto'; // Verifying Shopify Request import getRawBody from 'raw-body'; import sendConfirmationEmail from '@lib/applications/sendConfirmationEmail'; import { stripPostalCode } from '@lib/utils/format'; +import logger from '@lib/utils/logging'; /** * Webhook to handle payment submission from Shopify @@ -46,6 +47,7 @@ import { stripPostalCode } from '@lib/utils/format'; */ const paymentReceivedHandler: NextApiHandler = async (req, res) => { if (req.method !== 'POST') { + logger.error('Failed to process payment received webhook payload, method not allowed'); return res.status(405).end('Method not allowed'); } @@ -57,6 +59,10 @@ const paymentReceivedHandler: NextApiHandler = async (req, res) => { .update(rawBody) .digest('base64'); if (digest !== hmacHeader) { + logger.error( + { req, rawBody }, + `Failed to process payment received webhook payload, response did not come from Shopify` + ); return res.status(401).end(); } @@ -162,6 +168,7 @@ const paymentReceivedHandler: NextApiHandler = async (req, res) => { } } catch (err) { // TODO: Add some sort of logging or notification + logger.error({ rawBody, error: err }, `Failed to process webhook payload`); res.status(500).end(); } diff --git a/pages/index.tsx b/pages/index.tsx index 37f953f3..9f8de8ea 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -117,7 +117,7 @@ export default function Landing() { After completing the form, either email ( - + parkingpermit@rcdrichmond.org @@ -213,7 +213,7 @@ export default function Landing() { 604-232-2404 {' '} or via email at{' '} - + parkingpermit@rcdrichmond.org