diff --git a/components/ui/Switch.tsx b/components/ui/Switch.tsx
new file mode 100644
index 00000000..ad2b415a
--- /dev/null
+++ b/components/ui/Switch.tsx
@@ -0,0 +1,41 @@
+import { useState } from "react";
+import * as PrimitiveSwitch from "@radix-ui/react-switch";
+import * as Label from "@radix-ui/react-label";
+
+function classNames(...classes) {
+ return classes.filter(Boolean).join(" ");
+}
+
+export default function Switch(props) {
+ const { label, onCheckedChange, ...primitiveProps } = props;
+ const [checked, setChecked] = useState(props.defaultChecked || false);
+
+ const onPrimitiveCheckedChange = (change: boolean) => {
+ if (onCheckedChange) {
+ onCheckedChange(change);
+ }
+ setChecked(change);
+ };
+
+ return (
+
+
+
+
+ {label && (
+
+ {label}
+
+ )}
+
+ );
+}
diff --git a/package.json b/package.json
index 6e151e85..a25a020f 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
"@radix-ui/react-collapsible": "^0.0.16",
"@radix-ui/react-dialog": "^0.0.19",
"@radix-ui/react-slot": "^0.0.12",
+ "@radix-ui/react-switch": "^0.0.15",
"@radix-ui/react-tooltip": "^0.0.21",
"@tailwindcss/forms": "^0.2.1",
"async": "^3.2.0",
diff --git a/pages/integrations/index.tsx b/pages/integrations/index.tsx
index 2b318e02..322d8dfc 100644
--- a/pages/integrations/index.tsx
+++ b/pages/integrations/index.tsx
@@ -6,10 +6,9 @@ import { useEffect, useState } from "react";
import { getSession, useSession } from "next-auth/client";
import { CheckCircleIcon, ChevronRightIcon, PlusIcon, XCircleIcon } from "@heroicons/react/solid";
import { InformationCircleIcon } from "@heroicons/react/outline";
-import { Switch } from "@headlessui/react";
-import Loader from "@components/Loader";
-import classNames from "@lib/classNames";
import { Dialog, DialogClose, DialogContent, DialogHeader, DialogTrigger } from "@components/Dialog";
+import Switch from "@components/ui/Switch";
+import Loader from "@components/Loader";
export default function IntegrationHome({ integrations }) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -32,17 +31,15 @@ export default function IntegrationHome({ integrations }) {
function calendarSelectionHandler(calendar) {
return (selected) => {
- const cals = [...selectableCalendars];
- const i = cals.findIndex((c) => c.externalId === calendar.externalId);
- cals[i].selected = selected;
- setSelectableCalendars(cals);
+ const i = selectableCalendars.findIndex((c) => c.externalId === calendar.externalId);
+ selectableCalendars[i].selected = selected;
if (selected) {
fetch("api/availability/calendar", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
- body: JSON.stringify(cals[i]),
+ body: JSON.stringify(selectableCalendars[i]),
}).then((response) => response.json());
} else {
fetch("api/availability/calendar", {
@@ -50,7 +47,7 @@ export default function IntegrationHome({ integrations }) {
headers: {
"Content-Type": "application/json",
},
- body: JSON.stringify(cals[i]),
+ body: JSON.stringify(selectableCalendars[i]),
}).then((response) => response.json());
}
};
@@ -67,6 +64,10 @@ export default function IntegrationHome({ integrations }) {
}
}
+ function onCloseSelectCalendar() {
+ setSelectableCalendars([...selectableCalendars]);
+ }
+
useEffect(loadCalendars, [integrations]);
if (loading) {
@@ -116,7 +117,7 @@ export default function IntegrationHome({ integrations }) {
);
const SelectCalendarDialog = () => (
-