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) {

loading

) - } + } else { return (
@@ -391,5 +391,6 @@ export default function InvoiceTable(props) {
*/} - ) + ) + } } diff --git a/components/SalesTable.tsx b/components/SalesTable.tsx index 4b88095..d519c2a 100644 --- a/components/SalesTable.tsx +++ b/components/SalesTable.tsx @@ -65,7 +65,7 @@ const handleSalesRowClick = (salesPerson) => { window.location.href = `/sales/${salesPerson}` } -const columns: ColumnDef[] = [ +const columns = [ { accessorKey: "name", header: ({ column }) => { diff --git a/components/SellerList.tsx b/components/SellerList.tsx index c0f4aff..a2768cf 100644 --- a/components/SellerList.tsx +++ b/components/SellerList.tsx @@ -60,13 +60,15 @@ export default function SellerList(props) {

- {name && ( -
- Sales People Under - {decodeURIComponent(name)} -
- )} - {!name && <>Manage Sales People} + <> + {name && ( +
+ Sales People Under + {decodeURIComponent(name)} +
+ )} + {!name && <>Manage Sales People} +

diff --git a/components/SetPassword.tsx b/components/SetPassword.tsx index 32a355b..d025bfb 100644 --- a/components/SetPassword.tsx +++ b/components/SetPassword.tsx @@ -1,6 +1,6 @@ "use client" -import React, { useState } from "react" +import React, { FormEvent, useState } from "react" import { useRouter } from "next/navigation" import { Label } from "@radix-ui/react-label" diff --git a/components/datatable.tsx b/components/datatable.tsx index 480304e..0d396d7 100644 --- a/components/datatable.tsx +++ b/components/datatable.tsx @@ -346,7 +346,7 @@ export default function DataTable(props) { - {!role === "Admin-IA" || + {!(role === "Admin-IA") || (role == "SuperAdmin" && ( } - + )} + {Role && ( <> diff --git a/components/superAdmin/TotalClients.tsx b/components/superAdmin/TotalClients.tsx index 0676795..5b1c3c5 100644 --- a/components/superAdmin/TotalClients.tsx +++ b/components/superAdmin/TotalClients.tsx @@ -1,5 +1,5 @@ "use client" -import React, { useState } from "react" +import React, { useEffect, useState } from "react" import { fetchProjectsBySales } from "@/lib/fetchProjects" diff --git a/components/superAdmin/TotalEarning.tsx b/components/superAdmin/TotalEarning.tsx index e28da01..576d202 100644 --- a/components/superAdmin/TotalEarning.tsx +++ b/components/superAdmin/TotalEarning.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from "react" -import {InvoiceByUserId} from "/lib/fetchInvoices" +import { InvoiceByUserId } from "@/lib/fetchInvoices" export default function TotalEarning(props) { const userId = props.userId const [invoices, setInvoices] = useState(0) diff --git a/components/superAdmin/TotalProject.tsx b/components/superAdmin/TotalProject.tsx index 3a7ab19..bc5b9e3 100644 --- a/components/superAdmin/TotalProject.tsx +++ b/components/superAdmin/TotalProject.tsx @@ -1,5 +1,5 @@ "use client" -import React, { useState } from "react" +import React, { useEffect, useState } from "react" export default function TotalEarning(props) { const [count, setcount] = useState() diff --git a/package-lock.json b/package-lock.json index 41867bb..3a11a00 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,7 +41,7 @@ "clsx": "^1.2.1", "cmdk": "^0.2.0", "date-fns": "^2.30.0", - "js-cookie": "^3.0.5", + "js-cookie": "^3.0.8", "lucide": "^0.356.0", "lucide-react": "^0.263.1", "mongoose": "^7.4.2", @@ -67,6 +67,7 @@ }, "devDependencies": { "@ianvs/prettier-plugin-sort-imports": "^3.7.2", + "@types/js-cookie": "^3.0.6", "@types/node": "^17.0.45", "@types/react": "^18.2.14", "@types/react-dom": "^18.2.6", @@ -3247,6 +3248,13 @@ "resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-2.3.4.tgz", "integrity": "sha512-xdDXbpVO74EvadI3UDxjxTdR6QIxm1FKzEA/+F8tL4GWWUg/hgvBqf6chql64U5A9ZUGWo7pEu4eNlyLwbKdhg==" }, + "node_modules/@types/js-cookie": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-3.0.6.tgz", + "integrity": "sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", diff --git a/package.json b/package.json index d341ed5..0958783 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ }, "devDependencies": { "@ianvs/prettier-plugin-sort-imports": "^3.7.2", + "@types/js-cookie": "^3.0.6", "@types/node": "^17.0.45", "@types/react": "^18.2.14", "@types/react-dom": "^18.2.6",