diff --git a/client/app/auth/change-password/page.tsx b/client/app/auth/change-password/page.tsx index 20d3edb..26bae76 100644 --- a/client/app/auth/change-password/page.tsx +++ b/client/app/auth/change-password/page.tsx @@ -13,6 +13,7 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import useChangePass from "@/hooks/auth/useChangePass"; import { setCookie } from "@/lib/cookieFunctions"; +import { message } from "antd"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useEffect, useState } from "react"; @@ -34,7 +35,7 @@ export default function ChangePassword() { setTime((time) => { if (time === 0) { clearInterval(timer); - alert("Time Expired!"); + message.error("Time Expired!"); router.push("/dashboard"); return 0; } else return time - 0.5; @@ -45,7 +46,7 @@ export default function ChangePassword() { async function submitForm() { isVerified && (await changePass()) && router.push("/dashboard"); - !isVerified && alert("Invalid Captcha!"); + !isVerified && message.error("Invalid Captcha!"); } return ( diff --git a/client/app/auth/reset-password/initiate/forgetPasswordInitiate.tsx b/client/app/auth/reset-password/initiate/forgetPasswordInitiate.tsx index bcf9fff..cda4588 100644 --- a/client/app/auth/reset-password/initiate/forgetPasswordInitiate.tsx +++ b/client/app/auth/reset-password/initiate/forgetPasswordInitiate.tsx @@ -9,6 +9,7 @@ import { useRouter } from "next/navigation"; import useForgetPassInitiate from "@/hooks/auth/useForgetPassInitiate"; import { useContext, useState } from "react"; import ReCAPTCHA from "react-google-recaptcha"; +import { message } from "antd"; function ForgetPassInitiateForm() { const { userEmail, setUserEmail, initiate } = useForgetPassInitiate(); @@ -18,7 +19,7 @@ function ForgetPassInitiateForm() { async function handleFormSubmit(e: React.FormEvent) { e.preventDefault(); if (!isCaptchaVerified) { - alert("Please verify that you are not a robot."); + message.warning("Please verify that you are not a robot."); return; } const success = await initiate(); diff --git a/client/app/layout.tsx b/client/app/layout.tsx index 50115ac..8ce03a3 100644 --- a/client/app/layout.tsx +++ b/client/app/layout.tsx @@ -13,7 +13,7 @@ export const metadata: Metadata = { title: "EcoSync", description: "EcoSync is a platform for managing waste in DNCC.", icons: { - icon: "/logo.png", + icon: "/logoBlack.png", }, }; diff --git a/client/app/profile/page.tsx b/client/app/profile/page.tsx index 81dde4e..9e18775 100644 --- a/client/app/profile/page.tsx +++ b/client/app/profile/page.tsx @@ -7,7 +7,7 @@ import { PersonIcon } from "@radix-ui/react-icons"; import { useParams } from "next/navigation"; import { useRouter } from "next/navigation"; import { EditIcon, Factory, CircleUser } from "lucide-react"; -import {useEffect, useState} from "react"; +import { useEffect, useState } from "react"; import { ProfileEditModal } from "@/components/modals/ProfileEditModal"; import useGetAllRole from "@/hooks/user_data/useGetAllRole"; import { UpdateStsStorage } from "@/components/modals/stsControl/updateSTSStorage"; @@ -16,34 +16,33 @@ import { UpdateLandfillStorageModal } from "@/components/modals/landfillControl/ type RolesWithPermisson = { id: string; name: string; - permissions: [{ - name: string; - description: string; -}] + permissions: [ + { + name: string; + description: string; + } + ]; }; - export default function ProfilePage() { - const router = useRouter(); - const { user, stsDetails, landfillDetails, getUserDetails} = useGetUserProfile(); // Destructure user and getUserDetails + const { user, stsDetails, landfillDetails, getUserDetails } = + useGetUserProfile(); // Destructure user and getUserDetails const [role, setRole] = useState("Role Name"); // const [permissions, setPermissions] = useState([]); - const RolePlace = 'Station'; + const RolePlace = "Station"; const { fetchAllRoles, roles, rolesWithPermissions } = useGetAllRole(); useEffect(() => { const fetchData = async () => { await getUserDetails(); await fetchAllRoles(); - + setRole(user.roleName); }; - - fetchData(); + fetchData(); }, []); - return (
@@ -55,129 +54,212 @@ export default function ProfilePage() { Back to Dashboard
- {user.roleName} + {user.roleName} +
-
- - - - - -

Profile Page

-
- {/*

ID: {user.id}

*/} -

Email: {user.email}

-

Role: {user.roleName}

-

Profile Name: {user.profileName}

-

Username: {user.username}

-

Role Description: {user.roleDescription}

-
- - -
- - -
- - - - {user?.roleName === 'STS_MANAGER' && stsDetails?.stsId?.toString().length > 1 &&
-
STS Details
-

Id: {stsDetails.stsId}

-

STS Name: {stsDetails.stsName}

-

Ward Number: {stsDetails.stsWardNumber}

-

Capacity: {stsDetails.stsCapacity}

-

Current Total Waste: {stsDetails.stsCurrentTotalWaste}

-

Coordinate: {stsDetails.stsLatitude}, {stsDetails.stsLongitude}

- - +
+ + + + + +

Profile Page

+
+ {/*

ID: {user.id}

*/} +

+ Email: + {user.email} +

+

+ Role: + {user.roleName} +

+

+ Profile Name: + {user.profileName} +

+

+ Username: + {user.username} +

+

+ Role Description: + {user.roleDescription} +

+
+
- - - } -{user?.roleName === 'STS_MANAGER' && stsDetails?.stsId?.toString().length < 1 &&
-
STS Not Assigned
- Call your admin to assign your STS. -
- } -{user?.roleName === 'STS_MANAGER' && rolesWithPermissions.some(role => role.name === 'STS_MANAGER') && ( -
-

Land Manager Permissions:

-
- {rolesWithPermissions - .find(role => role.name === 'STS_MANAGER') - ?.permissions.map(permission => ( -
-
{permission.name}:
-
{permission.description}
-
- ))} -
-
-)} +
+ + {user?.roleName === "STS_MANAGER" && + stsDetails?.stsId?.toString().length > 1 && ( +
+
STS Details
+

+ Id: + {stsDetails.stsId} +

+

+ STS Name: + {stsDetails.stsName} +

+

+ Ward Number: + {stsDetails.stsWardNumber} +

+

+ Capacity: + {stsDetails.stsCapacity} +

+

+ Current Total Waste: + {stsDetails.stsCurrentTotalWaste} +

+

+ Coordinate: + {stsDetails.stsLatitude}, {stsDetails.stsLongitude} +

+
+ )} - {user?.roleName === 'LAND_MANAGER' && landfillDetails?.landfillId?.toString().length > 1 &&
-
Landfill Details
-

ID: {landfillDetails.landfillId}

-

Landfill Name: {landfillDetails.landFillName}

-

Capacity: {landfillDetails.landFillCapacity}

-

Current Total Waste: {landfillDetails.landFillCurrentWaste}

-

Coordinate: {landfillDetails.landfillLatitude}, {landfillDetails.landFillLongitude}

- -
} + {user?.roleName === "STS_MANAGER" && + stsDetails?.stsId?.toString().length < 1 && ( +
+
STS Not Assigned
+ Call your admin to assign your STS. +
+ )} + {user?.roleName === "STS_MANAGER" && + rolesWithPermissions.some( + (role) => role.name === "STS_MANAGER" + ) && ( +
+

+ Land Manager Permissions: +

+
+ {rolesWithPermissions + .find((role) => role.name === "STS_MANAGER") + ?.permissions.map((permission) => ( +
+
+ {permission.name}: +
+
{permission.description}
+
+ ))} +
+
+ )} - {user?.roleName === 'LAND_MANAGER' && landfillDetails?.landfillId?.toString().length < 1 && ( -
-
LandFill Not Assigned
- Call your admin to assign your Landfill. -
- )} + {user?.roleName === "LAND_MANAGER" && + landfillDetails?.landfillId?.toString().length > 1 && ( +
+
Landfill Details
+

+ ID: + {landfillDetails.landfillId} +

+

+ Landfill Name: + {landfillDetails.landFillName} +

+

+ Capacity: + {landfillDetails.landFillCapacity} +

+

+ Current Total Waste: + {landfillDetails.landFillCurrentWaste} +

+

+ Coordinate: + {landfillDetails.landfillLatitude},{" "} + {landfillDetails.landFillLongitude} +

+
+ )} -{user?.roleName === 'LAND_MANAGER' && rolesWithPermissions.some(role => role.name === 'LAND_MANAGER') && ( -
-

Land Manager Permissions:

-
- {rolesWithPermissions - .find(role => role.name === 'LAND_MANAGER') - ?.permissions.map(permission => ( -
-
{permission.name}:
-
{permission.description}
-
- ))} -
-
-)} + {user?.roleName === "LAND_MANAGER" && + landfillDetails?.landfillId?.toString().length < 1 && ( +
+
+ LandFill Not Assigned +
+ Call your admin to assign your Landfill. +
+ )} - {user?.roleName === 'SYSTEM_ADMIN' &&
-
Admin
-
You are admin
-
} - {user?.roleName !== 'STS_MANAGER' && user?.roleName !== 'LAND_MANAGER' && user?.roleName !== 'SYSTEM_ADMIN' && ( -
Wait! Your role has not assigned yet
- )} + {user?.roleName === "LAND_MANAGER" && + rolesWithPermissions.some( + (role) => role.name === "LAND_MANAGER" + ) && ( +
+

+ Land Manager Permissions: +

+
+ {rolesWithPermissions + .find((role) => role.name === "LAND_MANAGER") + ?.permissions.map((permission) => ( +
+
+ {permission.name}: +
+
{permission.description}
+
+ ))} +
+
+ )} -{user?.roleName === 'SYSTEM_ADMIN' && rolesWithPermissions.some(role => role.name === 'SYSTEM_ADMIN') && ( -
-

System Admin Permissions:

-
- {rolesWithPermissions - .find(role => role.name === 'SYSTEM_ADMIN') - ?.permissions.map(permission => ( -
-
{permission.name}:
-
{permission.description}
-
- ))} -
-
-)} + {user?.roleName === "SYSTEM_ADMIN" && ( +
+
Admin
+
You are admin
+
+ )} + {user?.roleName !== "STS_MANAGER" && + user?.roleName !== "LAND_MANAGER" && + user?.roleName !== "SYSTEM_ADMIN" && ( +
Wait! Your role has not assigned yet
+ )} - -
+ {user?.roleName === "SYSTEM_ADMIN" && + rolesWithPermissions.some( + (role) => role.name === "SYSTEM_ADMIN" + ) && ( +
+

+ System Admin Permissions: +

+
+ {rolesWithPermissions + .find((role) => role.name === "SYSTEM_ADMIN") + ?.permissions.map((permission) => ( +
+
+ {permission.name}: +
+
{permission.description}
+
+ ))} +
+
+ )} +
); diff --git a/client/components/dashboard-componenets/mainContent/landFillManagerContents/DumpEntry.tsx b/client/components/dashboard-componenets/mainContent/landFillManagerContents/DumpEntry.tsx index 4129fb1..b3e81c7 100644 --- a/client/components/dashboard-componenets/mainContent/landFillManagerContents/DumpEntry.tsx +++ b/client/components/dashboard-componenets/mainContent/landFillManagerContents/DumpEntry.tsx @@ -6,6 +6,7 @@ import LandFillDeliveredVehicles from "../../../dataTables/LandFillDeliveredVehi import { AllStsMapShow } from "@/components/maps/AllStsShow"; import { Button } from "@/components/ui/button"; import { Cog, LogOut } from "lucide-react"; +import { UpdateLandfillStorageModal } from "@/components/modals/landfillControl/updateLandfillStorage"; export default function LandfillManagerDumpEntries() { @@ -14,13 +15,10 @@ export default function LandfillManagerDumpEntries() {
-

DUMP ENTRIES

+

Bills

- +
@@ -36,7 +34,7 @@ export default function LandfillManagerDumpEntries() {
- + ); } diff --git a/client/components/dashboard-componenets/mainContent/landFillManagerContents/Storage.tsx b/client/components/dashboard-componenets/mainContent/landFillManagerContents/Storage.tsx index 32a7f06..b296a72 100644 --- a/client/components/dashboard-componenets/mainContent/landFillManagerContents/Storage.tsx +++ b/client/components/dashboard-componenets/mainContent/landFillManagerContents/Storage.tsx @@ -23,8 +23,7 @@ export default function LandfillManagerStorageData() { getLandfillDatabyID(getCookie(landfillId)) }, []); - useEffect(() => { - // alert(JSON.stringify(landfillData)) + useEffect(() => { }, [landfillData]); return ( diff --git a/client/components/dashboard-componenets/mainContent/mainSection.tsx b/client/components/dashboard-componenets/mainContent/mainSection.tsx index fcc9c93..f988a8d 100644 --- a/client/components/dashboard-componenets/mainContent/mainSection.tsx +++ b/client/components/dashboard-componenets/mainContent/mainSection.tsx @@ -11,7 +11,7 @@ function MainSection({ role = "unassigned" }: { role: string }) { const currentState = useContext(NavContext)?.currentActive; return ( -
+
{getDashboardFor(currentState)} diff --git a/client/components/dashboard-componenets/mainContent/mainSectionHeader.tsx b/client/components/dashboard-componenets/mainContent/mainSectionHeader.tsx index fa61a9e..d7e2960 100644 --- a/client/components/dashboard-componenets/mainContent/mainSectionHeader.tsx +++ b/client/components/dashboard-componenets/mainContent/mainSectionHeader.tsx @@ -48,8 +48,9 @@ import { username, } from "@/data/cookieNames"; import { get } from "http"; -import { landfillManager, stsManager } from "@/data/roles"; +import { admin, landfillManager, stsManager } from "@/data/roles"; import axios from "axios"; +import { message } from "antd"; function logout(router: AppRouterInstance) { axios.post( @@ -63,6 +64,7 @@ function logout(router: AppRouterInstance) { ); eraseCookie(role); eraseCookie(jwtToken); + message.success("logged out successfully"); router.push("/auth/login"); } @@ -76,7 +78,7 @@ export default function MainSectionHeader({ const router = useRouter(); const { currentActive, setCurrentActive } = useContext(NavContext); return ( -
+
{/* Sheet for displaying menu in small screens */} @@ -125,6 +127,12 @@ export default function MainSectionHeader({ ) : ( <>{"NO LANDFILL ASSIGNED"} ))} + + {getCookie(curActive)?.startsWith(admin) && + + SYSTEM ADMIN OF ECOSYNC + } +
{/* Profile Icon and dropdown menu */} diff --git a/client/components/dashboard-componenets/mainContent/stsManagerContents/Dashboard.tsx b/client/components/dashboard-componenets/mainContent/stsManagerContents/Dashboard.tsx index 4d65975..1260ab7 100644 --- a/client/components/dashboard-componenets/mainContent/stsManagerContents/Dashboard.tsx +++ b/client/components/dashboard-componenets/mainContent/stsManagerContents/Dashboard.tsx @@ -10,6 +10,7 @@ import { PieChart } from "@mantine/charts"; import LanfFillUpcomingVehiclesInDashboard from "@/components/dataTables/LandFillUpcomingVehicleInDashboard"; import STSVehicleList from "@/components/dataTables/StsVehicleList"; import STSVehicleHistoryList from "@/components/dataTables/STSVehicleHistoryList"; +import { UpdateStsStorage } from "@/components/modals/stsControl/updateSTSStorage"; export default function STSManagerDashboard() { const { getstsDatabyID, stsData } = useGetstsDatabyID(); @@ -18,8 +19,7 @@ export default function STSManagerDashboard() { getstsDatabyID(getCookie(stsId)); }, []); - useEffect(() => { - // alert(JSON.stringify(stsData)) + useEffect(() => { }, [stsData]); return ( @@ -34,10 +34,7 @@ export default function STSManagerDashboard() { OUTGOING DUMP ENTRY - +
diff --git a/client/components/dashboard-componenets/mainContent/stsManagerContents/DumpEntry.tsx b/client/components/dashboard-componenets/mainContent/stsManagerContents/DumpEntry.tsx index 4b50cb3..ad337c6 100644 --- a/client/components/dashboard-componenets/mainContent/stsManagerContents/DumpEntry.tsx +++ b/client/components/dashboard-componenets/mainContent/stsManagerContents/DumpEntry.tsx @@ -11,6 +11,9 @@ import LanfFillUpcomingVehiclesInDashboard from "@/components/dataTables/LandFil import STSVehicleList from "@/components/dataTables/StsVehicleList"; import STSVehicleHistoryList from "@/components/dataTables/STSVehicleHistoryList"; import GetStsCoordinateForRoute from "@/components/maps/getStsCoordinateForRoute"; +import { UpdateStsStorage } from "@/components/modals/stsControl/updateSTSStorage"; +import VehicleReleaseRoute from "@/components/maps/VehicleReleaseRoute"; +import GetVehicleCoordinateRoute from "@/components/maps/getVehicleCoordinate"; export default function STSManagerDumpEntries() { const { getstsDatabyID, stsData } = useGetstsDatabyID(); @@ -20,7 +23,7 @@ export default function STSManagerDumpEntries() { }, []); useEffect(() => { - // alert(JSON.stringify(stsData)) + }, [stsData]); return ( @@ -35,10 +38,7 @@ export default function STSManagerDumpEntries() { OUTGOING DUMP ENTRY - +
@@ -48,7 +48,7 @@ export default function STSManagerDumpEntries() {
*/}
- +
diff --git a/client/components/dashboard-componenets/mainContent/stsManagerContents/Storage.tsx b/client/components/dashboard-componenets/mainContent/stsManagerContents/Storage.tsx index 5e97ad5..c5d14cd 100644 --- a/client/components/dashboard-componenets/mainContent/stsManagerContents/Storage.tsx +++ b/client/components/dashboard-componenets/mainContent/stsManagerContents/Storage.tsx @@ -24,7 +24,7 @@ export default function STSManagerStorageData() { }, []); useEffect(() => { - // alert(JSON.stringify(stsData)) + }, [stsData]); return ( diff --git a/client/components/dashboard-componenets/mainContent/systemAdminContents/Bills.tsx b/client/components/dashboard-componenets/mainContent/systemAdminContents/Bills.tsx index 9378846..1a8edac 100644 --- a/client/components/dashboard-componenets/mainContent/systemAdminContents/Bills.tsx +++ b/client/components/dashboard-componenets/mainContent/systemAdminContents/Bills.tsx @@ -1,33 +1,18 @@ import { Button } from "@/components/ui/button"; import { UserRoundCog, Cog } from "lucide-react"; import EmptyFillContainer from "../../cards/EmptyFillContainer"; +import CompletedBillList from "@/components/dataTables/CompletedBillList"; +import PendingBillList from "@/components/dataTables/PendingBillList"; +import BillListAdmin from "@/components/dataTables/BillListAdmin"; export default function AdminBillsManagementPanel() { - return ( -
-
-

Bills

-
-
- + return ( +
+ +
+
-
-
-
-
- Recent Bills -
-
- Search Bill -
-
- Bill Heatmap -
-
-
-
- ); - } \ No newline at end of file + + + ); +} diff --git a/client/components/dashboard-componenets/mainContent/systemAdminContents/Roles.tsx b/client/components/dashboard-componenets/mainContent/systemAdminContents/Roles.tsx index 7190efb..ef86aa1 100644 --- a/client/components/dashboard-componenets/mainContent/systemAdminContents/Roles.tsx +++ b/client/components/dashboard-componenets/mainContent/systemAdminContents/Roles.tsx @@ -9,7 +9,7 @@ export default function AdminRolesManagementPanel() { return (
-

Roles

+

Roles

@@ -31,7 +31,7 @@ export default function AdminRolesManagementPanel() {
- +

PERMISSON LIST BY ROLE

diff --git a/client/components/dashboard-componenets/mainContent/systemAdminContents/Schedule.tsx b/client/components/dashboard-componenets/mainContent/systemAdminContents/Schedule.tsx index 3d773c3..767a438 100644 --- a/client/components/dashboard-componenets/mainContent/systemAdminContents/Schedule.tsx +++ b/client/components/dashboard-componenets/mainContent/systemAdminContents/Schedule.tsx @@ -1,23 +1,20 @@ import { Button } from "@/components/ui/button"; import { Plus, Truck } from "lucide-react"; import EmptyFillContainer from "../../cards/EmptyFillContainer"; +import { BillBySTSId } from "@/components/dataTables/BillBySTSId"; export default function AdminSchedulePanel() { return ( -
-
-
-
- ADD NEW SCHEDULE -
-
- CRITICAL FIRST SCHEDULES -
-
- DISPATCH HISTORY -
+
+ +
+ SEE SCHEDULE FOR STS 1
-
+ +
+ +
+
); } diff --git a/client/components/dataTables/BillBySTSId.tsx b/client/components/dataTables/BillBySTSId.tsx new file mode 100644 index 0000000..da62473 --- /dev/null +++ b/client/components/dataTables/BillBySTSId.tsx @@ -0,0 +1,196 @@ +"use client"; +import { + Table, + TableBody, + TableCaption, + TableCell, + TableFooter, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table"; +import { message } from "antd"; +import axios from "axios"; +import { useEffect, useState } from "react"; + +const invoices = [ + { + invoice: "INV001", + paymentStatus: "Paid", + totalAmount: "$250.00", + paymentMethod: "Credit Card", + }, + { + invoice: "INV002", + paymentStatus: "Pending", + totalAmount: "$150.00", + paymentMethod: "PayPal", + }, + { + invoice: "INV003", + paymentStatus: "Unpaid", + totalAmount: "$350.00", + paymentMethod: "Bank Transfer", + }, + { + invoice: "INV004", + paymentStatus: "Paid", + totalAmount: "$450.00", + paymentMethod: "Credit Card", + }, + { + invoice: "INV005", + paymentStatus: "Paid", + totalAmount: "$550.00", + paymentMethod: "PayPal", + }, + { + invoice: "INV006", + paymentStatus: "Pending", + totalAmount: "$200.00", + paymentMethod: "Bank Transfer", + }, + { + invoice: "INV007", + paymentStatus: "Unpaid", + totalAmount: "$300.00", + paymentMethod: "Credit Card", + }, +]; + +const dummyDataArray: ScheduleEntry[] = [ + { + time: "10:00 AM", + vehicleNumber: "MH12AB1234", + vehicleType: "Truck", + landFillName: "Landfill 1", + amount: "50 tons", + duration: "2 hours", + }, + { + time: "12:00 PM", + vehicleNumber: "MH12AB1235", + vehicleType: "Van", + landFillName: "Landfill 2", + amount: "30 tons", + duration: "1.5 hours", + }, + { + time: "02:00 PM", + vehicleNumber: "MH12AB1236", + vehicleType: "Truck", + landFillName: "Landfill 3", + amount: "60 tons", + duration: "2.5 hours", + }, + { + time: "04:00 PM", + vehicleNumber: "MH12AB1237", + vehicleType: "Van", + landFillName: "Landfill 4", + amount: "40 tons", + duration: "2 hours", + }, + { + time: "06:00 PM", + vehicleNumber: "MH12AB1238", + vehicleType: "Truck", + landFillName: "Landfill 5", + amount: "70 tons", + duration: "3 hours", + }, + { + time: "08:00 PM", + vehicleNumber: "MH12AB1239", + vehicleType: "Van", + landFillName: "Landfill 6", + amount: "35 tons", + duration: "1.5 hours", + }, + { + time: "10:00 PM", + vehicleNumber: "MH12AB1240", + vehicleType: "Truck", + landFillName: "Landfill 7", + amount: "55 tons", + duration: "2.5 hours", + }, +]; + +type ScheduleEntry = { + time: string; + vehicleNumber: string; + vehicleType: string; + landFillName: string; + amount: string; + duration: string; +}; + +export function BillBySTSId({ stsId, date }: { stsId: string; date: string }) { + const [scheduleData, setSchedulData] = useState([]); + const [stsName, setStsName] = useState(""); + + async function fetchStsScheduleData() { + try { + // fetch data from api + const res: any = await axios.get( + "http://localhost:8585/schedules/search?date=2024-01-5&stsId=sts1", + { + headers: { + Authorization: `Bearer ${localStorage.getItem("token")}`, + }, + } + ); + const data = res.data.map((d: any) => ({ + time: d.scheduleTime, + vehicleNumber: d.vehicle?.vehicleNumber ?? 'N/A', + vehicleType: d.vehicle?.vehicleType ?? 'N/A', + landFillName: d.vehicle?.landFill?.name ?? 'N/A', + amount: d.wasteAmount ?? 'N/A', + duration: d.vehicle?.duration ?? 'N/A', + })); + setStsName(res.data[0].sts?.name); + setSchedulData(data); + } catch (error: any) { + message.error(error?.response?.data?.message || error); + } + } + + useEffect(() => { + fetchStsScheduleData(); + }, []); + + return ( + + Schedule of {stsName} for 12/12/2020. + + + Time + Vehicle Number + Vehicle Type + Landfill Name + Amount + Duration + + + + {scheduleData.map((data, i) => ( + + {data.time} + {data.vehicleNumber} + {data.vehicleType} + {data.landFillName} + {data.duration} + {data.amount} + + ))} + + + + Total + 500 tons + + +
+ ); +} diff --git a/client/components/dataTables/BillListAdmin.tsx b/client/components/dataTables/BillListAdmin.tsx new file mode 100644 index 0000000..c05ecd4 --- /dev/null +++ b/client/components/dataTables/BillListAdmin.tsx @@ -0,0 +1,387 @@ +"use client"; + +import * as React from "react"; +import { + CaretSortIcon, + ChevronDownIcon, + DotsHorizontalIcon, +} from "@radix-ui/react-icons"; + +import { Button } from "@/components/ui/button"; + +import { + ColumnDef, + ColumnFiltersState, + SortingState, + VisibilityState, + flexRender, + getCoreRowModel, + getFilteredRowModel, + getPaginationRowModel, + getSortedRowModel, + useReactTable, +} from "@tanstack/react-table"; + +import { + DropdownMenu, + DropdownMenuCheckboxItem, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import { Input } from "@/components/ui/input"; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table"; +import useGetAllVehicleList from "@/hooks/vehicles/useGetAllVehicleList"; +import { DeleteVehicleModal } from "../modals/vehicleControl/DeleteVehicleModal"; +import { EditVehicleInfoModal } from "../modals/vehicleControl/EditVehicleInfoModal"; +import useGetAllPendingBillList from "@/hooks/bills/useGetAllPendingBillList"; +import { Package, PackageCheck, PackageX } from "lucide-react"; +import { getCookie } from "@/lib/cookieFunctions"; +import { landfillId, landfillName } from "@/data/cookieNames"; +import { BillCreationModal } from "../modals/billControl/BillCreationModal"; +import useGetAllCompletedBillList from "@/hooks/bills/useGetAllCompletedBillList"; +import { BillViewModal } from "../modals/billControl/BillViewModal"; + +export type Bill = { + id: string; + billNo: string; + stsName: string; + landFillName: string; + vehicleNumber: string; + vehicleType: string; + weightOfWaste: number; + shortage: number; + loadedFuelCostPerKm: number; + unloadedFuelCostPerKm: number; + capacity: number; + estimatedFuelCost: number; + distance: number; + estimatedDuration: number; + actualDuration: number; + allocatedFuelCost: number; + tripId: string; +}; + +export const columns: ColumnDef[] = [ + { + accessorKey: "billNo", + header: ({ column }) => { + return ( +
+ +
+ ); + }, + cell: ({ row }) => ( +
{row.getValue("billNo")}
+ ), + }, + { + accessorKey: "vehicleNumber", + header: ({ column }) => { + return ( +
+ +
+ ); + }, + cell: ({ row }) => ( +
+ {row.getValue("vehicleNumber")} +
+ ), + }, + { + accessorKey: "stsName", + header: ({ column }) => { + return ( +
+ +
+ ); + }, + cell: ({ row }) => ( +
{row.getValue("stsName")}
+ ), + }, + { + accessorKey: "weightOfWaste", + header: ({ column }) => { + return ( +
+ +
+ ); + }, + cell: ({ row }) => ( +
+ {row.getValue("weightOfWaste") + " Ton"} +
+ ), + }, + { + accessorKey: "allocatedFuelCost", + header: ({ column }) => { + return ( +
+ +
+ ); + }, + cell: ({ row }) => ( +
+ {row.getValue("allocatedFuelCost")} +
+ ), + }, + { + accessorKey: "actualDuration", + header: ({ column }) => { + return ( +
+ +
+ ); + }, + cell: ({ row }) => ( +
+ {row.getValue("actualDuration")} +
+ ), + }, + { + id: "actions", + enableHiding: false, + cell: ({ row }) => { + const bill: Bill = row.original; + + return ( +
+ {/* + */} + +
+ ); + }, + }, +]; + +export default function BillListAdmin() { + const [data, setData] = React.useState([]); + const { billList, getbillList } = useGetAllCompletedBillList(); + const [sorting, setSorting] = React.useState([]); + const [columnFilters, setColumnFilters] = React.useState( + [] + ); + const [columnVisibility, setColumnVisibility] = + React.useState({}); + const [rowSelection, setRowSelection] = React.useState({}); + + React.useEffect(() => { + getbillList( + "rootSecretKey" + ); + }, []); + + React.useEffect(() => { + setData(billList); + }, [billList]); + + const table = useReactTable({ + data, + columns, + onSortingChange: setSorting, + onColumnFiltersChange: setColumnFilters, + getCoreRowModel: getCoreRowModel(), + getPaginationRowModel: getPaginationRowModel(), + getSortedRowModel: getSortedRowModel(), + getFilteredRowModel: getFilteredRowModel(), + onColumnVisibilityChange: setColumnVisibility, + onRowSelectionChange: setRowSelection, + state: { + sorting, + columnFilters, + columnVisibility, + rowSelection, + }, + }); + return ( + <> +
+ COMPLETED BILL LIST +
+
+ + table.getColumn("vehicleNumber")?.setFilterValue(event.target.value) + } + className="max-w-sm" + /> + + + + + + {table + .getAllColumns() + .filter((column) => column.getCanHide()) + .map((column) => { + return ( + + column.toggleVisibility(!!value) + } + > + {column.id} + + ); + })} + + +
+
+ + + {table.getHeaderGroups().map((headerGroup) => ( + + {headerGroup.headers.map((header) => { + return ( + + {header.isPlaceholder + ? null + : flexRender( + header.column.columnDef.header, + header.getContext() + )} + + ); + })} + + ))} + + + {table.getRowModel().rows?.length ? ( + table.getRowModel().rows.map((row) => ( + + {row.getVisibleCells().map((cell) => ( + + {flexRender( + cell.column.columnDef.cell, + cell.getContext() + )} + + ))} + + )) + ) : ( + + + {billList.length > 0 ? ( +
+ + No bills include this vehicle number. +
+ ) : ( +
+ + No pending bills. +
+ )} +
+
+ )} +
+
+
+
+
+ Total {table.getFilteredRowModel().rows.length} row(s) rendered. +
+
+ + +
+
+ + ); +} diff --git a/client/components/dataTables/LandFillUpcomingVehicle.tsx b/client/components/dataTables/LandFillUpcomingVehicle.tsx index 8dfe0bf..0badd86 100644 --- a/client/components/dataTables/LandFillUpcomingVehicle.tsx +++ b/client/components/dataTables/LandFillUpcomingVehicle.tsx @@ -58,19 +58,17 @@ import { landfillId } from "@/data/cookieNames"; import formatTimestamp from "@/lib/formatTimestamp"; type Vehicle = { - tripId: string, - weightOfWaste: string, - vehicleNumber: string, - stsId: string, - vehicleType: string, - distance: string, - tripStartTime: string, - estimatedDuration: string - tripStatus: string - capacity: string, - - }; - + tripId: string; + weightOfWaste: string; + vehicleNumber: string; + stsId: string; + vehicleType: string; + distance: string; + tripStartTime: string; + estimatedDuration: string; + tripStatus: string; + capacity: string; +}; export const columns: ColumnDef[] = [ { @@ -90,7 +88,9 @@ export const columns: ColumnDef[] = [ ); }, cell: ({ row }) => ( -
{row.getValue("vehicleNumber")}
+
+ {row.getValue("vehicleNumber")} +
), }, { @@ -132,7 +132,9 @@ export const columns: ColumnDef[] = [ ); }, cell: ({ row }) => ( -
{formatTimestamp(row.getValue("tripStartTime".toLocaleString()))}
+
+ {formatTimestamp(row.getValue("tripStartTime".toLocaleString()))} +
), }, { @@ -152,7 +154,9 @@ export const columns: ColumnDef[] = [ ); }, cell: ({ row }) => ( -
{row.getValue("estimatedDuration")}
+
+ {row.getValue("estimatedDuration")} +
), }, { @@ -192,7 +196,9 @@ export const columns: ColumnDef[] = [ ); }, cell: ({ row }) => ( -
{row.getValue("weightOfWaste")}
+
+ {row.getValue("weightOfWaste")} +
), }, { @@ -245,11 +251,9 @@ export default function LanfFillUpcomingVehicles() { async function getAllUpcomingVehicles() { console.log(landfillId); - await UpcomingVehicle( - { - landFillId: await getCookie(landfillId) - } - ); + await UpcomingVehicle({ + landFillId: await getCookie(landfillId), + }); } React.useEffect(() => { @@ -276,7 +280,7 @@ export default function LanfFillUpcomingVehicles() { columnFilters, columnVisibility, rowSelection, - }, + }, initialState: { pagination: { pageIndex: 0, @@ -286,11 +290,15 @@ export default function LanfFillUpcomingVehicles() { }); return ( <> -
UPCOMING VEHICLES
+
+ UPCOMING VEHICLES +
table.getColumn("vehicleNumber")?.setFilterValue(event.target.value) } diff --git a/client/components/dataTables/LandFillUpcomingVehicleInDashboard.tsx b/client/components/dataTables/LandFillUpcomingVehicleInDashboard.tsx index c344050..19ab973 100644 --- a/client/components/dataTables/LandFillUpcomingVehicleInDashboard.tsx +++ b/client/components/dataTables/LandFillUpcomingVehicleInDashboard.tsx @@ -58,18 +58,17 @@ import { landfillId, landfillName } from "@/data/cookieNames"; import formatTimestamp from "@/lib/formatTimestamp"; type Vehicle = { - tripId: string, - weightOfWaste: string, - vehicleNumber: string, - stsId: string, - vehicleType: string, - distance: string, - tripStartTime: string, - estimatedDuration: string - tripStatus: string - capacity: string, - - }; + tripId: string; + weightOfWaste: string; + vehicleNumber: string; + stsId: string; + vehicleType: string; + distance: string; + tripStartTime: string; + estimatedDuration: string; + tripStatus: string; + capacity: string; +}; export const columns: ColumnDef[] = [ { @@ -89,9 +88,11 @@ export const columns: ColumnDef[] = [ ); }, cell: ({ row }) => ( -
{row.getValue("vehicleNumber")}
+
+ {row.getValue("vehicleNumber")} +
), - }, + }, { accessorKey: "stsId", header: ({ column }) => { @@ -129,7 +130,9 @@ export const columns: ColumnDef[] = [ ); }, cell: ({ row }) => ( -
{formatTimestamp(row.getValue("tripStartTime".toLocaleString()))}
+
+ {formatTimestamp(row.getValue("tripStartTime".toLocaleString()))} +
), }, { @@ -149,10 +152,12 @@ export const columns: ColumnDef[] = [ ); }, cell: ({ row }) => ( -
{row.getValue("weightOfWaste")}
+
+ {row.getValue("weightOfWaste")} +
), }, - + { id: "actions", enableHiding: false, @@ -181,8 +186,8 @@ export default function LanfFillUpcomingVehiclesInDashboard() { React.useState({}); const [rowSelection, setRowSelection] = React.useState({}); - async function callUpcomingVehicle() { - await UpcomingVehicle(await getCookie(landfillId)); + async function callUpcomingVehicle() { + await UpcomingVehicle({landFillId: await getCookie(landfillId)}); } React.useEffect(() => { @@ -203,27 +208,31 @@ export default function LanfFillUpcomingVehiclesInDashboard() { getSortedRowModel: getSortedRowModel(), getFilteredRowModel: getFilteredRowModel(), onColumnVisibilityChange: setColumnVisibility, - onRowSelectionChange: setRowSelection, + onRowSelectionChange: setRowSelection, state: { sorting, columnFilters, columnVisibility, - rowSelection, + rowSelection, }, initialState: { pagination: { pageIndex: 0, pageSize: 4, }, - }, + }, }); return ( <> -
Upcoming trips to your {getCookie(landfillName)} landfill
+
+ Upcoming trips to your {getCookie(landfillName)} landfill +
table.getColumn("vehicleNumber")?.setFilterValue(event.target.value) } diff --git a/client/components/lists/PermissonList.tsx b/client/components/lists/PermissonList.tsx index b318c89..befb620 100644 --- a/client/components/lists/PermissonList.tsx +++ b/client/components/lists/PermissonList.tsx @@ -20,6 +20,7 @@ import { import { Button } from "../ui/button"; import { updatePermisson } from "@/hooks/user_data/updatePermisson"; import { Pointer, SquareMousePointer } from "lucide-react"; +import { message } from "antd"; type RolesWithPermisson = { id: string; @@ -175,7 +176,7 @@ function PermissonList() { Cancel { - msg && alert(await updatePermisson(msg)); + msg && message.info(await updatePermisson(msg)); await fetchAllRoles(); setMsg(undefined); }} diff --git a/client/components/maps/OptimizedVehicleRoute.tsx b/client/components/maps/OptimizedVehicleRoute.tsx index cc69544..cd7aa61 100644 --- a/client/components/maps/OptimizedVehicleRoute.tsx +++ b/client/components/maps/OptimizedVehicleRoute.tsx @@ -25,6 +25,15 @@ import { useJsApiLoader, } from "@react-google-maps/api"; import { ChevronDownIcon } from "@chakra-ui/icons"; +import { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectLabel, + SelectTrigger, + SelectValue, +} from "../ui/select"; const center = { lat: 23.77217046, lng: 90.39943882 }; @@ -34,11 +43,11 @@ type StsRouteType = { }; type VehicleCoordinateType = { - vehicleNumber: string; - vehicleType: string; - capacity: string; - coordinate: string; - }; + vehicleNumber: string; + vehicleType: string; + capacity: string; + coordinate: string; +}; type MapProps = { coordinates: StsRouteType[]; @@ -46,14 +55,15 @@ type MapProps = { }; interface Coordinate { - lat: number; - lng: number; + lat: number; + lng: number; } -const OptimizedVehicleRoute: React.FC = ({ coordinates, vehicleCoord }) => { - const [routeType, setRouteType] = useState( - "Vehicle Tracking Map" - ); +const OptimizedVehicleRoute: React.FC = ({ + coordinates, + vehicleCoord, +}) => { + const [routeType, setRouteType] = useState("Vehicle Tracking Map"); const [useDropdown, setUseDropdown] = useState(false); const [useLandDropdown, setUseLandDropdown] = useState(false); const [searchTerm, setSearchTerm] = useState(""); @@ -84,8 +94,12 @@ const OptimizedVehicleRoute: React.FC = ({ coordinates, vehicleCoord } useEffect(() => { const coordinateArray: string[] = coordinates.map((route) => route.name); - const VehicleCoordinateArray: string[] = vehicleCoord.map((route) => route.vehicleNumber); - const VehicleCoordinateObject: string[] = vehicleCoord.map((route) => route.coordinate); + const VehicleCoordinateArray: string[] = vehicleCoord.map( + (route) => route.vehicleNumber + ); + const VehicleCoordinateObject: string[] = vehicleCoord.map( + (route) => route.coordinate + ); setAllCoordinates(coordinateArray); setVehicleAllCoord(VehicleCoordinateArray); setVehicleObjectCoord(VehicleCoordinateObject); @@ -112,15 +126,13 @@ const OptimizedVehicleRoute: React.FC = ({ coordinates, vehicleCoord } handleLandChangeInputType(); }; - const handleInputChange = (event: React.ChangeEvent) => { - setSearchTerm(event.target.value); - setShowSuggestions(true); + const handleInputChange = (event: string) => { + setSearchTerm(event); + //setShowSuggestions(true); }; - const handleLandInputChange = ( - event: React.ChangeEvent - ) => { - setLandterm(event.target.value); - setShowLandsuggestion(true); + const handleLandInputChange = (event: string) => { + setLandterm(event); + //setShowLandsuggestion(true); }; const handleSuggestionClick = (suggestion: string) => { @@ -183,25 +195,23 @@ const OptimizedVehicleRoute: React.FC = ({ coordinates, vehicleCoord } }; async function calculateRoute() { - - const stsCoord = getSTSCoodrdinateByName(searchTerm); - const vehicleCoord = getVehicleCoordByName(landTerm); - - const newString = stsCoord.substring(0, 11); - console.log(stsCoord); - const directionsService = new google.maps.DirectionsService(); - const results = await directionsService.route({ - origin: vehicleCoord, - destination: stsCoord, - travelMode: google.maps.TravelMode.DRIVING, - }); - - if (results && results.routes.length > 0) { - setDirectionsResponse(results); - setDistance(results.routes[0].legs[0].distance?.text || ""); - setDuration(results.routes[0].legs[0].duration?.text || ""); - } - + const stsCoord = getSTSCoodrdinateByName(searchTerm); + const vehicleCoord = getVehicleCoordByName(landTerm); + + const newString = stsCoord.substring(0, 11); + console.log(stsCoord); + const directionsService = new google.maps.DirectionsService(); + const results = await directionsService.route({ + origin: vehicleCoord, + destination: stsCoord, + travelMode: google.maps.TravelMode.DRIVING, + }); + + if (results && results.routes.length > 0) { + setDirectionsResponse(results); + setDistance(results.routes[0].legs[0].distance?.text || ""); + setDuration(results.routes[0].legs[0].duration?.text || ""); + } } function clearRoute() { @@ -214,22 +224,24 @@ const OptimizedVehicleRoute: React.FC = ({ coordinates, vehicleCoord } if (destinationRef.current) destinationRef.current.value = ""; } -// const DummyCoordinates = [ -// { lat: 23.76287175, lng: 90.4306625 }, -// { lat: 23.79067691, lng: 90.3932404 }, -// { lat: 23.75847265, lng: 90.3819107 }, -// { lat: 23.79868747, lng: 90.3870606 }, -// { lat: 23.79083399, lng: 90.3762459 }, -// { lat: 23.79366130, lng: 90.4129814 }, -// { lat: 23.77952415, lng: 90.4260277 } -// ]; - -const ObjectCoordinates: Coordinate[] = vehicleObjectCoord.map(coordString => { - const [lat, lng] = coordString.split(',').map(parseFloat); - return { lat, lng }; -}); + // const DummyCoordinates = [ + // { lat: 23.76287175, lng: 90.4306625 }, + // { lat: 23.79067691, lng: 90.3932404 }, + // { lat: 23.75847265, lng: 90.3819107 }, + // { lat: 23.79868747, lng: 90.3870606 }, + // { lat: 23.79083399, lng: 90.3762459 }, + // { lat: 23.79366130, lng: 90.4129814 }, + // { lat: 23.77952415, lng: 90.4260277 } + // ]; + + const ObjectCoordinates: Coordinate[] = vehicleObjectCoord.map( + (coordString) => { + const [lat, lng] = coordString.split(",").map(parseFloat); + return { lat, lng }; + } + ); const carIcon = { - url: 'https://banner2.cleanpng.com/20180331/tsw/kisspng-pickup-truck-car-dump-truck-clip-art-dump-truck-5abfc5a5931d73.2100081815225174136026.jpg', + url: "https://banner2.cleanpng.com/20180331/tsw/kisspng-pickup-truck-car-dump-truck-clip-art-dump-truck-5abfc5a5931d73.2100081815225174136026.jpg", scaledSize: new window.google.maps.Size(40, 40), // Adjust the size as per your icon }; console.log(ObjectCoordinates); @@ -255,9 +267,14 @@ const ObjectCoordinates: Coordinate[] = vehicleObjectCoord.map(coordString => { }} onLoad={(map) => setMap(map as google.maps.Map)} > - {map && ObjectCoordinates.map(coord => ( - - ))} + {map && + ObjectCoordinates.map((coord) => ( + + ))} {directionsResponse && ( )} @@ -265,76 +282,100 @@ const ObjectCoordinates: Coordinate[] = vehicleObjectCoord.map(coordString => { -
+
Vehicle Live Tracking
- - - -
- - {showLandSuggestion && ( -
    - {landFilteredSuggestions.map((suggestion, index) => ( -
  • handleLandSuggestionClick(suggestion)} - > - {suggestion} -
  • - ))} -
- )} -
- -
- - -
- - {showSuggestions && ( -
    - {filteredSuggestions.map((suggestion, index) => ( -
  • handleSuggestionClick(suggestion)} - > - {suggestion} -
  • - ))} -
- )} -
- -
- - - +
+ + {/* +
+ + {showLandSuggestion && ( +
    + {landFilteredSuggestions.map((suggestion, index) => ( +
  • handleLandSuggestionClick(suggestion)} + > + {suggestion} +
  • + ))} +
+ )} +
+
*/} + {/* +
+ + {showSuggestions && ( +
    + {filteredSuggestions.map((suggestion, index) => ( +
  • handleSuggestionClick(suggestion)} + > + {suggestion} +
  • + ))} +
+ )} +
+
*/} + + { onClick={clearRoute} /> - +
Distance: {distance} Duration: {duration} @@ -373,5 +414,5 @@ export default OptimizedVehicleRoute; // "23.790833993414953, 90.37624594171659", // "23.793661300302535, 90.41298147521984", // "23.779524150835503, 90.42602773945464", - -// ] \ No newline at end of file + +// ] diff --git a/client/components/modals/DeleteVehicleModalForSTS.tsx b/client/components/modals/DeleteVehicleModalForSTS.tsx index 533f786..55f1f56 100644 --- a/client/components/modals/DeleteVehicleModalForSTS.tsx +++ b/client/components/modals/DeleteVehicleModalForSTS.tsx @@ -15,6 +15,7 @@ import React, { useState } from "react"; import { Trash } from "lucide-react"; import deleteUser from "@/hooks/user_data/deleteUser"; import deleteVehicleEntryFromSTS from "@/hooks/StsDashboard/deleteVehicleEntryFromSTS"; +import { message } from "antd"; type Vehicle = { entryId: string, @@ -90,9 +91,9 @@ export const DeleteVehicleModalForSTS = ({ vehicleInfo }: { vehicleInfo: Vehicle type="submit" onClick={async () => { if (confirmText !== "CONFIRM") - return alert("Please type 'CONFIRM' to confirm"); + return message.error("Please type 'CONFIRM' to confirm"); const result = await deleteVehicleEntryFromSTS(vehicleInfo.entryId); - if (result) return alert(result); + if (result) return message.info(result); }} > Confirm diff --git a/client/components/modals/LandFillVehicleEntryModal.tsx b/client/components/modals/LandFillVehicleEntryModal.tsx index bf2354e..15eaf0a 100644 --- a/client/components/modals/LandFillVehicleEntryModal.tsx +++ b/client/components/modals/LandFillVehicleEntryModal.tsx @@ -38,6 +38,7 @@ import useTripComplete from "@/hooks/landFillDashboard/useTripComplete"; import DatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; +import { message } from "antd"; type Vehicle = { @@ -84,7 +85,7 @@ const handleDateChange = (date: Date) => { weightOfWaste: weightOfWaste, entryTime: selectedDateTime.toISOString()//entryTime, }); - if(postEntry) return alert(postEntry); + if(postEntry) return message.success(postEntry); } catch (error) { console.error("Error:", error); diff --git a/client/components/modals/ProfileEditModal.tsx b/client/components/modals/ProfileEditModal.tsx index 0243b5f..5cc6b39 100644 --- a/client/components/modals/ProfileEditModal.tsx +++ b/client/components/modals/ProfileEditModal.tsx @@ -37,6 +37,7 @@ import useTripComplete from "@/hooks/landFillDashboard/useTripComplete"; import { profile } from "console"; import useEditProfileInfo from "@/hooks/user_data/useEditProfileInfo"; import useGetUserProfile from "@/hooks/user_data/useGetUserProfile"; +import { message } from "antd"; type User = { @@ -73,7 +74,7 @@ export const ProfileEditModal = ({ profileInfo }: { profileInfo: User }) => { profileName: profilename }); - if(postEntry) return alert(postEntry); + if(postEntry) return message.success(postEntry); } catch (error) { console.error("Error:", error); diff --git a/client/components/modals/STSVehicleReleaseModal.tsx b/client/components/modals/STSVehicleReleaseModal.tsx index abc5863..02d78c7 100644 --- a/client/components/modals/STSVehicleReleaseModal.tsx +++ b/client/components/modals/STSVehicleReleaseModal.tsx @@ -35,6 +35,7 @@ import useVehicleReleaseFromSTS from "@/hooks/StsDashboard/useVehicleReleaseFrom import DatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; +import { message } from "antd"; type Vehicle = { entryId: string; @@ -83,7 +84,7 @@ export const STSVehicleRelease = ({ estimatedDuration: duration, }); // window.location.reload(); - if(postEntry) return alert(postEntry); + if(postEntry) return message.success(postEntry); } catch (error) { console.error("Error:", error); } diff --git a/client/components/modals/StsVehicleEntryModal.tsx b/client/components/modals/StsVehicleEntryModal.tsx index e023a3f..fdec517 100644 --- a/client/components/modals/StsVehicleEntryModal.tsx +++ b/client/components/modals/StsVehicleEntryModal.tsx @@ -33,6 +33,7 @@ import { } from "../ui/select"; import useGetSTSAvailableVehicles from "@/hooks/vehicles/useSTSAvailableVehicles"; +import { message } from "antd"; interface DialogWrapperProps { @@ -67,7 +68,7 @@ export const StsVehicleEntryModal: React.FC = ({ const [weightOfWaste, setWeightOfWaste] = useState(""); const callVehcilse = async () => { const sucess = await GetSTSAvailableVehicles(); - if(!sucess) return alert("Wrong Vehicle Information"); + if(!sucess) return message.error("Wrong Vehicle Information"); }; useEffect(() => { @@ -121,7 +122,7 @@ export const StsVehicleEntryModal: React.FC = ({ vehicleIds: vehicleId, entryTimes: selectedDateTime.toISOString(), }); - if(postEntry) return alert(postEntry); + if(postEntry) return message.success(postEntry); } catch (error) { console.error("Error:", error); } diff --git a/client/components/modals/VehicleModal.tsx b/client/components/modals/VehicleModal.tsx index 61ba794..b0ae6b0 100644 --- a/client/components/modals/VehicleModal.tsx +++ b/client/components/modals/VehicleModal.tsx @@ -33,6 +33,7 @@ import { import useGetAllLandfill from "@/hooks/dataQuery/useGetAllLandfill"; import useCreateVehicle from "@/hooks/entityCreation/useCreateVehicle"; import useGetAllSTS from "@/hooks/stsdata/useGetAllSTS"; +import { message } from "antd"; interface DialogWrapperProps { children: React.ReactNode; @@ -62,10 +63,6 @@ export const VehicleCreateModal: React.FC = ({ useEffect(() => {}, [stsList]); const handleSaveChanges = async () => { - console.log("Vehicle Number:", vehicleNumber); - console.log("Vehicle Type:", vehicleType); - console.log("Capacity:", capacity); - //alert(assignedLandfill); const res = await createVehicle({ vehicleNumber, vehicleType, @@ -75,7 +72,7 @@ export const VehicleCreateModal: React.FC = ({ landFillId: assignedLandfill, stsId: assignedSTS, }) - if(res) return alert(res); + if(res) return message.success(res); }; return ( diff --git a/client/components/modals/billControl/BillCreationModal.tsx b/client/components/modals/billControl/BillCreationModal.tsx index ece447f..6504da8 100644 --- a/client/components/modals/billControl/BillCreationModal.tsx +++ b/client/components/modals/billControl/BillCreationModal.tsx @@ -33,6 +33,7 @@ import useGetAllLandfill from "@/hooks/dataQuery/useGetAllLandfill"; import editVehicle from "@/hooks/vehicles/editVehicle"; import { Trip } from "@/components/dataTables/PendingBillList"; import makeBill from "@/hooks/bills/makeBill"; +import { message } from "antd"; export const BillCreationModal = ({ tripInfo }: { tripInfo: Trip }) => { const [allocatedCost, setAllocatedCost] = useState(); @@ -131,7 +132,7 @@ export const BillCreationModal = ({ tripInfo }: { tripInfo: Trip }) => { onClick={async () => { let result; allocatedCost ? result = await makeBill(tripInfo, allocatedCost) : result = "Please enter allocated cost"; - if (result) return alert(result); + if (result) return message.success(result); }} > GENERATE BILL diff --git a/client/components/modals/billControl/BillViewModal.tsx b/client/components/modals/billControl/BillViewModal.tsx index 5e7806b..54fcc09 100644 --- a/client/components/modals/billControl/BillViewModal.tsx +++ b/client/components/modals/billControl/BillViewModal.tsx @@ -133,14 +133,7 @@ export const BillViewModal = ({ billInfo }: { billInfo: Bill }) => { diff --git a/client/components/modals/landfillControl/DeleteLandfillModal.tsx b/client/components/modals/landfillControl/DeleteLandfillModal.tsx index 754553c..0fa8aac 100644 --- a/client/components/modals/landfillControl/DeleteLandfillModal.tsx +++ b/client/components/modals/landfillControl/DeleteLandfillModal.tsx @@ -17,6 +17,7 @@ import deleteUser from "@/hooks/user_data/deleteUser"; import deleteSTS from "@/hooks/entityCreation/deleteSTS"; import { LandFill } from "@/components/dataTables/LandFillList"; import deleteLandFill from "@/hooks/entityCreation/deleteLandfill"; +import { message } from "antd"; export const DeleteLandfillModal = ({ landfillInfo }: { landfillInfo: LandFill }) => { const [confirmText, setConfirmText] = useState(""); @@ -77,9 +78,9 @@ export const DeleteLandfillModal = ({ landfillInfo }: { landfillInfo: LandFill } type="submit" onClick={async () => { if (confirmText !== "CONFIRM") - return alert("Please type 'CONFIRM' to confirm"); + return message.error("Please type 'CONFIRM' to confirm"); const result = await deleteLandFill(landfillInfo.id); - if (result) return alert(result); + if (result) return message.success(result); }} > Confirm diff --git a/client/components/modals/landfillControl/EditLandfillInfoModal.tsx b/client/components/modals/landfillControl/EditLandfillInfoModal.tsx index 04eb53c..c475376 100644 --- a/client/components/modals/landfillControl/EditLandfillInfoModal.tsx +++ b/client/components/modals/landfillControl/EditLandfillInfoModal.tsx @@ -30,6 +30,7 @@ import { admin, landfillManager, stsManager, unassigned } from "@/data/roles"; import editSTS from "@/hooks/entityCreation/editSTS"; import getUserByRole from "@/hooks/user_data/getUserByRole"; import editLandfill from "@/hooks/entityCreation/editLandfill"; +import { message } from "antd"; type LandFill = { id: string; @@ -136,7 +137,7 @@ export const EditLandfillInfoModal = ({ landfillInfo }: { landfillInfo: LandFill type="submit" onClick={async () => { const result = await editLandfill(landfillData, landfillManagerData?.id || ""); - if (result) return alert(result); + if (result) return message.success(result); }} > Update Landfill diff --git a/client/components/modals/landfillControl/LandfillModal.tsx b/client/components/modals/landfillControl/LandfillModal.tsx index f625693..145892e 100644 --- a/client/components/modals/landfillControl/LandfillModal.tsx +++ b/client/components/modals/landfillControl/LandfillModal.tsx @@ -17,6 +17,7 @@ import SetZone from "../../maps/SetZone"; import useCreateLandFill, { LandFill, } from "@/hooks/entityCreation/useCreateLandfill"; +import { message } from "antd"; interface DialogWrapperProps { children: React.ReactNode; @@ -38,7 +39,7 @@ export const LandfillCreateModal: React.FC = ({ latitude: parseFloat(latitude), longitude: parseFloat(longitude), }; - alert((await createLandfill(data)) || "Landfill data invalid"); + message.success((await createLandfill(data)) || "Landfill data invalid"); }; return ( diff --git a/client/components/modals/landfillControl/updateLandfillStorage.tsx b/client/components/modals/landfillControl/updateLandfillStorage.tsx index 44c026f..792ebdc 100644 --- a/client/components/modals/landfillControl/updateLandfillStorage.tsx +++ b/client/components/modals/landfillControl/updateLandfillStorage.tsx @@ -12,13 +12,14 @@ import { import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; -import React, { use, useEffect, useState } from "react"; -import { Send, Trash,EditIcon } from "lucide-react"; +import React, { Children, use, useEffect, useState } from "react"; +import { Send, Trash,EditIcon, LogOut } from "lucide-react"; import useEditProfileInfo from "@/hooks/user_data/useEditProfileInfo"; import useGetUserProfile from "@/hooks/user_data/useGetUserProfile"; import useUpdateSts from "@/hooks/StsDashboard/useUpdateSts"; import useLandFillStorageEdit from "@/hooks/landFillDashboard/useLandFillStorageEdit"; +import { message } from "antd"; type User = { @@ -55,9 +56,10 @@ export const UpdateLandfillStorageModal = () => { landfillId: landfillDetails.landfillId }); - if(postEntry) return alert(postEntry); - } catch (error) { - console.error("Error:", error); + if(postEntry) return message.success(postEntry); + } catch (error: any) { + message.error(error?.response?.data?.message || "An error occurred"); + // console.error("Error:", error); } @@ -69,10 +71,11 @@ export const UpdateLandfillStorageModal = () => { return ( - - + + diff --git a/client/components/modals/stsControl/DeleteSTSModal.tsx b/client/components/modals/stsControl/DeleteSTSModal.tsx index 52373e1..a8a03c6 100644 --- a/client/components/modals/stsControl/DeleteSTSModal.tsx +++ b/client/components/modals/stsControl/DeleteSTSModal.tsx @@ -15,6 +15,7 @@ import React, { useState } from "react"; import { Trash } from "lucide-react"; import deleteUser from "@/hooks/user_data/deleteUser"; import deleteSTS from "@/hooks/entityCreation/deleteSTS"; +import { message } from "antd"; export type STS = { id: string; @@ -89,9 +90,9 @@ export const DeleteSTSModal = ({ stsInfo }: { stsInfo: STS }) => { type="submit" onClick={async () => { if (confirmText !== "CONFIRM") - return alert("Please type 'CONFIRM' to confirm"); + return message.error("Please type 'CONFIRM' to confirm"); const result = await deleteSTS(stsInfo.id); - if (result) return alert(result); + if (result) return message.success(result); }} > Confirm diff --git a/client/components/modals/stsControl/EditSTSInfoModal.tsx b/client/components/modals/stsControl/EditSTSInfoModal.tsx index 5f4d425..d455860 100644 --- a/client/components/modals/stsControl/EditSTSInfoModal.tsx +++ b/client/components/modals/stsControl/EditSTSInfoModal.tsx @@ -29,6 +29,7 @@ import { number } from "prop-types"; import { admin, landfillManager, stsManager, unassigned } from "@/data/roles"; import editSTS from "@/hooks/entityCreation/editSTS"; import getUserByRole from "@/hooks/user_data/getUserByRole"; +import { message } from "antd"; export type STS = { id: string; @@ -151,7 +152,7 @@ export const EditSTSInfoModal = ({ stsInfo }: { stsInfo: STS }) => { type="submit" onClick={async () => { const result = await editSTS(stsData, stsManagerData?.id || ""); - if (result) return alert(result); + if (result) return message.success(result); }} > Update STS diff --git a/client/components/modals/stsControl/StsModal.tsx b/client/components/modals/stsControl/StsModal.tsx index a00853a..f7e2d8a 100644 --- a/client/components/modals/stsControl/StsModal.tsx +++ b/client/components/modals/stsControl/StsModal.tsx @@ -16,6 +16,7 @@ import { Label } from "@/components/ui/label"; import React , {useState} from "react"; import SetZone from "../../maps/SetZone"; import useCreateSTS, { STS } from "@/hooks/entityCreation/useCreateSTS"; +import { message } from "antd"; interface DialogWrapperProps { children: React.ReactNode; @@ -32,9 +33,8 @@ export const StsCreateModal: React.FC = ({ const {createSTS } = useCreateSTS(); const handleSaveChanges = async () => { - const data:STS = {name: stsName, wardNumber , capacity: parseInt(capacity), latitude: parseFloat(latitude), longitude: parseFloat(longitude)}; - console.log(data); - alert(await createSTS(data) || "STS data invalid"); + const data:STS = {name: stsName, wardNumber , capacity: parseInt(capacity), latitude: parseFloat(latitude), longitude: parseFloat(longitude)}; + message.success(await createSTS(data) || "STS data invalid"); }; diff --git a/client/components/modals/stsControl/updateSTSStorage.tsx b/client/components/modals/stsControl/updateSTSStorage.tsx index df019c2..28c209d 100644 --- a/client/components/modals/stsControl/updateSTSStorage.tsx +++ b/client/components/modals/stsControl/updateSTSStorage.tsx @@ -7,76 +7,70 @@ import { DialogHeader, DialogTitle, DialogTrigger, - DialogClose + DialogClose, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import React, { use, useEffect, useState } from "react"; -import { Send, Trash,EditIcon } from "lucide-react"; +import { Send, Trash, EditIcon, ArrowDown } from "lucide-react"; import useEditProfileInfo from "@/hooks/user_data/useEditProfileInfo"; import useGetUserProfile from "@/hooks/user_data/useGetUserProfile"; import useUpdateSts from "@/hooks/StsDashboard/useUpdateSts"; - +import { message } from "antd"; type User = { id: string; username: string; email: string; profileName: string; - roleName: string; + roleName: string; roleDescription: string; - }; - export const UpdateStsStorage = () => { - + const { user, stsDetails, landfillDetails, getUserDetails } = + useGetUserProfile(); - const { user, stsDetails, landfillDetails, getUserDetails} = useGetUserProfile(); - + const [username, setUsername] = useState(user.username); + const [profilename, setProfilename] = useState(user.profileName); + const [wastageEntry, setWastageEntry] = useState( + stsDetails.stsCurrentTotalWaste + ); - const [username , setUsername] = useState(user.username); - const [profilename , setProfilename] = useState(user.profileName); - const [wastageEntry , setWastageEntry] = useState(stsDetails.stsCurrentTotalWaste); - const { UpdateSts } = useUpdateSts(); - - - const handleSaveChanges = async () => { try { - const remainingCapacity = parseInt(stsDetails.stsCurrentTotalWaste) + parseInt(wastageEntry); - const postEntry = await UpdateSts({ - storedData: remainingCapacity, - stsId: stsDetails.stsId - }); + const remainingCapacity = + parseInt(stsDetails.stsCurrentTotalWaste) + parseInt(wastageEntry); + const postEntry = await UpdateSts({ + storedData: remainingCapacity, + stsId: stsDetails.stsId, + }); - if(postEntry) return alert(postEntry); - } catch (error) { - console.error("Error:", error); - } - - + if (postEntry) return message.success(postEntry); + } catch (error) { + console.error("Error:", error); + } }; useEffect(() => { getUserDetails(); }, []); - return ( - - Entry Dump In STS + Entry Dump In STS
@@ -89,27 +83,24 @@ export const UpdateStsStorage = () => { {stsDetails.stsName}

-

- Ward Number: - {stsDetails.stsWardNumber} -

- Capacity: +

+ Ward Number: + {stsDetails.stsWardNumber} +

+ Capacity: {stsDetails.stsCapacity}

Current Total Waste: {stsDetails.stsCurrentTotalWaste}

- - -
{ onChange={(e) => setWastageEntry(e.target.value)} />
- -
- - - + + +
diff --git a/client/components/modals/userControls/AddNewUserModal.tsx b/client/components/modals/userControls/AddNewUserModal.tsx index 27fde5b..aba3834 100644 --- a/client/components/modals/userControls/AddNewUserModal.tsx +++ b/client/components/modals/userControls/AddNewUserModal.tsx @@ -24,6 +24,7 @@ import { SelectTrigger, SelectValue, } from "../../ui/select"; +import { message } from "antd"; interface DialogWrapperProps { children: React.ReactNode; @@ -135,7 +136,7 @@ export const AddNewUserModal = ({ props }: { props: any }) => { type="submit" onClick={async () => { const result = await props.createNewUser(); - if (result) return alert(result); + if (result) return message.success(result); }} > Create User diff --git a/client/components/modals/userControls/DeleteUserModal.tsx b/client/components/modals/userControls/DeleteUserModal.tsx index eb4d359..08f814f 100644 --- a/client/components/modals/userControls/DeleteUserModal.tsx +++ b/client/components/modals/userControls/DeleteUserModal.tsx @@ -14,6 +14,7 @@ import { Label } from "@/components/ui/label"; import React, { useState } from "react"; import { Trash } from "lucide-react"; import deleteUser from "@/hooks/user_data/deleteUser"; +import { message } from "antd"; type User = { id: string; @@ -79,9 +80,9 @@ export const DeleteUserModal = ({ userInfo }: { userInfo: User }) => { type="submit" onClick={async () => { if (confirmText !== "CONFIRM") - return alert("Please type 'CONFIRM' to confirm"); + return message.error("Please type 'CONFIRM' to confirm"); const result = await deleteUser(userInfo.id); - if (result) return alert(result); + if (result) return message.success(result); }} > Confirm diff --git a/client/components/modals/userControls/EditUserInfoModal.tsx b/client/components/modals/userControls/EditUserInfoModal.tsx index 238c9d1..6d682a1 100644 --- a/client/components/modals/userControls/EditUserInfoModal.tsx +++ b/client/components/modals/userControls/EditUserInfoModal.tsx @@ -27,6 +27,7 @@ import editUser from "@/hooks/user_data/editUser"; import gettAllRoles from "@/hooks/user_data/useGetAllRole"; import { number } from "prop-types"; import { admin, landfillManager, stsManager, unassigned } from "@/data/roles"; +import { message } from "antd"; type User = { id: string; @@ -132,7 +133,7 @@ export const EditUserModal = ({ userInfo }: { userInfo: User }) => { type="submit" onClick={async () => { const result = await editUser(userData); - if (result) return alert(result); + if (result) return message.success(result); }} > Update User diff --git a/client/components/modals/vehicleControl/DeleteVehicleModal.tsx b/client/components/modals/vehicleControl/DeleteVehicleModal.tsx index 10102c1..4c32340 100644 --- a/client/components/modals/vehicleControl/DeleteVehicleModal.tsx +++ b/client/components/modals/vehicleControl/DeleteVehicleModal.tsx @@ -16,6 +16,7 @@ import { Trash } from "lucide-react"; import deleteUser from "@/hooks/user_data/deleteUser"; import deleteVehicleEntryFromSTS from "@/hooks/StsDashboard/deleteVehicleEntryFromSTS"; import deleteVehiclebyId from "@/hooks/vehicles/deleteVehiclebyId"; +import { message } from "antd"; type Vehicle = { id: string, @@ -86,9 +87,9 @@ export const DeleteVehicleModal = ({ vehicleInfo }: { vehicleInfo: Vehicle }) => type="submit" onClick={async () => { if (confirmText !== "CONFIRM") - return alert("Please type 'CONFIRM' to confirm"); + return message.error("Please type 'CONFIRM' to confirm"); const result = await deleteVehiclebyId(vehicleInfo.id); - if (result) return alert(result); + if (result) return message.success(result); }} > Confirm diff --git a/client/components/modals/vehicleControl/EditVehicleInfoModal.tsx b/client/components/modals/vehicleControl/EditVehicleInfoModal.tsx index f64de5b..cb69c1d 100644 --- a/client/components/modals/vehicleControl/EditVehicleInfoModal.tsx +++ b/client/components/modals/vehicleControl/EditVehicleInfoModal.tsx @@ -32,6 +32,7 @@ import getUserByRole from "@/hooks/user_data/getUserByRole"; import useGetAllLandfill from "@/hooks/dataQuery/useGetAllLandfill"; import editVehicle from "@/hooks/vehicles/editVehicle"; import useGetAllSTS from "@/hooks/stsdata/useGetAllSTS"; +import { message } from "antd"; type Vehicle = { id: string, @@ -216,9 +217,8 @@ export const EditVehicleInfoModal = ({ vehicleInfo }: { vehicleInfo: Vehicle })