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 { Fragment, useState } from 'react'
import { Dialog, Transition } from '@headlessui/react' import { Dialog, Transition } from '@headlessui/react'
import { CheckIcon } from '@heroicons/react/outline' import { CheckIcon } from '@heroicons/react/outline'

View file

@ -1,14 +1,15 @@
import { PrismaClient } from '@prisma/client'; import { PrismaClient } from '@prisma/client';
let prisma: PrismaClient; let prisma: PrismaClient;
const globalAny:any = global;
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient(); prisma = new PrismaClient();
} else { } else {
if (!global.prisma) { if (!globalAny.prisma) {
global.prisma = new PrismaClient(); globalAny.prisma = new PrismaClient();
} }
prisma = global.prisma; prisma = globalAny.prisma;
} }
export default prisma; export default prisma;

View file

@ -84,16 +84,19 @@ export default function Type(props) {
)]; )];
// Handle date change // Handle date change
useEffect(async () => { useEffect(() => {
if(!selectedDate) { const changeDate = async () => {
return 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);
} }
changeDate();
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);
}, [selectedDate]); }, [selectedDate]);

View file

@ -11,7 +11,7 @@ export default function EventType(props) {
const [ session, loading ] = useSession(); const [ session, loading ] = useSession();
const titleRef = useRef<HTMLInputElement>(); const titleRef = useRef<HTMLInputElement>();
const slugRef = useRef<HTMLInputElement>(); const slugRef = useRef<HTMLInputElement>();
const descriptionRef = useRef<HTMLInputElement>(); const descriptionRef = useRef<HTMLTextAreaElement>();
const lengthRef = useRef<HTMLInputElement>(); const lengthRef = useRef<HTMLInputElement>();
const isHiddenRef = useRef<HTMLInputElement>(); const isHiddenRef = useRef<HTMLInputElement>();

View file

@ -17,7 +17,7 @@ export default function Availability(props) {
const [showChangeTimesModal, setShowChangeTimesModal] = useState(false); const [showChangeTimesModal, setShowChangeTimesModal] = useState(false);
const titleRef = useRef<HTMLInputElement>(); const titleRef = useRef<HTMLInputElement>();
const slugRef = useRef<HTMLInputElement>(); const slugRef = useRef<HTMLInputElement>();
const descriptionRef = useRef<HTMLInputElement>(); const descriptionRef = useRef<HTMLTextAreaElement>();
const lengthRef = useRef<HTMLInputElement>(); const lengthRef = useRef<HTMLInputElement>();
const isHiddenRef = useRef<HTMLInputElement>(); const isHiddenRef = useRef<HTMLInputElement>();
@ -42,7 +42,7 @@ export default function Availability(props) {
setShowChangeTimesModal(!showChangeTimesModal); setShowChangeTimesModal(!showChangeTimesModal);
} }
const closeSuccessModal = () => { Router.reload(); } const closeSuccessModal = () => { router.replace(router.asPath); }
function convertMinsToHrsMins (mins) { function convertMinsToHrsMins (mins) {
let h = Math.floor(mins / 60); let h = Math.floor(mins / 60);

View file

@ -15,7 +15,7 @@ export default function Settings(props) {
const [successModalOpen, setSuccessModalOpen] = useState(false); const [successModalOpen, setSuccessModalOpen] = useState(false);
const usernameRef = useRef<HTMLInputElement>(); const usernameRef = useRef<HTMLInputElement>();
const nameRef = useRef<HTMLInputElement>(); const nameRef = useRef<HTMLInputElement>();
const descriptionRef = useRef<HTMLInputElement>(); const descriptionRef = useRef<HTMLTextAreaElement>();
const avatarRef = useRef<HTMLInputElement>(); const avatarRef = useRef<HTMLInputElement>();
const [ selectedTimeZone, setSelectedTimeZone ] = useState({ value: props.user.timeZone }); const [ selectedTimeZone, setSelectedTimeZone ] = useState({ value: props.user.timeZone });