Skip to content

Commit 79ad58d

Browse files
committed
fixed dashboard for no sts assigned
1 parent b5382f8 commit 79ad58d

File tree

3 files changed

+54
-24
lines changed

3 files changed

+54
-24
lines changed

client/app/dashboard/page.tsx

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,60 @@
33
import { NavContext } from "@/hooks/contexts/useNavCtx";
44
import { useContext, useEffect, useState } from "react";
55
import Sidebar from "../../components/dashboard-componenets/sidebar/Sidebar";
6-
import { admin , landfillManager, stsManager, unassigned } from "@/data/roles";
6+
import { admin, landfillManager, stsManager, unassigned } from "@/data/roles";
77
import MainSection from "../../components/dashboard-componenets/mainContent/mainSection";
88
import { useRouter } from "next/navigation";
99
import { getCookie } from "@/lib/cookieFunctions";
10-
import { curActive, role } from "@/data/cookieNames";
10+
import { curActive, role, stsId, username, landfillId } from "@/data/cookieNames";
1111
import { set } from "react-hook-form";
12+
import AppLogo from "../auth/login/AppLogo";
1213

1314
export default function Dashboard() {
14-
1515
const [curRole, setCurrentRole] = useState("");
1616
const [currentActive, setCurrentActive] = useState("");
1717
const router = useRouter();
18-
18+
1919
useEffect(() => {
2020
setCurrentRole(getCookie(role));
2121
setCurrentActive(getCookie(curActive));
2222
}, []);
2323

2424
//console.log('Role: ' + curRole + ' Current Active: ' + currentActive);
25-
25+
2626
return (
27-
<div className="grid min-h-screen w-full md:grid-cols-[220px_1fr] lg:grid-cols-[280px_1fr]">
28-
<NavContext.Provider value={{currentActive, setCurrentActive}}>
29-
<Sidebar role={curRole}/>
30-
<MainSection role={curRole}/>
31-
</ NavContext.Provider>
27+
<div className="grid min-h-screen w-full md:grid-cols-[220px_1fr] lg:grid-cols-[280px_1fr]">
28+
<NavContext.Provider value={{ currentActive, setCurrentActive }}>
29+
{(curRole === stsManager && getCookie(stsId) === "") || (curRole === landfillManager && getCookie(landfillId) === "") ? (
30+
<>
31+
<div className="w-screen h-screen flex flex-col justify-center items-center text gap-4">
32+
<div className="h-24 w-24 only:md:h-32 md:w-32 mb-4">
33+
<AppLogo />
34+
</div>
35+
<h1 className="text-xl sm:text-xl lg:text-3xl font-semibold">
36+
Welcome {getCookie(username)}
37+
</h1>
38+
<h1 className="text-2xl sm:text-3xl lg:text-5xl font-bold">
39+
You are not assigned to any {curRole === stsManager ? "STS" : "Landfill"}
40+
</h1>
41+
<h1 className="text-md sm:text-lg lg:text-2xl">
42+
Contact admin for being assigned to a {curRole === stsManager ? "STS" : "Landfill"}
43+
</h1>
44+
<button
45+
onClick={() => router.push("/auth/login")}
46+
className="bg-[#1A4D2E] text-white font-semibold px-4 py-2 rounded-md"
47+
>
48+
Logout
49+
</button>
50+
</div>
51+
</>
52+
) : (
53+
<>
54+
<Sidebar role={curRole} />
55+
<MainSection role={curRole} />
56+
</>
57+
)}
58+
59+
</NavContext.Provider>
3260
</div>
3361
);
3462
}

client/app/page.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import Hero from "@/components/Homepage/Hero";
22
import Navbar from "@/components/Homepage/Navbar";
3-
import Image from "next/image";
4-
import SectionTitle from "@/components/Homepage/SectionTitle";import Benifit from "@/components/Homepage/Benifit";
3+
import SectionTitle from "@/components/Homepage/SectionTitle";
4+
import Benifit from "@/components/Homepage/Benifit";
55
import Deliverable from "@/components/Homepage/Deliverables";
66
import Teamintro from "@/components/Homepage/Teamintro";
7-
;
87

98
export default function Home() {
109
return (
1110
<main className="bg-[#EEF7FC]">
12-
<Navbar/>
11+
<Navbar />
1312
<Hero />
1413
<SectionTitle
1514
pretitle="EcoSync Benefits"
16-
title=" Why should you use this EcoSync Software">
17-
Our dashboard empowers Dhaka South City Corporation to allocate resources more effectively,
18-
optimizing manpower and equipment utilization for waste management tasks, thus fostering operational efficiency, reducing operational costs,
19-
and ultimately leading to a cleaner, more sustainable urban environment.
15+
title=" Why should you use this EcoSync Software"
16+
>
17+
Our dashboard empowers Dhaka South City Corporation to allocate
18+
resources more effectively, optimizing manpower and equipment
19+
utilization for waste management tasks, thus fostering operational
20+
efficiency, reducing operational costs, and ultimately leading to a
21+
cleaner, more sustainable urban environment.
2022
</SectionTitle>
2123
<Benifit />
22-
<Deliverable/>
23-
<Teamintro/>
24-
24+
<Deliverable />
25+
<Teamintro />
2526
</main>
2627
);
27-
}
28-
// /<Image src="/logo.png" alt="EcoSync" width={200} height={200} />
28+
}

server/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"main": "index.js",
66
"scripts": {
77
"build": "tsc",
8+
"install": "cd ./src && npx prisma migrate dev --name init && createdb ecosync 2> /dev/null || echo 'database already exists'",
89
"start": "node build/index.js",
910
"dev": "ts-node src/index.ts",
10-
"test": "echo \"Error: no test specified\" && exit 1"
11+
"test": "echo \"Error: no test specified\" && exit 1",
12+
"prisma": "npx prisma generate && npx prisma migrate dev"
1113
},
1214
"keywords": [],
1315
"author": "",

0 commit comments

Comments
 (0)