Skip to content

Commit 13e8b90

Browse files
committed
issueCard added
1 parent 5ec549d commit 13e8b90

File tree

5 files changed

+117
-8
lines changed

5 files changed

+117
-8
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
@@ -111,4 +111,8 @@ export const apiRoutes = {
111111
delete: `${baseUrl}/plans/`,
112112
edit: `${baseUrl}/plans/`,
113113
},
114+
issue: {
115+
create: `${baseUrl}/issues/all`,
116+
117+
},
114118
};
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.

0 commit comments

Comments
 (0)