prettier all the things

This commit is contained in:
Thomas Ruoff
2022-02-19 23:18:49 +01:00
committed by Thomas Ruoff
parent c35d3009c6
commit 36f8719531
28 changed files with 433 additions and 428 deletions

View File

@@ -14,23 +14,22 @@ export type ServerSideRecentBooking = {
}
}
export const getServerSideRecentBookings = async (): Promise<
ServerSideRecentBooking
> => {
const bookings = await getBookings({
startDateGreaterThan: startOfYear(nowInTz()).toISOString(),
})
export const getServerSideRecentBookings =
async (): Promise<ServerSideRecentBooking> => {
const bookings = await getBookings({
startDateGreaterThan: startOfYear(nowInTz()).toISOString(),
})
// TODO: hack, not sure why _id is not serilizable
const bookingsJSON = JSON.parse(
JSON.stringify(bookings.map((b) => b.toJSON()))
) as object[]
return {
props: {
bookings: bookingsJSON,
},
// TODO: hack, not sure why _id is not serilizable
const bookingsJSON = JSON.parse(
JSON.stringify(bookings.map((b) => b.toJSON()))
) as object[]
return {
props: {
bookings: bookingsJSON,
},
}
}
}
export const getServerSideBooking = async (
context: any

View File

@@ -1,46 +1,44 @@
import { google } from 'googleapis'
import { Booking } from '../db/booking'
import {google} from 'googleapis';
import { Booking } from '../db/booking';
const keyFile = process.env.GOOGLE_SERVICE_ACCOUNT_KEY_FILE;
const calendarId = process.env.GOOGLE_CALENDAR_ID;
const keyFile = process.env.GOOGLE_SERVICE_ACCOUNT_KEY_FILE
const calendarId = process.env.GOOGLE_CALENDAR_ID
const auth = new google.auth.GoogleAuth({
keyFile,
scopes: [
'https://www.googleapis.com/auth/calendar',
'https://www.googleapis.com/auth/calendar.readonly'
'https://www.googleapis.com/auth/calendar.readonly',
],
});
})
const calendar = google.calendar({
version: 'v3',
auth,
});
})
export async function getNewEvents() {
const { data } = await calendar.events.list({
calendarId,
timeMin: new Date().toISOString()}
);
timeMin: new Date().toISOString(),
})
return data.items;
return data.items
}
function getSummary(booking: Partial<Booking>) : string {
let summary = "";
function getSummary(booking: Partial<Booking>): string {
let summary = ''
if (booking.org) {
summary += `${booking.org} - `;
summary += `${booking.org} - `
}
summary += booking.name;
summary += booking.name
return summary;
return summary
}
export async function createCalendarEvent(booking : Booking) : Promise<Booking> {
export async function createCalendarEvent(booking: Booking): Promise<Booking> {
const response = await calendar.events.insert({
auth,
calendarId,
@@ -49,12 +47,12 @@ export async function createCalendarEvent(booking : Booking) : Promise<Booking>
// description,
start: { date: booking.startDate },
end: { date: booking.endDate },
}
});
},
})
booking.calendarEventId = response.data.id;
booking.calendarEventId = response.data.id
return booking;
return booking
}
export async function deleteCalendarEvent(booking: Booking) {
@@ -62,9 +60,9 @@ export async function deleteCalendarEvent(booking: Booking) {
auth,
calendarId,
eventId: booking.calendarEventId,
});
})
booking.calendarEventId = null;
booking.calendarEventId = null
}
//export async function patchCalendarEvent(booking: { calendarEventId: string } & Partial<Booking> ) : Promise<Booking> {
@@ -76,4 +74,3 @@ export async function deleteCalendarEvent(booking: Booking) {
//
// return booking;
//}