Skip to content

Commit 9280fd3

Browse files
committed
2 parents e8a4e1c + 6864113 commit 9280fd3

File tree

18 files changed

+463
-30
lines changed

18 files changed

+463
-30
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from 'react';
2+
3+
// Define the Issue type
4+
type Issue = {
5+
issueType: string;
6+
description: string;
7+
latitude: string;
8+
longitude: string;
9+
isAnonymous: string;
10+
};
11+
12+
13+
14+
const IssueCard: React.FC<Issue> = ({ issueType, description, latitude, longitude }) => {
15+
return (
16+
<div id="alert-additional-content-1" className="p-4 mb-4 text-blue-800 border border-blue-300 rounded-lg bg-blue-50 dark:bg-gray-800 dark:text-blue-400 dark:border-blue-800" role="alert">
17+
<div className="flex items-center">
18+
<svg className="flex-shrink-0 w-4 h-4 me-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
19+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
20+
</svg>
21+
<span className="sr-only">Info</span>
22+
<h3 className="text-lg font-medium">{issueType}</h3>
23+
</div>
24+
<div className="mt-2 mb-4 text-sm">
25+
{description}
26+
</div>
27+
<div className="flex">
28+
<button type="button" className="text-white bg-blue-800 hover:bg-blue-900 focus:ring-4 focus:outline-none focus:ring-blue-200 font-medium rounded-lg text-xs px-3 py-1.5 me-2 text-center inline-flex items-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
29+
<svg className="me-2 h-3 w-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 14">
30+
<path d="M10 0C4.612 0 0 5.336 0 7c0 1.742 3.546 7 10 7 6.454 0 10-5.258 10-7 0-1.664-4.612-7-10-7Zm0 10a3 3 0 1 1 0-6 3 3 0 0 1 0 6Z"/>
31+
</svg>
32+
View more
33+
</button>
34+
<button type="button" className="text-blue-800 bg-transparent border border-blue-800 hover:bg-blue-900 hover:text-white focus:ring-4 focus:outline-none focus:ring-blue-200 font-medium rounded-lg text-xs px-3 py-1.5 text-center dark:hover:bg-blue-600 dark:border-blue-600 dark:text-blue-400 dark:hover:text-white dark:focus:ring-blue-800" data-dismiss-target="#alert-additional-content-1" aria-label="Close">
35+
Dismiss
36+
</button>
37+
</div>
38+
</div>
39+
);
40+
};
41+
42+
export default IssueCard;

client/components/dashboard-componenets/mainContent/systemAdminContents/Workforce.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Button } from "@/components/ui/button";
2+
import * as React from "react";
23
import EmptyFillContainer from "../../cards/EmptyFillContainer";
34
import { Plus, Trash, Truck, Warehouse } from "lucide-react";
45
import ContractLists from "@/components/dataTables/ContractLists";
@@ -8,8 +9,17 @@ import { AddNewContractorManager } from "@/components/modals/ContractorControl/A
89
import CleanerLists from "@/components/dataTables/CleanerList";
910
import { AddNewCleaner } from "@/components/modals/cleanerControl/AddNewCleaner";
1011
import CleanerLog from "@/components/dataTables/CleanerLog";
12+
import useGetIssue from "@/hooks/issues/useGetIssue";
13+
import IssueCard from "../../cards/IssueCard";
14+
1115

