Skip to content

Scheduling infrastructure for absolutely everyone.

Fix a bunch of TypeScript errors

Bailey Pumfleetea3160759890
diff --git a/components/Modal.tsx b/components/Modal.tsx
index 40f1a5a2ee8..658bf7064d7 100644
--- a/components/Modal.tsx
+++ b/components/Modal.tsx
@@ -1,4 +1,3 @@
-/* This example requires Tailwind CSS v2.0+ */
import { Fragment, useState } from 'react'
import { Dialog, Transition } from '@headlessui/react'
import { CheckIcon } from '@heroicons/react/outline'
diff --git a/lib/prisma.ts b/lib/prisma.ts
index 20e4d98c9ab..4d3f847070e 100644
--- a/lib/prisma.ts
+++ b/lib/prisma.ts
@@ -1,14 +1,15 @@
import { PrismaClient } from '@prisma/client';
let prisma: PrismaClient;
+const globalAny:any = global;
if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient();
} else {
- if (!global.prisma) {
- global.prisma = new PrismaClient();
+ if (!globalAny.prisma) {
+ globalAny.prisma = new PrismaClient();
}
- prisma = global.prisma;
+ prisma = globalAny.prisma;
}
export default prisma;
\ No newline at end of file
diff --git a/pages/[user]/[type].tsx b/pages/[user]/[type].tsx
index 8d7fcc8b677..8ca4d5d6cd4 100644
--- a/pages/[user]/[type].tsx
+++ b/pages/[user]/[type].tsx
@@ -84,16 +84,19 @@ export default function Type(props) {
)];
// Handle date change
- useEffect(async () => {
- if(!selectedDate) {
- return
+ useEffect(() => {
+ const changeDate = async () => {
+ if (!selectedDate) {
+ return
+ }
+
+ setLoading(true);
+ const res = await fetch(`/api/availability/${user}?dateFrom=${lowerBound.utc().format()}&dateTo=${upperBound.utc().format()}`);
+ const busyTimes = await res.json();
+ if (busyTimes.length > 0) setBusy(busyTimes);
+ setLoading(false);
}
-
- setLoading(true);
- const res = await fetch(`/api/availability/${user}?dateFrom=${lowerBound.utc().format()}&dateTo=${upperBound.utc().format()}`);
- const busyTimes = await res.json();
- if (busyTimes.length > 0) setBusy(busyTimes);
- setLoading(false);
+ changeDate();
}, [selectedDate]);
diff --git a/pages/availability/event/[type].tsx b/pages/availability/event/[type].tsx
index 007ebcea8b4..89deae62acd 100644
--- a/pages/availability/event/[type].tsx
+++ b/pages/availability/event/[type].tsx
@@ -11,7 +11,7 @@ export default function EventType(props) {
const [ session, loading ] = useSession();
const titleRef = useRef<HTMLInputElement>();
const slugRef = useRef<HTMLInputElement>();
- const descriptionRef = useRef<HTMLInputElement>();
+ const descriptionRef = useRef<HTMLTextAreaElement>();
const lengthRef = useRef<HTMLInputElement>();
const isHiddenRef = useRef<HTMLInputElement>();
diff --git a/pages/availability/index.tsx b/pages/availability/index.tsx
index 2c1163b5708..9369a0b019a 100644
--- a/pages/availability/index.tsx
+++ b/pages/availability/index.tsx
@@ -17,7 +17,7 @@ export default function Availability(props) {
const [showChangeTimesModal, setShowChangeTimesModal] = useState(false);
const titleRef = useRef<HTMLInputElement>();
const slugRef = useRef<HTMLInputElement>();
- const descriptionRef = useRef<HTMLInputElement>();
+ const descriptionRef = useRef<HTMLTextAreaElement>();
const lengthRef = useRef<HTMLInputElement>();
const isHiddenRef = useRef<HTMLInputElement>();
@@ -42,7 +42,7 @@ export default function Availability(props) {
setShowChangeTimesModal(!showChangeTimesModal);
}
- const closeSuccessModal = () => { Router.reload(); }
+ const closeSuccessModal = () => { router.replace(router.asPath); }
function convertMinsToHrsMins (mins) {
let h = Math.floor(mins / 60);
diff --git a/pages/settings/profile.tsx b/pages/settings/profile.tsx
index 76039466f4c..e536f8b1480 100644
--- a/pages/settings/profile.tsx
+++ b/pages/settings/profile.tsx
@@ -15,7 +15,7 @@ export default function Settings(props) {
const [successModalOpen, setSuccessModalOpen] = useState(false);
const usernameRef = useRef<HTMLInputElement>();
const nameRef = useRef<HTMLInputElement>();
- const descriptionRef = useRef<HTMLInputElement>();
+ const descriptionRef = useRef<HTMLTextAreaElement>();
const avatarRef = useRef<HTMLInputElement>();
const [ selectedTimeZone, setSelectedTimeZone ] = useState({ value: props.user.timeZone });