diff --git a/components/DonateBanner.tsx b/components/DonateBanner.tsx index db3835c1..41675d9a 100644 --- a/components/DonateBanner.tsx +++ b/components/DonateBanner.tsx @@ -1,9 +1,8 @@ import { GiftIcon } from "@heroicons/react/outline"; export default function DonateBanner() { - -if (location.hostname.endsWith(".calendso.com")) { -return null; -} + if (location.hostname.endsWith(".calendso.com")) { + return null; + } return ( <> @@ -17,21 +16,19 @@ return null;
- - Support the ongoing development - + Support the ongoing development - You're using the free self-hosted version. Support the - ongoing development by making a donation. + You're using the free self-hosted version. Support the ongoing development by making + a donation.
diff --git a/components/ui/Text/Text.module.css b/components/ui/Text/Text.module.css index 0afe4759..c850000e 100644 --- a/components/ui/Text/Text.module.css +++ b/components/ui/Text/Text.module.css @@ -2,9 +2,6 @@ @apply font-medium; } */ -.text { -} - .text--body { @apply text-lg leading-relaxed; } diff --git a/next.config.js b/next.config.js index ab513115..b35afdce 100644 --- a/next.config.js +++ b/next.config.js @@ -1,31 +1,40 @@ - -const withTM = require('next-transpile-modules')(['react-timezone-select']); +import nextTranspileModules from "next-transpile-modules"; +const withTM = nextTranspileModules(["react-timezone-select"]); // TODO: Revisit this later with getStaticProps in App if (process.env.NEXTAUTH_URL) { - process.env.BASE_URL = process.env.NEXTAUTH_URL.replace('/api/auth', ''); + process.env.BASE_URL = process.env.NEXTAUTH_URL.replace("/api/auth", ""); } -if ( ! process.env.EMAIL_FROM ) { - console.warn('\x1b[33mwarn', '\x1b[0m', 'EMAIL_FROM environment variable is not set, this may indicate mailing is currently disabled. Please refer to the .env.example file.'); +if (!process.env.EMAIL_FROM) { + console.warn( + "\x1b[33mwarn", + "\x1b[0m", + "EMAIL_FROM environment variable is not set, this may indicate mailing is currently disabled. Please refer to the .env.example file." + ); } if (process.env.BASE_URL) { - process.env.NEXTAUTH_URL = process.env.BASE_URL + '/api/auth'; + process.env.NEXTAUTH_URL = process.env.BASE_URL + "/api/auth"; } const validJson = (jsonString) => { - try { - const o = JSON.parse(jsonString); - if (o && typeof o === "object") { - return o; - } + try { + const o = JSON.parse(jsonString); + if (o && typeof o === "object") { + return o; } - catch (e) {} - return false; -} + } catch (e) { + console.error(e); + } + return false; +}; -if (process.env.GOOGLE_API_CREDENTIALS && ! validJson(process.env.GOOGLE_API_CREDENTIALS)) { - console.warn('\x1b[33mwarn', '\x1b[0m', "- Disabled 'Google Calendar' integration. Reason: Invalid value for GOOGLE_API_CREDENTIALS environment variable. When set, this value needs to contain valid JSON like {\"web\":{\"client_id\":\"- We hope to see you again soon! -
-We hope to see you again soon!
+- Hide the event type from your page, so it can only be booked through its URL. + Hide the event type from your page, so it can only be booked through it's URL.
diff --git a/pages/integrations/index.tsx b/pages/integrations/index.tsx index 7ddb3c41..544dc65e 100644 --- a/pages/integrations/index.tsx +++ b/pages/integrations/index.tsx @@ -1,387 +1,457 @@ -import Head from 'next/head'; -import Link from 'next/link'; -import prisma from '../../lib/prisma'; -import Shell from '../../components/Shell'; -import {useEffect, useState} from 'react'; -import {getSession, useSession} from 'next-auth/client'; -import {CalendarIcon, CheckCircleIcon, ChevronRightIcon, PlusIcon, XCircleIcon} from '@heroicons/react/solid'; -import {InformationCircleIcon} from '@heroicons/react/outline'; -import {Switch} from '@headlessui/react' +import Head from "next/head"; +import Link from "next/link"; +import prisma from "../../lib/prisma"; +import Shell from "../../components/Shell"; +import { useEffect, useState } from "react"; +import { getSession, useSession } from "next-auth/client"; +import { + CalendarIcon, + CheckCircleIcon, + ChevronRightIcon, + PlusIcon, + XCircleIcon, +} from "@heroicons/react/solid"; +import { InformationCircleIcon } from "@heroicons/react/outline"; +import { Switch } from "@headlessui/react"; export default function Home({ integrations }) { - const [session, loading] = useSession(); - const [showAddModal, setShowAddModal] = useState(false); - const [showSelectCalendarModal, setShowSelectCalendarModal] = useState(false); - const [selectableCalendars, setSelectableCalendars] = useState([]); + const [, loading] = useSession(); + const [showAddModal, setShowAddModal] = useState(false); + const [showSelectCalendarModal, setShowSelectCalendarModal] = useState(false); + const [selectableCalendars, setSelectableCalendars] = useState([]); - function toggleAddModal() { - setShowAddModal(!showAddModal); + function toggleAddModal() { + setShowAddModal(!showAddModal); + } + + function toggleShowCalendarModal() { + setShowSelectCalendarModal(!showSelectCalendarModal); + } + + function loadCalendars() { + fetch("api/availability/calendar") + .then((response) => response.json()) + .then((data) => { + setSelectableCalendars(data); + }); + } + + function integrationHandler(type) { + fetch("/api/integrations/" + type.replace("_", "") + "/add") + .then((response) => response.json()) + .then((data) => (window.location.href = data.url)); + } + + function calendarSelectionHandler(calendar) { + return (selected) => { + const cals = [...selectableCalendars]; + const i = cals.findIndex((c) => c.externalId === calendar.externalId); + cals[i].selected = selected; + setSelectableCalendars(cals); + if (selected) { + fetch("api/availability/calendar", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(cals[i]), + }).then((response) => response.json()); + } else { + fetch("api/availability/calendar", { + method: "DELETE", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(cals[i]), + }).then((response) => response.json()); + } + }; + } + + function getCalendarIntegrationImage(integrationType: string) { + switch (integrationType) { + case "google_calendar": + return "integrations/google-calendar.png"; + case "office365_calendar": + return "integrations/office-365.png"; + default: + return ""; } + } - function toggleShowCalendarModal() { - setShowSelectCalendarModal(!showSelectCalendarModal); - } + function classNames(...classes) { + return classes.filter(Boolean).join(" "); + } - function loadCalendars() { - fetch('api/availability/calendar') - .then((response) => response.json()) - .then(data => { - setSelectableCalendars(data) - }); - } + useEffect(loadCalendars, [integrations]); - function integrationHandler(type) { - fetch('/api/integrations/' + type.replace('_', '') + '/add') - .then((response) => response.json()) - .then((data) => window.location.href = data.url); - } + if (loading) { + return ; + } - function calendarSelectionHandler(calendar) { - return (selected) => { - let cals = [...selectableCalendars]; - let i = cals.findIndex(c => c.externalId === calendar.externalId); - cals[i].selected = selected; - setSelectableCalendars(cals); - if (selected) { - fetch('api/availability/calendar', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(cals[i]) - }).then((response) => response.json()); - } else { - fetch('api/availability/calendar', { - method: 'DELETE', headers: { - 'Content-Type': 'application/json' - }, body: JSON.stringify(cals[i]) - }).then((response) => response.json()); - } - } - } + return ( +{ig.title}
-- {ig.type.endsWith('_calendar') && Calendar Integration} - {ig.type.endsWith('_video') && Video Conferencing} -
-
-
-
- You currently do not have any integrations set up. Add your first integration to get started. -
-- Link a new integration to your account. -
-{ integration.description }
-- Select which calendars are checked for availability to prevent double bookings. -
-- If no entry is selected, all calendars will be checked -
-{ig.title}
++ {ig.type.endsWith("_calendar") && ( + Calendar Integration + )} + {ig.type.endsWith("_video") && ( + Video Conferencing + )} +
+
+
+
+ You currently do not have any integrations set up. Add your first integration to get + started. +
+Link a new integration to your account.
+{integration.description}
+Select which calendars are checked for availability to prevent double bookings.
++ If no entry is selected, all calendars will be checked +
+