Fix a bunch of TypeScript errors

This commit is contained in:
Bailey Pumfleet 2021-04-29 14:47:01 +01:00
parent 1b7c9cf359
commit ea31607598
6 changed files with 20 additions and 17 deletions

View File

@ -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'

View File

@ -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;

View File

@ -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]);

View File

@ -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>();

View File

@ -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);

View File

@ -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 });