fix all the formatting

This commit is contained in:
Thomas Ruoff
2022-04-02 00:42:25 +02:00
parent 8e0648bf0f
commit 3c4f0efdc2
11 changed files with 79 additions and 59 deletions

View File

@@ -9,9 +9,13 @@ export const getServerSideProps = getServerSideRecentBookings
function AdminRecentBookings({ bookings }) {
if (!bookings || !bookings.length) {
return <Layout>
<h3 className="text-lg leading-6 font-medium text-gray-900">No recent bookings 😿</h3>
</Layout>
return (
<Layout>
<h3 className="text-lg leading-6 font-medium text-gray-900">
No recent bookings 😿
</h3>
</Layout>
)
}
return (

View File

@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import NextAuth from 'next-auth'
import EmailProvider from 'next-auth/providers/email'
import GitHubProvider from "next-auth/providers/github";
import GitHubProvider from 'next-auth/providers/github'
import { MongoDBAdapter } from '@next-auth/mongodb-adapter'
import { MONGO_URI } from '../../../db'
@@ -10,7 +10,7 @@ import { MongoClient } from 'mongodb'
let client: MongoClient
const ADMIN_EMAIL = process.env.ADMIN_EMAIL
const GITHUB_USERS_GRANTED = ['111471'];
const GITHUB_USERS_GRANTED = ['111471']
async function getMongoClient() {
if (!client) {
@@ -28,7 +28,7 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) {
providers: [
GitHubProvider({
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET
clientSecret: process.env.GITHUB_CLIENT_SECRET,
}),
EmailProvider({
server: {
@@ -48,17 +48,17 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) {
if (account.provider === 'email') {
if (email.verificationRequest) {
// only allow admins by email entered
return account.providerAccountId === ADMIN_EMAIL;
return account.providerAccountId === ADMIN_EMAIL
}
// if user accesses with magic link, also only allow admin
return account.providerAccountId === ADMIN_EMAIL
} else if (account.provider === 'github') {
// only one and only one user
return GITHUB_USERS_GRANTED.includes(account.providerAccountId);
return GITHUB_USERS_GRANTED.includes(account.providerAccountId)
}
return false;
}
}
return false
},
},
})
}

View File

@@ -5,7 +5,7 @@ import { createBill, patchBill } from '../../../../db/index'
export default async function billHandler(
req: NextApiRequest,
res: NextApiResponse
): Promise<void> {
): Promise<void> {
const {
method,
query: { uuid: uuids },

View File

@@ -27,10 +27,10 @@ export default async function userHandler(
}
try {
const booking = await patchBooking(uuid, req.body);
const booking = await patchBooking(uuid, req.body)
res.status(200).json(booking)
} catch (error) {
console.error('failed patch booking', error);
console.error('failed patch booking', error)
res.status(400).end(`Failed to save booking: ${error.message}`)
}
break