diff --git a/app/dashboard/DashboardClient.tsx b/app/dashboard/DashboardClient.tsx index 7b56d59..fadee2a 100644 --- a/app/dashboard/DashboardClient.tsx +++ b/app/dashboard/DashboardClient.tsx @@ -1,5 +1,5 @@ "use client" -import { useEffect } from "react" +import { useEffect, useState } from "react" import { useSession } from "next-auth/react" import { fetchInvoices } from "@/lib/fetchInvoices" import { fetchProjects } from "@/lib/fetchProjects" @@ -15,6 +15,14 @@ export default function DashboardPage() { const role = session?.user?.role const username = session?.user?.name + // TODO: The data is now set correctly to avoid runtime errors if hit, but the use of the data itself may be plausible to review + const [completedProject, setCompletedProject] = useState() + const [pendingProject, setPendingProject] = useState() + const [clientName, setClientName] = useState() + const [data, setData] = useState() + const [loading, setLoading] = useState(true) + const [totalEarn, setTotalEarn] = useState() + useEffect(() => { if (session && role == "Sales2") { fetchProjects() @@ -41,9 +49,9 @@ export default function DashboardPage() { } }) - setcompletedproject(completedproject) - setclientName(uniqueClientNames) - setpendingProject(pendingProjects) + setCompletedProject(completedproject) + setClientName(uniqueClientNames) + setPendingProject(pendingProjects) setData(filteredData) setLoading(false) } @@ -67,7 +75,7 @@ export default function DashboardPage() { 0 ) - settotalEarn(total) + setTotalEarn(total) } }) .catch((error) => { diff --git a/components/CropImage.tsx b/components/CropImage.tsx index 0dee529..4df0343 100644 --- a/components/CropImage.tsx +++ b/components/CropImage.tsx @@ -28,8 +28,8 @@ const CropImage = ({file,setResult}) => { getCroppedImg(image, crop, 'profile.jpeg') } } - - const getCroppedImg = () => { + + const getCroppedImg = (image, crop, fileName) => { if (image && crop) { const canvas = document.createElement('canvas'); const scaleX = image.naturalWidth / image.width; diff --git a/components/Editinvoice.tsx b/components/Editinvoice.tsx index 4370a1e..38f7a7b 100644 --- a/components/Editinvoice.tsx +++ b/components/Editinvoice.tsx @@ -1,6 +1,6 @@ "use client" -import React, { useEffect, useState } from "react" +import React, { FormEvent, useEffect, useState } from "react" import { useRouter } from "next/navigation" import { format } from "date-fns" import { diff --git a/components/InvoiceTable.tsx b/components/InvoiceTable.tsx index 866ff35..bc73e7a 100644 --- a/components/InvoiceTable.tsx +++ b/components/InvoiceTable.tsx @@ -313,7 +313,7 @@ export default function InvoiceTable(props) {