Scheduling infrastructure for absolutely everyone.
Standardise semicolons
Bailey Pumfleetddd7ccfb01af
diff --git a/lib/prisma.ts b/lib/prisma.tsindex bd998662719..20e4d98c9ab 100644--- a/lib/prisma.ts+++ b/lib/prisma.ts@@ -1,14 +1,14 @@-import { PrismaClient } from '@prisma/client'+import { PrismaClient } from '@prisma/client';-let prisma: PrismaClient+let prisma: PrismaClient;if (process.env.NODE_ENV === 'production') {- prisma = new PrismaClient()+ prisma = new PrismaClient();} else {if (!global.prisma) {- global.prisma = new PrismaClient()+ global.prisma = new PrismaClient();}- prisma = global.prisma+ prisma = global.prisma;}-export default prisma\ No newline at end of file+export default prisma;\ No newline at end of filediff --git a/pages/[user].tsx b/pages/[user].tsxindex dcf6413b5cb..c41f3907460 100644--- a/pages/[user].tsx+++ b/pages/[user].tsx@@ -1,6 +1,6 @@-import Head from 'next/head'-import Link from 'next/link'-import prisma from '../lib/prisma'+import Head from 'next/head';+import Link from 'next/link';+import prisma from '../lib/prisma';export default function User(props) {const eventTypes = props.user.eventTypes.map(type =>diff --git a/pages/[user]/[type].tsx b/pages/[user]/[type].tsxindex df71bb048ae..6dec63545d9 100644--- a/pages/[user]/[type].tsx+++ b/pages/[user]/[type].tsx@@ -1,11 +1,11 @@-import {useEffect, useState} from 'react'-import Head from 'next/head'-import Link from 'next/link'-import prisma from '../../lib/prisma'-import { useRouter } from 'next/router'-const dayjs = require('dayjs')-const isSameOrBefore = require('dayjs/plugin/isSameOrBefore')-dayjs.extend(isSameOrBefore)+import {useEffect, useState} from 'react';+import Head from 'next/head';+import Link from 'next/link';+import prisma from '../../lib/prisma';+import { useRouter } from 'next/router';+const dayjs = require('dayjs');+const isSameOrBefore = require('dayjs/plugin/isSameOrBefore');+dayjs.extend(isSameOrBefore);export default function Type(props) {// Initialise state@@ -15,23 +15,23 @@ export default function Type(props) {const [busy, setBusy] = useState([]);// Get router variables- const router = useRouter()- const { user } = router.query+ const router = useRouter();+ const { user } = router.query;// Handle month changesconst incrementMonth = () => {- setSelectedMonth(selectedMonth + 1)+ setSelectedMonth(selectedMonth + 1);}const decrementMonth = () => {- setSelectedMonth(selectedMonth - 1)+ setSelectedMonth(selectedMonth - 1);}// Set up calendar- var daysInMonth = dayjs().month(selectedMonth).daysInMonth()- var days = []+ var daysInMonth = dayjs().month(selectedMonth).daysInMonth();+ var days = [];for (let i = 1; i <= daysInMonth; i++) {- days.push(i)+ days.push(i);}const calendar = days.map((day) =>@@ -43,14 +43,14 @@ export default function Type(props) {// Handle date changeuseEffect(async () => {setLoading(true);- const res = await fetch('/api/availability/' + user + '?date=' + dayjs(selectedDate).format("YYYY-MM-DD"))- const data = await res.json()- setBusy(data.primary.busy)- setLoading(false)+ const res = await fetch('/api/availability/' + user + '?date=' + dayjs(selectedDate).format("YYYY-MM-DD"));+ const data = await res.json();+ setBusy(data.primary.busy);+ setLoading(false);}, [selectedDate]);// Set up timeslots- let times = []+ let times = [];// If we're looking at availability throughout the current date, work out the current number of minutes elapsed throughout the dayif (selectedDate == dayjs().format("YYYY-MM-DD")) {@@ -61,14 +61,14 @@ export default function Type(props) {// Until day end, push new times every x minutesfor (;i < 1440; i += parseInt(props.eventType.length)) {- times.push(dayjs(selectedDate).hour(Math.floor(i / 60)).minute(i % 60).startOf(props.eventType.length, 'minute').add(props.eventType.length, 'minute').format("YYYY-MM-DD HH:mm:ss"))+ times.push(dayjs(selectedDate).hour(Math.floor(i / 60)).minute(i % 60).startOf(props.eventType.length, 'minute').add(props.eventType.length, 'minute').format("YYYY-MM-DD HH:mm:ss"));}// Check for conflictstimes.forEach(time => {busy.forEach(busyTime => {- let startTime = dayjs(busyTime.start)- let endTime = dayjs(busyTime.end)+ let startTime = dayjs(busyTime.start);+ let endTime = dayjs(busyTime.end);// Check if start times are the sameif (dayjs(time).format('HH:mm') == startTime.format('HH:mm')) {@@ -143,7 +143,7 @@ export default function Type(props) {</div></main></div>- )+ );}export async function getServerSideProps(context) {diff --git a/pages/[user]/book.tsx b/pages/[user]/book.tsxindex 8fbb99ef7cb..5ede46fc391 100644--- a/pages/[user]/book.tsx+++ b/pages/[user]/book.tsx@@ -1,15 +1,15 @@-import Head from 'next/head'-import Link from 'next/link'-import { useRouter } from 'next/router'-import prisma from '../../lib/prisma'-const dayjs = require('dayjs')+import Head from 'next/head';+import Link from 'next/link';+import { useRouter } from 'next/router';+import prisma from '../../lib/prisma';+const dayjs = require('dayjs');export default function Book(props) {- const router = useRouter()- const { date, user } = router.query+ const router = useRouter();+ const { date, user } = router.query;const bookingHandler = event => {- event.preventDefault()+ event.preventDefault();const res = fetch('/api/book/' + user,{@@ -25,8 +25,8 @@ export default function Book(props) {},method: 'POST'}- )- router.push("/success?date=" + date + "&type=" + props.eventType.id + "&user=" + props.user.username)+ );+ router.push("/success?date=" + date + "&type=" + props.eventType.id + "&user=" + props.user.username);}return (diff --git a/pages/_app.tsx b/pages/_app.tsxindex 45f01971706..2bbf669da65 100644--- a/pages/_app.tsx+++ b/pages/_app.tsx@@ -1,12 +1,12 @@-import '../styles/globals.css'-import { Provider } from 'next-auth/client'+import '../styles/globals.css';+import { Provider } from 'next-auth/client';function MyApp({ Component, pageProps }) {return (<Provider session={pageProps.session}><Component {...pageProps} /></Provider>- )+ );}-export default MyApp+export default MyApp;diff --git a/pages/api/book/[user].ts b/pages/api/book/[user].tsindex 0205e576779..6fee253b57e 100644--- a/pages/api/book/[user].ts+++ b/pages/api/book/[user].ts@@ -1,11 +1,11 @@-import type { NextApiRequest, NextApiResponse } from 'next'-import prisma from '../../../lib/prisma'+import type { NextApiRequest, NextApiResponse } from 'next';+import prisma from '../../../lib/prisma';const {google} = require('googleapis');const credentials = process.env.GOOGLE_API_CREDENTIALS;export default async function handler(req: NextApiRequest, res: NextApiResponse) {- const { user } = req.query+ const { user } = req.query;const currentUser = await prisma.user.findFirst({where: {@@ -16,14 +16,14 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)}});- authorise(bookEvent)+ authorise(bookEvent);// Set up Google API credentialsfunction authorise(callback) {const {client_secret, client_id, redirect_uris} = JSON.parse(credentials).web;const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);oAuth2Client.setCredentials(currentUser.credentials[0].key);- callback(oAuth2Client)+ callback(oAuth2Client);}function bookEvent(auth) {diff --git a/pages/api/integrations/googlecalendar/add.ts b/pages/api/integrations/googlecalendar/add.tsindex 18520ae0afe..0e7be5a71d2 100644--- a/pages/api/integrations/googlecalendar/add.ts+++ b/pages/api/integrations/googlecalendar/add.ts@@ -1,4 +1,4 @@-import type { NextApiRequest, NextApiResponse } from 'next'+import type { NextApiRequest, NextApiResponse } from 'next';import { getSession } from 'next-auth/client';import prisma from '../../../../lib/prisma';const {google} = require('googleapis');diff --git a/pages/api/integrations/googlecalendar/callback.ts b/pages/api/integrations/googlecalendar/callback.tsindex 6e0c2f220bc..8063d6752ff 100644--- a/pages/api/integrations/googlecalendar/callback.ts+++ b/pages/api/integrations/googlecalendar/callback.ts@@ -1,4 +1,4 @@-import type { NextApiRequest, NextApiResponse } from 'next'+import type { NextApiRequest, NextApiResponse } from 'next';import { getSession } from 'next-auth/client';import prisma from '../../../../lib/prisma';const {google} = require('googleapis');@@ -6,7 +6,7 @@ const {google} = require('googleapis');const credentials = process.env.GOOGLE_API_CREDENTIALS;export default async function handler(req: NextApiRequest, res: NextApiResponse) {- const { code } = req.query+ const { code } = req.query;// Check that user is authenticatedconst session = await getSession({req: req});diff --git a/pages/auth/error.tsx b/pages/auth/error.tsxindex 45591a5be81..9bb69151a69 100644--- a/pages/auth/error.tsx+++ b/pages/auth/error.tsx@@ -3,8 +3,8 @@ import Head from 'next/head';import Link from 'next/link';export default function Error() {- const router = useRouter()- const { error } = router.query+ const router = useRouter();+ const { error } = router.query;return (<div className="fixed z-10 inset-0 overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true">diff --git a/pages/success.tsx b/pages/success.tsxindex 36c733b2181..aeb16f0850f 100644--- a/pages/success.tsx+++ b/pages/success.tsx@@ -1,12 +1,12 @@-import Head from 'next/head'-import Link from 'next/link'-import prisma from '../lib/prisma'-import { useRouter } from 'next/router'-const dayjs = require('dayjs')+import Head from 'next/head';+import Link from 'next/link';+import prisma from '../lib/prisma';+import { useRouter } from 'next/router';+const dayjs = require('dayjs');export default function Success(props) {- const router = useRouter()- const { date } = router.query+ const router = useRouter();+ const { date } = router.query;return(<div>diff --git a/pages/team/add.tsx b/pages/team/add.tsxdeleted file mode 100644index 57cbce3ee28..00000000000--- a/pages/team/add.tsx+++ /dev/null@@ -1,51 +0,0 @@-import { useRef } from 'react';--export default function add() {- const usernameInputRef = useRef();- const emailInputRef = useRef();- const passwordInputRef = useRef();-- async function createUser(username, email, password) {- const response = await fetch('/api/auth/signup', {- method: 'POST',- body: JSON.stringify({username, email, password}),- headers: {- 'Content-Type': 'application/json'- }- });-- const data = await response.json();-- if (!response.ok) {- throw new Error(data.message || 'Something went wrong.');- }-- return data;- }-- async function submitHandler(event) {- event.preventDefault();-- const enteredUsername = usernameInputRef.current.value;- const enteredEmail = emailInputRef.current.value;- const enteredPassword = passwordInputRef.current.value;-- // TODO: Add validation-- try {- const result = await createUser(enteredUsername, enteredEmail, enteredPassword);- console.log(result);- } catch (error) {- console.log(error);- }- }-- return (- <form onSubmit={submitHandler}>- <input type="text" id="username" name="username" placeholder="Username" ref={usernameInputRef} />- <input type="text" id="email" name="email" placeholder="Email Address" ref={emailInputRef}/>- <input type="text" id="password" name="password" placeholder="Password" ref={passwordInputRef}/>- <input type="submit" value="Sign up"/>- </form>- );-}\ No newline at end of file