1216
export default function AdminWorkforcePanel() {
17+
const { issueData, getAllIssue } = useGetIssue();
18+
19+
React.useEffect(() => {
20+
getAllIssue();
21+
}, []);
22+
1323
return (
1424
<main className="flex flex-1 flex-col gap-4 p-4 lg:gap-6 lg:p-6 max-h-[calc(100vh-60px)] overflow-scroll">
1525
<div className="flex items-center justify-between">
@@ -38,9 +48,21 @@ export default function AdminWorkforcePanel() {
3848
</EmptyFillContainer>
3949
</div>
4050
<div className="md:col-span-2 min-h-48">
41-
<EmptyFillContainer>
51+
{/* <EmptyFillContainer>
4252
<CleanerLog />
43-
</EmptyFillContainer>
53+
</EmptyFillContainer> */}
54+
<div>
55+
{issueData.map((issue, index) => (
56+
<IssueCard
57+
key={index}
58+
issueType={issue.issueType}
59+
description={issue.description}
60+
latitude={issue.latitude}
61+
longitude={issue.longitude}
62+
isAnonymous={issue.isAnonymous}
63+
/>
64+
))}
65+
</div>
4466
</div>
4567
</div>
4668
</div>

client/data/apiRoutes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,8 @@ export const apiRoutes = {
113113
delete: `${baseUrl}/plans/`,
114114
edit: `${baseUrl}/plans/`,
115115
},
116+
issue: {
117+
create: `${baseUrl}/issues/all`,
118+
119+
},
116120
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { apiRoutes } from "@/data/apiRoutes";
2+
import { jwtToken } from "@/data/cookieNames";
3+
import { message } from "antd";
4+
import axios from "axios";
5+
import { useState } from "react";
6+
import { getCookie } from "@/lib/cookieFunctions";
7+
8+
type Issue = {
9+
issueType: string;
10+
description: string;
11+
latitude: string;
12+
longitude: string;
13+
isAnonymous: string;
14+
};
15+
16+
export default function useGetIssue() {
17+
const [issueData, setIssueData] = useState<Issue[]>([]);
18+
19+
async function getAllIssue() {
20+
try {
21+
const token = await getCookie(jwtToken);
22+
const res = await axios.get(apiRoutes.issue.create, {
23+
headers: {
24+
Authorization: `Bearer ${token}`,
25+
},
26+
});
27+
const allIssues: Issue[] = res.data.map((issue: any) => ({
28+
issueType: issue.issueType,
29+
description: issue.description,
30+
latitude: issue.latitude,
31+
longitude: issue.longitude,
32+
isAnonymous: issue.isAnonymous,
33+
}));
34+
35+
setIssueData(allIssues);
36+
37+
return allIssues;
38+
} catch (error: any) {
39+
message.error(
40+
(error?.response?.data?.message || "Error fetching issue data.") +
41+
" Are you authorized?"
42+
);
43+
}
44+
}
45+
46+
return { issueData, getAllIssue };
47+
}

server/.env.example

Lines changed: 0 additions & 6 deletions
This file was deleted.

server/src/controllers/tracking.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,20 @@ const track = (io: Server) => {
1717
handleSts(socket);
1818
} else if (connectionType == "landfill") {
1919
handleLandfill(socket);
20+
} else if (connectionType == "citizen") {
21+
// handleCitizen(socket);
2022
}
2123
});
2224
};
2325

26+
// const handleCitizen = (socket: Socket) => {
27+
28+
// socket.on("join_rooms", async (data) => {
29+
// socket.join("notification");
30+
// }
31+
32+
// }
33+
2434
const handleSts = (socket: Socket) => {
2535
const id = socket.handshake.query.id;
2636

server/src/routes/logs.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
import express from "express";
22
import { getAdminLogs, getContractorManagerLogs } from "../controllers/logs";
3+
import { adminLog, contractorLog } from "../services/logdata";
34
const router = express.Router();
45

6+
router.route("/checkin").post((req, res) => {
7+
const { flag } = req.body;
8+
9+
if (flag) {
10+
adminLog("Checkin", "Shawon Majid has checked in");
11+
contractorLog("Checkin", "Shawon Majid has checked in");
12+
} else {
13+
contractorLog("Checkin", "Shawon Majid has checked in");
14+
adminLog("Checkout", "Shawon Majid has checked out");
15+
}
16+
17+
res.status(200).json({ message: "Checkin status updated" });
18+
});
519
router.route("/admin").get(getAdminLogs);
620
router.route("/contractor").get(getContractorManagerLogs);
721

waste_management/lib/constants/theming.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const kBackgroundColor = Color.fromRGBO(232, 223, 202, 1);
44
const kPrimaryColor = Color.fromRGBO(26, 77, 46, 1);
55
const ksecondaryHeaderColor = Color.fromRGBO(245, 239, 230, 1);
66
const kPrimaryLightColor = Color.fromRGBO(79, 111, 82, 1);
7-
String uri= 'http://10.42.0.238:8585'; //10.42.0.107
7+
String uri= 'http://192.168.1.109:8585'; //10.42.0.107
88

99
const appBarGradient = LinearGradient(
1010
colors: [

waste_management/lib/models/issueModel.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class Issue {
55
final String description;
66
final String latitude;
77
final String longitude;
8+
final bool isAnonymous;
89

910
Issue({
1011
required this.id,
@@ -13,6 +14,7 @@ class Issue {
1314
required this.description,
1415
required this.latitude,
1516
required this.longitude,
17+
required this.isAnonymous
1618
});
1719
}
1820

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'package:flutter/material.dart';
2+
3+
class NotificationScreen extends StatefulWidget {
4+
const NotificationScreen({super.key});
5+
6+
@override
7+
State<NotificationScreen> createState() => _NotificationScreenState();
8+
}
9+
10+
class _NotificationScreenState extends State<NotificationScreen> {
11+
@override
12+
Widget build(BuildContext context) {
13+
return Scaffold(
14+
body: Center(child: Text("You have no notification right now")),
15+
);
16+
}
17+
}

0 commit comments

Comments
 (0)