diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..59b6b4f Binary files /dev/null and b/.DS_Store differ 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/auth/signup/leftImage.tsx b/client/app/auth/signup/leftImage.tsx deleted file mode 100644 index b125e82..0000000 --- a/client/app/auth/signup/leftImage.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import Image from "next/image"; - -export default function LeftImage() { - return ( -
- Image -
- ) -} \ No newline at end of file diff --git a/client/app/auth/signup/page.tsx b/client/app/auth/signup/page.tsx deleted file mode 100644 index 2bce8b6..0000000 --- a/client/app/auth/signup/page.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import LeftImage from "./leftImage"; -import RightForm from "./rightForm"; - -export default function LoginPage() { - return ( - <> -
- - - - -
- - ); -} diff --git a/client/app/auth/signup/rightForm.tsx b/client/app/auth/signup/rightForm.tsx deleted file mode 100644 index db81893..0000000 --- a/client/app/auth/signup/rightForm.tsx +++ /dev/null @@ -1,84 +0,0 @@ -"use client"; -import Link from "next/link"; - -import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; - -import useSignup from "../../../hooks/auth/useSignup"; -import { useRouter } from "next/navigation"; -import CaptchaDiv from "@/components/Captcha"; -import { useState } from "react"; - -function RightForm() { - const { signupData, setSignUpData, signup } = useSignup(); - const router = useRouter(); - const [correctCaptcha, setCorrectCaptcha] = useState(""); - const [userCaptcha, setUserCaptcha] = useState(""); - - return ( -
-
-
-

Sign Up

-

- Enter your email below to Sign Up -

-
-
{ - e.preventDefault(); - const sucess = await signup(); - userCaptcha === correctCaptcha ? sucess && router.push("/dashboard") : alert("Captcha is incorrect"); - }} - className="grid gap-4" - > -
- - - setSignUpData({ ...signupData, email: e.target.value }) - } - required - /> -
-
-
- - - Forgot your password? - -
- - setSignUpData({ ...signupData, password: e.target.value }) - } - required - /> -
- - - -
- Already have an account?{" "} - - Login - -
-
-
- ); -} -export default RightForm; diff --git a/client/app/layout.tsx b/client/app/layout.tsx index b28bdce..8ce03a3 100644 --- a/client/app/layout.tsx +++ b/client/app/layout.tsx @@ -3,6 +3,7 @@ import { Inter } from "next/font/google"; import "./globals.css"; import '@mantine/core/styles.css'; import '@mantine/charts/styles.css'; +import { AntdRegistry } from '@ant-design/nextjs-registry'; import { ColorSchemeScript, MantineProvider } from '@mantine/core'; @@ -26,7 +27,7 @@ export default function RootLayout({ - {children} + {children} ); } diff --git a/client/app/page.tsx b/client/app/page.tsx index 5c87672..c1393e1 100644 --- a/client/app/page.tsx +++ b/client/app/page.tsx @@ -1,10 +1,28 @@ +import Hero from "@/components/Homepage/Hero"; +import Navbar from "@/components/Homepage/Navbar"; import Image from "next/image"; +import SectionTitle from "@/components/Homepage/SectionTitle";import Benifit from "@/components/Homepage/Benifit"; +import Deliverable from "@/components/Homepage/Deliverables"; +import Teamintro from "@/components/Homepage/Teamintro"; +; export default function Home() { return ( -
-

Welcome to EcoSync

- EcoSync +
+ + + + Our dashboard empowers Dhaka South City Corporation to allocate resources more effectively, + optimizing manpower and equipment utilization for waste management tasks, thus fostering operational efficiency, reducing operational costs, + and ultimately leading to a cleaner, more sustainable urban environment. + + + + +
); } +// /EcoSync \ No newline at end of file diff --git a/client/app/profile/[userId]/page.tsx b/client/app/profile/[userId]/page.tsx deleted file mode 100644 index d605e38..0000000 --- a/client/app/profile/[userId]/page.tsx +++ /dev/null @@ -1,184 +0,0 @@ -"use client"; -import BackgroundComponent from "@/components/profile/backgroundComp"; -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; -import { Button } from "@/components/ui/button"; -import useGetUserProfile from "@/hooks/user_data/useGetUserProfile"; -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 { ProfileEditModal } from "@/components/modals/ProfileEditModal"; -import useGetAllRole from "@/hooks/user_data/useGetAllRole"; -import { UpdateStsStorage } from "@/components/modals/stsControl/updateSTSStorage"; -import { UpdateLandfillStorageModal } from "@/components/modals/landfillControl/updateLandfillStorage"; - -type RolesWithPermisson = { - id: string; - name: string; - permissions: [{ - name: string; - description: string; -}] -}; - - -export default function ProfilePage() { - - const router = useRouter(); - const { user, stsDetails, landfillDetails, getUserDetails} = useGetUserProfile(); // Destructure user and getUserDetails - const [role, setRole] = useState("Role Name"); - // const [permissions, setPermissions] = useState([]); - const RolePlace = 'Station'; - const { fetchAllRoles, roles, rolesWithPermissions } = useGetAllRole(); - useEffect(() => { - const fetchData = async () => { - await getUserDetails(); - await fetchAllRoles(); - - setRole(user.roleName); - }; - - fetchData(); - - }, []); - - - return ( -
- - -
- {user.roleName} -
-
-
- - - - - -

Profile Page

-
-

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}

- - -
- - - } - -{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 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' && landfillDetails?.landfillId?.toString().length < 1 && ( -
-
LandFill Not Assigned
- Call your admin to assign your Landfill. -
- )} - -{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' &&
-
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/app/profile/page.tsx b/client/app/profile/page.tsx new file mode 100644 index 0000000..9e18775 --- /dev/null +++ b/client/app/profile/page.tsx @@ -0,0 +1,266 @@ +"use client"; +import BackgroundComponent from "@/components/profile/backgroundComp"; +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; +import { Button } from "@/components/ui/button"; +import useGetUserProfile from "@/hooks/user_data/useGetUserProfile"; +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 { ProfileEditModal } from "@/components/modals/ProfileEditModal"; +import useGetAllRole from "@/hooks/user_data/useGetAllRole"; +import { UpdateStsStorage } from "@/components/modals/stsControl/updateSTSStorage"; +import { UpdateLandfillStorageModal } from "@/components/modals/landfillControl/updateLandfillStorage"; + +type RolesWithPermisson = { + id: string; + name: string; + permissions: [ + { + name: string; + description: string; + } + ]; +}; + +export default function ProfilePage() { + const router = useRouter(); + const { user, stsDetails, landfillDetails, getUserDetails } = + useGetUserProfile(); // Destructure user and getUserDetails + const [role, setRole] = useState("Role Name"); + // const [permissions, setPermissions] = useState([]); + const RolePlace = "Station"; + const { fetchAllRoles, roles, rolesWithPermissions } = useGetAllRole(); + useEffect(() => { + const fetchData = async () => { + await getUserDetails(); + await fetchAllRoles(); + + setRole(user.roleName); + }; + + fetchData(); + }, []); + + return ( +
+ + +
+ {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} +

+
+ )} + + {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 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" && + landfillDetails?.landfillId?.toString().length < 1 && ( +
+
+ LandFill Not Assigned +
+ Call your admin to assign your Landfill. +
+ )} + + {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" && ( +
+
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/Homepage/Benifit.tsx b/client/components/Homepage/Benifit.tsx new file mode 100644 index 0000000..5efe8a1 --- /dev/null +++ b/client/components/Homepage/Benifit.tsx @@ -0,0 +1,96 @@ +import React from 'react' +import Image from "next/image"; +const Benifit = () => { + return ( +
+ +
+ +
+ +
+ {/* Hero Illustration */} + N +
+
+
+
Key Features
+
+
+
+ + + +
+

Centralized Administration

+
+
+ +

Empower system administrators to efficiently manage all aspects of waste management, including user creation, role assignment, and permissions. With a user-friendly interface, administrators can streamline operations and ensure accountability across the organization.

+ +
+
+
+
+
+ + + + + + +
+

Efficient Resource Allocation and Billing System

+
+
+ +

Facilitate efficient resource allocation by providing tools for managing vehicle entry and release at STS and landfill sites. STS managers can oversee vehicle entry and release processes, while landfill managers can track vehicle entries, manage billing, and monitor STS status in real-time.

+ +
+
+
+
+
+ + + + + +
+

Real-time Vehicle Tracking and Fleet Optimizations

+
+
+ +

Enable STS and landfill managers to monitor vehicle movements in real-time using live Google Maps integration. With accurate vehicle location data, managers can optimize routes, track vehicle status, and ensure timely waste transfer between STS and landfills.

+ +
+
+
+
+
+ ) +} + +export default Benifit \ No newline at end of file diff --git a/client/components/Homepage/Container.tsx b/client/components/Homepage/Container.tsx new file mode 100644 index 0000000..9e41a64 --- /dev/null +++ b/client/components/Homepage/Container.tsx @@ -0,0 +1,17 @@ +import React, { ReactNode } from "react"; + +interface ContainerProps { + className?: string; + children: ReactNode; +} + +const Container = ({ className, children }: ContainerProps) => { + return ( +
+ {children} +
+ ); +} + +export default Container; diff --git a/client/components/Homepage/DarkSwitch.tsx b/client/components/Homepage/DarkSwitch.tsx new file mode 100644 index 0000000..0f17c59 --- /dev/null +++ b/client/components/Homepage/DarkSwitch.tsx @@ -0,0 +1,53 @@ +import React, { useState, useEffect } from "react"; +import { useTheme } from "next-themes"; + +const ThemeChanger = () => { + const [mounted, setMounted] = useState(false); + const { theme, setTheme } = useTheme(); + + // When mounted on client, now we can show the UI + useEffect(() => setMounted(true), []); + + if (!mounted) return null; + + return ( +
+ {theme === "dark" ? ( + + ) : ( + + )} +
+ ); +}; + +export default ThemeChanger; diff --git a/client/components/Homepage/Data.ts b/client/components/Homepage/Data.ts new file mode 100644 index 0000000..a4f404e --- /dev/null +++ b/client/components/Homepage/Data.ts @@ -0,0 +1,62 @@ +import { ReactNode } from "react"; + +interface Bullet { + title: string; + desc: string; + icon: string; // Image URL +} + +interface Benefit { + title: string; + desc: string; + image: string; // Image URL + bullets: Bullet[]; +} + +const benefitOne: Benefit = { + title: "Highlight your benefits", + desc: "You can use this space to highlight your first benefit or a feature of your product. It can also contain an image or Illustration like in the example along with some bullet points.", + image: "url_to_image.png", // Replace with URL of the image + bullets: [ + { + title: "Enhanced Operational Efficiency", + desc: "Then explain the first point briefly in one or two lines.", + icon: "url_to_image1.png", // Replace with URL of the first image + }, + { + title: "Improve acquisition", + desc: "Here you can add the next benefit point.", + icon: "url_to_image2.png", // Replace with URL of the second image + }, + { + title: "Drive customer retention", + desc: "This will be your last bullet point in this section.", + icon: "url_to_image3.png", // Replace with URL of the third image + }, + ], +}; + +const benefitTwo: Benefit = { + title: "Offer more benefits here", + desc: "You can use this same layout with a flip image to highlight your rest of the benefits of your product. It can also contain an image or Illustration as above section along with some bullet points.", + image: "url_to_image.png", // Replace with URL of the image + bullets: [ + { + title: "Mobile Responsive Template", + desc: "Nextly is designed as a mobile first responsive template.", + icon: "url_to_image4.png", // Replace with URL of the fourth image + }, + { + title: "Powered by Next.js & TailwindCSS", + desc: "This template is powered by latest technologies and tools.", + icon: "url_to_image5.png", // Replace with URL of the fifth image + }, + { + title: "Dark & Light Mode", + desc: "Nextly comes with a zero-config light & dark mode. ", + icon: "url_to_image6.png", // Replace with URL of the sixth image + }, + ], +}; + +export { benefitOne, benefitTwo }; diff --git a/client/components/Homepage/Deliverables.tsx b/client/components/Homepage/Deliverables.tsx new file mode 100644 index 0000000..8a72b10 --- /dev/null +++ b/client/components/Homepage/Deliverables.tsx @@ -0,0 +1,125 @@ +import React from 'react' +import Image from "next/image"; +const Deliverable = () => { + return ( +
+
+
+

Deliverable Project Resources +

+

A collection of downloadable assets essential for project development and understanding including API documentation, diagrams, UI prototype, and Powerpoint presentation.

+
+
+
+
+
+ +
+

+ API Documentation + +

+

Detailed API documentation structured in an Excel file for easy reference and organization.

+
+
+
+
+
+ + + + + + + +
+

Entity Relationship Diagram

+

Visualization of entity relationships to depict the connections between data entities.

+
+
+
+
+
+ + + + +
+

End to End Activity Diagram

+

Visual representation illustrating the sequential flow of activities from start to finish.

+
+
+
+
+
+ + + +
+

Backend Workflow Diagram

+

Diagram outlining the step-by-step process and interactions of the backend system.

+
+
+
+
+
+ + + +
+

UI Prototype

+

UI prototype (made with Figma) presented for design evaluation and feedback.

+
+
+
+
+
+ + + +
+

Powerpoint presentation

+

PowerPoint presentation showcasing app screens with titles, offering a comprehensive overview.

+
+
+
+
+
+ ) +} + +export default Deliverable \ No newline at end of file diff --git a/client/components/Homepage/Hero.tsx b/client/components/Homepage/Hero.tsx new file mode 100644 index 0000000..09325ab --- /dev/null +++ b/client/components/Homepage/Hero.tsx @@ -0,0 +1,205 @@ +"use client"; + +import Image from "next/image"; +import Container from "./Container"; + + +const Hero = () => { + return ( + <> + +
+
+

+ Revolutionizing Waste Management with Dhaka South City Corporation +

+

+ Join us in Building a Cleaner, Greener Dhaka - Innovating Solutions for Sustainable Waste Management, Enhancing Public Health, + and Preserving Our Environment for Generations to Come +

+ + +
+
+
+
+ {/* Hero Illustration */} + N +
+
+
+ {/* +
+
+ Trusted by 2000+{" "} + customers worldwide +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
*/} + + ); +} + +function AmazonLogo() { + return ( + + + + + + + + + + + + + ); +} + +function MicrosoftLogo() { + return ( + + + + + ); +} + +function NetflixLogo() { + return ( + + + + + + ); +} + +function SonyLogo() { + return ( + + + + + + + + + ); +} + +function VerizonLogo() { + return ( + + + + + + + + + ); +} + +export default Hero; \ No newline at end of file diff --git a/client/components/Homepage/Navbar.tsx b/client/components/Homepage/Navbar.tsx new file mode 100644 index 0000000..dd75a2b --- /dev/null +++ b/client/components/Homepage/Navbar.tsx @@ -0,0 +1,104 @@ +"use client"; +import Link from "next/link"; +import ThemeChanger from "./DarkSwitch"; +import Image from "next/image" +import { Disclosure } from "@headlessui/react"; + +const Navbar = () => { + const navigation = [ + "Product", + "Features", + "Pricing", + "Company", + "Blog", + ]; + + return ( +
+ +
+ ); +} + +export default Navbar; diff --git a/client/components/Homepage/SectionTitle.tsx b/client/components/Homepage/SectionTitle.tsx new file mode 100644 index 0000000..1e68e0a --- /dev/null +++ b/client/components/Homepage/SectionTitle.tsx @@ -0,0 +1,39 @@ +import React, { ReactNode } from "react"; +import Container from "./Container"; + +interface SectionTitleProps { + align?: "left" | "center"; // Align can be left or center + pretitle?: string; + title?: string; + children?: ReactNode; +} + +const SectionTitle = ({ align = "center", pretitle, title, children }: SectionTitleProps) => { + return ( + + {pretitle && ( +
+ {pretitle} +
+ )} + + {title && ( +

+ {title} +

+ )} + + {children && ( +

+ {children} +

+ )} +
+ ); +} + +export default SectionTitle; diff --git a/client/components/Homepage/Teamintro.tsx b/client/components/Homepage/Teamintro.tsx new file mode 100644 index 0000000..248a9ea --- /dev/null +++ b/client/components/Homepage/Teamintro.tsx @@ -0,0 +1,49 @@ +import React from 'react' +import Image from 'next/image' +import mehrajvai from './assets/mehrajvai.jpeg'; +import shawonvai from './assets/shawonvai.jpeg'; +import nafi from './assets/nafi.jpeg'; + + +const Teamintro = () => { + return ( +
+
+ Our Team +
+
+
+
+
+ testimonial +

I'm a student currently studying Software Engineering at Shahjalal University of Science & Technology. I really enjoy learning data structures and algorithms. And I love doing Competitive Programming. I'm also interested in exploring core Object Oriented Programming concepts.

+ +

Shawon Majid

+

Backend Developer

+
+
+
+
+ testimonial +

A highly motivated and hardworking individual, who is seeking an apprenticeship in the IT industry to build upon a keen scientific interest and start a career as an IT Expert and a critical problem solver. The eventual career goal is to become a fully-qualified and experienced Software Developer.

+ +

Md Mehrajul Islam

+

MERN Develeoper

+
+
+
+
+ testimonial +

I am a dedicated and energetic software developer with a diverse skill set. My expertise covers a range of areas, including Cloud Technology, mobile app and web development. In the realm of web development, I've successfully executed projects using Next.js, React.js, and JavaScript.

+ +

Nafi Ullah Shafin

+

Frontend Developer

+
+
+
+
+
+ ) +} + +export default Teamintro \ No newline at end of file diff --git a/client/components/dashboard-componenets/mainContent/landFillManagerContents/Dashboard.tsx b/client/components/dashboard-componenets/mainContent/landFillManagerContents/Dashboard.tsx index 1c9ba51..253dbd8 100644 --- a/client/components/dashboard-componenets/mainContent/landFillManagerContents/Dashboard.tsx +++ b/client/components/dashboard-componenets/mainContent/landFillManagerContents/Dashboard.tsx @@ -20,7 +20,7 @@ export default function LandfillManagerDashboard() { }, []); useEffect(() => { - // alert(JSON.stringify(landfillData)) + }, [landfillData]); return ( @@ -42,8 +42,8 @@ export default function LandfillManagerDashboard() { {(landfillData?.graphData?.empty !== undefined && landfillData?.graphData?.full !== undefined) ?
-

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 71ff7e3..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 ( @@ -57,8 +56,8 @@ export default function LandfillManagerStorageData() { {(landfillData?.graphData?.empty !== undefined && landfillData?.graphData?.full !== undefined) ? +
{getDashboardFor(currentState)} diff --git a/client/components/dashboard-componenets/mainContent/mainSectionHeader.tsx b/client/components/dashboard-componenets/mainContent/mainSectionHeader.tsx index bfabbba..d7e2960 100644 --- a/client/components/dashboard-componenets/mainContent/mainSectionHeader.tsx +++ b/client/components/dashboard-componenets/mainContent/mainSectionHeader.tsx @@ -48,11 +48,23 @@ 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( + "/auth/logout", + {}, + { + headers: { + Authorization: `Bearer ${getCookie(jwtToken)}`, + }, + } + ); eraseCookie(role); eraseCookie(jwtToken); + message.success("logged out successfully"); router.push("/auth/login"); } @@ -66,7 +78,7 @@ export default function MainSectionHeader({ const router = useRouter(); const { currentActive, setCurrentActive } = useContext(NavContext); return ( -
+
{/* Sheet for displaying menu in small screens */} @@ -99,60 +111,72 @@ export default function MainSectionHeader({
{getCookie(curActive)?.startsWith(stsManager) && (getCookie(stsName) ? ( - YOUR STS : {getCookie(stsName).toUpperCase()} + + YOUR STS : {getCookie(stsName).toUpperCase()} + ) : ( <>{"NO STS ASSIGNED"} ))} {getCookie(curActive)?.startsWith(landfillManager) && (getCookie(landfillName) ? ( - YOUR LANDFILL : {getCookie(landfillName).toUpperCase()} + + YOUR LANDFILL :{" "} + {getCookie(landfillName).toUpperCase()} + ) : ( <>{"NO LANDFILL ASSIGNED"} - ))} + ))} + + {getCookie(curActive)?.startsWith(admin) && + + SYSTEM ADMIN OF ECOSYNC + } +
{/* Profile Icon and dropdown menu */}
- {getCookie(username)} - - - - - - My Account - - { - router.push("profile/1234"); - }} - > - My Profile - - setCurrentActive(role + "-Settings")} - > - Settings - - { - router.push("auth/change-password"); - }} - > - Change Password - - - logout(router)} - > - Logout - - -
+ {getCookie(username)} + + + + + + My Account + + { + router.push("profile"); + }} + > + My Profile + + setCurrentActive(role + "-Settings")} + > + Settings + + { + router.push("auth/change-password"); + }} + > + Change Password + + + logout(router)} + > + Logout + + + +
); } diff --git a/client/components/dashboard-componenets/mainContent/stsManagerContents/Dashboard.tsx b/client/components/dashboard-componenets/mainContent/stsManagerContents/Dashboard.tsx index 4626cfa..1260ab7 100644 --- a/client/components/dashboard-componenets/mainContent/stsManagerContents/Dashboard.tsx +++ b/client/components/dashboard-componenets/mainContent/stsManagerContents/Dashboard.tsx @@ -1,51 +1,97 @@ import { Button } from "@/components/ui/button"; import EmptyFillContainer from "../../cards/EmptyFillContainer"; -import { Cog, UserRoundCog } from "lucide-react"; -import { StsVehicleEntryModal } from "@/components/modals/StsVehicleEntryModal"; +import { ArrowDown, Cog, Truck, UserRoundCog } from "lucide-react"; +import { StsVehicleEntryModal } from "@/components/modals/StsVehicleEntryModal"; +import { stsId } from "@/data/cookieNames"; +import useGetstsDatabyID from "@/hooks/StsDashboard/getStsDataById"; +import { useEffect } from "react"; +import { getCookie } from "@/lib/cookieFunctions"; +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() { - return ( -
-
-

- STS Dashboard -

+ const { getstsDatabyID, stsData } = useGetstsDatabyID(); + + useEffect(() => { + getstsDatabyID(getCookie(stsId)); + }, []); + + useEffect(() => { + }, [stsData]); + + return ( +
+
+

STS DASHBOARD

- - + + - +
-
-
- Storage Status -
-
- Upcoming Gari -
-
- Dumping History -
-
- Dump graph +
+
+ +
+ {" "} +
+ STORAGE STATUS OF +
+ OF {stsData?.name?.toUpperCase()} +
+
+ {" "} + {stsData?.graphData?.emptyPercentage}% EMPTY +
+ {stsData?.graphData?.fullPercentage}% FULL +
+
+ {stsData?.graphData?.empty !== undefined && + stsData?.graphData?.full !== undefined ? ( + + ) : ( + "loading..." + )} +
-
- MAP +
+ + +
-
- Storage Graph +
+ + +
-
- ); - } \ No newline at end of file +
+ ); +} diff --git a/client/components/dashboard-componenets/mainContent/stsManagerContents/DumpEntry.tsx b/client/components/dashboard-componenets/mainContent/stsManagerContents/DumpEntry.tsx index 2b349ff..ad337c6 100644 --- a/client/components/dashboard-componenets/mainContent/stsManagerContents/DumpEntry.tsx +++ b/client/components/dashboard-componenets/mainContent/stsManagerContents/DumpEntry.tsx @@ -1,111 +1,68 @@ import { Button } from "@/components/ui/button"; -import { - Card, - CardHeader, - CardTitle, - CardDescription, - CardContent, - CardFooter, -} from "@/components/ui/card"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; +import EmptyFillContainer from "../../cards/EmptyFillContainer"; +import { ArrowDown, Cog, Send, Truck, UserRoundCog } from "lucide-react"; +import { StsVehicleEntryModal } from "@/components/modals/StsVehicleEntryModal"; +import { stsId } from "@/data/cookieNames"; +import useGetstsDatabyID from "@/hooks/StsDashboard/getStsDataById"; +import { useEffect } from "react"; +import { getCookie } from "@/lib/cookieFunctions"; +import { PieChart } from "@mantine/charts"; +import LanfFillUpcomingVehiclesInDashboard from "@/components/dataTables/LandFillUpcomingVehicleInDashboard"; +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() { - return ( -
-
-

SETTINGS

+ const { getstsDatabyID, stsData } = useGetstsDatabyID(); + + useEffect(() => { + getstsDatabyID(getCookie(stsId)); + }, []); + + useEffect(() => { + + }, [stsData]); + + return ( +
+
+

DUMP ENTRIES

+
+
+ + + + +
-
-
- {/*

ADD NEW DUMP ENTRY

*/} -
-

ADD STORAGE ENTRIES

- - - Create project - - Deploy your new project in one-click. - - - -
-
-
- - -
-
- - -
-
-
-
- - - - -
+
+
+ {/*
+ DISPATCH HISTORY +
*/} +
+ + + +
+
+ + +
-
-

ADD DUMP ENTRIES

- - - Create project - - Deploy your new project in one-click. - - - -
-
-
- - -
-
- - -
-
-
-
- - - - -
+
+ + +
-
- ); +
+ ); } \ No newline at end of file diff --git a/client/components/dashboard-componenets/mainContent/stsManagerContents/Schedules.tsx b/client/components/dashboard-componenets/mainContent/stsManagerContents/Schedules.tsx index c35b12a..aeb7ebd 100644 --- a/client/components/dashboard-componenets/mainContent/stsManagerContents/Schedules.tsx +++ b/client/components/dashboard-componenets/mainContent/stsManagerContents/Schedules.tsx @@ -4,26 +4,31 @@ import OptimizedRouteMap from "@/components/maps/OptimizedRoute"; import RouteMap from "@/components/maps/RouteMap"; import STSVehicleList from "@/components/dataTables/StsVehicleList"; import GetStsCoordinateForRoute from "@/components/maps/getStsCoordinateForRoute"; +import STSVehicleHistoryList from "@/components/dataTables/STSVehicleHistoryList"; export default function STSManagerSchedules() { return (
-
-
- - UPCOMING - CRITICAL FIRST SCHEDULES - - -
+
{/*
DISPATCH HISTORY
*/} -
+
+
+ + + +
+
+ + + +
diff --git a/client/components/dashboard-componenets/mainContent/stsManagerContents/Storage.tsx b/client/components/dashboard-componenets/mainContent/stsManagerContents/Storage.tsx index 8c589f9..c5d14cd 100644 --- a/client/components/dashboard-componenets/mainContent/stsManagerContents/Storage.tsx +++ b/client/components/dashboard-componenets/mainContent/stsManagerContents/Storage.tsx @@ -1,41 +1,169 @@ +"use client"; import { Button } from "@/components/ui/button"; -import { Cog, UserRoundCog } from "lucide-react"; +import "@mantine/charts/styles.css"; import EmptyFillContainer from "../../cards/EmptyFillContainer"; +import { AllStsMapShow } from "@/components/maps/AllStsShow"; +import useGetAllSTS from "@/hooks/stsdata/useGetAllSTS"; +import { use, useEffect, useState } from "react"; +import GoogleMapComponent from "@/components/maps/GoogleMap"; +// import PieChart from "@/components/graphs/PieChart"; +import BarChart from "@/components/graphs/BarChart"; +import { AreaChart, PieChart } from "@mantine/charts"; +import { landfillId, stsId } from "@/data/cookieNames"; +import useGetLandfillDatabyID from "@/hooks/landFillDashboard/getLandFillDataById"; +import { getCookie } from "@/lib/cookieFunctions"; +import useGetstsDatabyID from "@/hooks/StsDashboard/getStsDataById"; +import STSVehicleHistoryList from "@/components/dataTables/STSVehicleHistoryList"; export default function STSManagerStorageData() { + + const { getstsDatabyID, stsData } = useGetstsDatabyID(); + + useEffect(() => { + getstsDatabyID(getCookie(stsId)); + }, []); + + useEffect(() => { + + }, [stsData]); + return (
-
-

Storage

-
-
- - -
-
-
-
-
- Dumping history -
-
- Storage history +
+
+ +
+ +
+ {" "} +
+ STORAGE STATUS OF +
+ OF {stsData?.name?.toUpperCase()} +
+
+ {" "} + {stsData?.graphData?.emptyPercentage}% EMPTY +
+ {stsData?.graphData?.fullPercentage}% FULL +
+
+ {stsData?.graphData?.empty !== undefined && + stsData?.graphData?.full !== undefined ? ( + + ) : ( + "loading..." + )} +
-
- Dumping graph +
+ + TOTAL WEIGHT HISTOTY + +
-
- storage status pie +
+ + WEEKLY INCOMING WASTE HISTORY + +
-
- Storage graph +
+ + +
+
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/dashboard-componenets/mainContent/systemAdminContents/System.tsx b/client/components/dashboard-componenets/mainContent/systemAdminContents/System.tsx index 2ef7807..a040e51 100644 --- a/client/components/dashboard-componenets/mainContent/systemAdminContents/System.tsx +++ b/client/components/dashboard-componenets/mainContent/systemAdminContents/System.tsx @@ -1,6 +1,6 @@ import { Button } from "@/components/ui/button"; import EmptyFillContainer from "../../cards/EmptyFillContainer"; -import { Plus, Truck } from "lucide-react"; +import { Plus, Trash, Truck, Warehouse } from "lucide-react"; import { StsCreateModal } from "../../../modals/stsControl/StsModal"; import { VehicleCreateModal } from "@/components/modals/VehicleModal"; import { LandfillCreateModal } from "@/components/modals/landfillControl/LandfillModal"; @@ -13,16 +13,16 @@ export default function AdminSystemDataPanel() { return (
-

SYSTEM DATA

+

SYSTEM DATA

@@ -30,9 +30,9 @@ export default function AdminSystemDataPanel() { diff --git a/client/components/dataTables/AllVehicleList.tsx b/client/components/dataTables/AllVehicleList.tsx index 9b75234..5ce6bea 100644 --- a/client/components/dataTables/AllVehicleList.tsx +++ b/client/components/dataTables/AllVehicleList.tsx @@ -65,6 +65,7 @@ type Vehicle = { unloadedFuelCostPerKm: string, landFillId: string, landFillName: string, + stsId: string, }; export const columns: ColumnDef[] = [ 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/dataTables/STSVehicleHistoryList.tsx b/client/components/dataTables/STSVehicleHistoryList.tsx new file mode 100644 index 0000000..db5630f --- /dev/null +++ b/client/components/dataTables/STSVehicleHistoryList.tsx @@ -0,0 +1,323 @@ +"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 useGetAllUser from "@/hooks/user_data/useGetAllUser"; +import { DeleteUserModal } from "../modals/userControls/DeleteUserModal"; +import { Copy, EditIcon } from "lucide-react"; +import { EditUserModal } from "../modals/userControls/EditUserInfoModal"; +import gettAllRoles from "@/hooks/user_data/useGetAllRole"; +import { roleList } from "@/data/roles"; +import useGetAllSTS from "@/hooks/dataQuery/useGetAllSTS"; +import { EditSTSInfoModal } from "../modals/stsControl/EditSTSInfoModal"; +import { DeleteSTSModal } from "../modals/stsControl/DeleteSTSModal"; +import useVehicleList from "@/hooks/vehicles/useVehiclesData"; +import useVehicleListForSTS from "@/hooks/vehicles/useGetVeicleForSTS"; +import { DeleteVehicleModalForSTS } from "../modals/DeleteVehicleModalForSTS"; +import { STSVehicleRelease } from "../modals/STSVehicleReleaseModal"; +import formatTimestamp from "@/lib/formatTimestamp"; +import useGetVehicleHistoryForSTS from "@/hooks/vehicles/useGetVehicleHistoryForSTS"; + +type Vehicle = { + vehicleNumber: string, + exitTime: string, + landFillName: string, + weightOfWaste: string, +}; + +export const columns: ColumnDef[] = [ + { + accessorKey: "vehicleNumber", + header: ({ column }) => { + return ( +
+ +
+ ); + }, + cell: ({ row }) => ( +
{row.getValue("vehicleNumber")}
+ ), + }, + + { + accessorKey: "weightOfWaste", + header: ({ column }) => { + return ( +
+ +
+ ); + }, + cell: ({ row }) => ( +
{row.getValue("weightOfWaste".toLocaleString())}
+ ), + }, + { + accessorKey: "landFillName", + header: ({ column }) => { + return ( +
+ +
+ ); + }, + cell: ({ row }) => ( +
+ {row.getValue("landFillName")} +
+ ), + }, + { + accessorKey: "exitTime", + header: ({ column }) => { + return ( +
+ +
+ ); + }, + cell: ({ row }) => ( +
{formatTimestamp(row.getValue("exitTime".toLocaleString()))}
+ ), + }, + { + id: "actions", + enableHiding: false, + cell: ({ row }) => { + const sts: Vehicle = row.original; + + return ( +
+ {/* + */} +
+ ); + }, + }, +]; + +export default function STSVehicleHistoryList() { + const [data, setData] = React.useState([]); + const { getVehicleHistory, vehicleList } = useGetVehicleHistoryForSTS(); + const [sorting, setSorting] = React.useState([]); + const [columnFilters, setColumnFilters] = React.useState( + [] + ); + const [columnVisibility, setColumnVisibility] = + React.useState({}); + const [rowSelection, setRowSelection] = React.useState({}); + + React.useEffect(() => { + getVehicleHistory(); + }, []); + + React.useEffect(() => { + setData(vehicleList); + }, [vehicleList]); + + 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, + }, + initialState: { + pagination: { + pageIndex: 0, + pageSize: 4, + }, + }, + }); + return ( +
+
HISTORY OF OUTGOING VEHICLES FROM YOUR STS
+
+ + 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() + )} + + ))} + + )) + ) : ( + + + No results. + + + )} + +
+
+
+
+ Total {table.getFilteredRowModel().rows.length} row(s) fetched. +
+
+ + +
+
+
+ ); +} diff --git a/client/components/dataTables/StsVehicleList.tsx b/client/components/dataTables/StsVehicleList.tsx index d453cff..6b5b745 100644 --- a/client/components/dataTables/StsVehicleList.tsx +++ b/client/components/dataTables/StsVehicleList.tsx @@ -53,6 +53,7 @@ import useVehicleList from "@/hooks/vehicles/useVehiclesData"; import useVehicleListForSTS from "@/hooks/vehicles/useGetVeicleForSTS"; import { DeleteVehicleModalForSTS } from "../modals/DeleteVehicleModalForSTS"; import { STSVehicleRelease } from "../modals/STSVehicleReleaseModal"; +import formatTimestamp from "@/lib/formatTimestamp"; type Vehicle = { entryId: string, @@ -82,7 +83,7 @@ export const columns: ColumnDef[] = [ className="text-center" onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} > - Name + Vehicle Number
@@ -131,7 +132,7 @@ export const columns: ColumnDef[] = [ ); }, cell: ({ row }) => ( -
{row.getValue("entryTime".toLocaleString())}
+
{formatTimestamp(row.getValue("entryTime".toLocaleString()))}
), }, { @@ -206,22 +207,29 @@ export default function STSVehicleList() { columnVisibility, rowSelection, }, + initialState: { + pagination: { + pageIndex: 0, + pageSize: 4, + }, + }, }); return ( - <> -
+
+
CURRENT VEHICLES IN YOUR STS
+
- table.getColumn("name")?.setFilterValue(event.target.value) + table.getColumn("vehicleNumber")?.setFilterValue(event.target.value) } className="max-w-sm" /> @@ -297,8 +305,7 @@ export default function STSVehicleList() {
- {table.getFilteredSelectedRowModel().rows.length} of{" "} - {table.getFilteredRowModel().rows.length} row(s) selected. + Total {table.getFilteredRowModel().rows.length} row(s) fetched.
-
- +
+
); } 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/OptimizedRoute.tsx b/client/components/maps/OptimizedRoute.tsx index 6c25786..1cd53bf 100644 --- a/client/components/maps/OptimizedRoute.tsx +++ b/client/components/maps/OptimizedRoute.tsx @@ -25,6 +25,17 @@ import { useJsApiLoader, } from "@react-google-maps/api"; import { ChevronDownIcon } from "@chakra-ui/icons"; +import { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectLabel, + SelectTrigger, + SelectValue, +} from "../ui/select"; +import { set } from "react-hook-form"; +import { Crosshair } from "lucide-react"; const center = { lat: 23.7244018, lng: 90.3887196 }; @@ -35,14 +46,18 @@ type StsRouteType = { type MapProps = { coordinates: StsRouteType[]; + landFillCoordinates: StsRouteType[]; }; -const OptimizedRouteMap: React.FC = ({ coordinates }) => { +const OptimizedRouteMap: React.FC = ({ + coordinates, + landFillCoordinates, +}) => { const [routeType, setRouteType] = useState( - "Location Based Optimal Route" + "STS TO LANDFILL OPTIMAL ROUTE" ); - const [useDropdown, setUseDropdown] = useState(false); - const [useLandDropdown, setUseLandDropdown] = useState(false); + const [useDropdown, setUseDropdown] = useState(true); + const [useLandDropdown, setUseLandDropdown] = useState(true); const [searchTerm, setSearchTerm] = useState(""); const [showSuggestions, setShowSuggestions] = useState(false); @@ -51,27 +66,21 @@ const OptimizedRouteMap: React.FC = ({ coordinates }) => { //coordinate data stuffs const [allCoordinates, setAllCoordinates] = useState([]); - const [landFilCoord, setLandFillCoord] = useState({ - coordinate: "23.7244018, 90.3887196", - name: "Amin Bazar", - }); + const [landFilCoords, setLandFillCoords] = useState([]); - const suggestionsList: string[] = [ - "23.7751927, 90.3810282", - "Dhanmondi STS", - "Gulshan STS", - "Baridhara STS", - "Mohammadpur STS", - "Gulistan STS", - "Rampura STS", - ]; + const [landfillList, setLandfillList] = useState([]); useEffect(() => { const coordinateArray: string[] = coordinates.map((route) => route.name); setAllCoordinates(coordinateArray); }, [coordinates]); - const landfillList: string[] = ["Amin Bazar"]; + useEffect(() => { + //const coordinateArray: string[] = coordinates.map((route) => route.coordinate); + setLandFillCoords(landFillCoordinates); + setLandfillList(landFillCoordinates.map((route) => route.name)); + console.log(landfillList); + }, [landFillCoordinates]); //input studds @@ -84,9 +93,9 @@ const OptimizedRouteMap: React.FC = ({ coordinates }) => { const handleChangeRouteType = () => { setRouteType((prevType) => - prevType === "Location Based Optimal Route" - ? "STS to Landfill Optimal Route" - : "Location Based Optimal Route" + prevType === "LOCATION BASED OPTIMAL ROUTE" + ? "STS TO LANDFILL OPTIMAL ROUTE" + : "LOCATION BASED OPTIMAL ROUTE" ); handleChangeInputType(); handleLandChangeInputType(); @@ -94,7 +103,7 @@ const OptimizedRouteMap: React.FC = ({ coordinates }) => { const handleInputChange = (event: React.ChangeEvent) => { setSearchTerm(event.target.value); - setShowSuggestions(true); + // setShowSuggestions(true); }; const handleLandInputChange = ( event: React.ChangeEvent @@ -176,13 +185,15 @@ const OptimizedRouteMap: React.FC = ({ coordinates }) => { setDuration(results.routes[0].legs[0].duration?.text || ""); } } else { - const stsCoord = getSTSCoodrdinateByName(searchTerm); + const stsCoord = getSTSCoodrdinateByName(coordinates[parseInt(searchTerm)].name); const newString = stsCoord.substring(0, 11); - console.log(stsCoord); + //console.log(stsCoord); const directionsService = new google.maps.DirectionsService(); const results = await directionsService.route({ origin: stsCoord, - destination: landFilCoord.coordinate, + destination: + landFilCoords.find((landfill) => landfill.name === landfillList[parseInt(landTerm)]) + ?.coordinate || "", travelMode: google.maps.TravelMode.DRIVING, }); @@ -233,94 +244,61 @@ const OptimizedRouteMap: React.FC = ({ coordinates }) => { -
+
{routeType} - + */}
- - - {useDropdown ? ( -
- - {showSuggestions && ( -
    - {filteredSuggestions.map((suggestion, index) => ( -
  • handleSuggestionClick(suggestion)} - > - {suggestion} -
  • - ))} -
- )} -
- ) : ( - - - - )} -
- - {useLandDropdown ? ( -
- - {showLandSuggestion && ( -
    - {landFilteredSuggestions.map((suggestion, index) => ( -
  • handleLandSuggestionClick(suggestion)} - > - {suggestion} -
  • - ))} -
- )} -
- ) : ( - - - - )} -
- - +
+ + + = ({ coordinates }) => { onClick={clearRoute} /> - +
+ - Distance: {distance} - Duration: {duration} + + Distance: {distance}{" "} + + + Duration: {duration}{" "} + } + title="Go to center" + icon={} isRound onClick={() => { if (map) { 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/maps/getStsCoordinateForRoute.tsx b/client/components/maps/getStsCoordinateForRoute.tsx index 67e4974..d22c1e7 100644 --- a/client/components/maps/getStsCoordinateForRoute.tsx +++ b/client/components/maps/getStsCoordinateForRoute.tsx @@ -1,4 +1,3 @@ - import { ChakraProvider, theme } from "@chakra-ui/react"; import OptimizedRouteMap from "@/components/maps/OptimizedRoute"; import RouteMap from "@/components/maps/RouteMap"; @@ -6,55 +5,49 @@ import STSVehicleList from "@/components/dataTables/StsVehicleList"; import useGetAllSTS from "@/hooks/stsdata/useGetAllSTS"; import * as React from "react"; -import {useState, useEffect} from "react"; - - +import { useState, useEffect } from "react"; +import useGetAllLandfill from "@/hooks/dataQuery/useGetAllLandfill"; type StsRouteType = { - coordinate: string, - name: string, -} + coordinate: string; + name: string; +}; export default function GetStsCoordinateForRoute() { - const {stsList, getAllSTS, stsRoute } = useGetAllSTS(); - const [coordinates, setCoordinates] = useState([]); - const [stsName, setStsName] = useState([]); - const [stsRouting , setStsRouting] = useState([]); - - - - // const suggestionsList: string[] = [ - // "23.7751927, 90.3810282", - // "Bolbacchan STS", - // "Gulshan STS", - // "Baridhara STS", - // "Mohammadpur STS", - // "Gulistan STS", - // "Rampura STS", - // ]; - - // const landfillList: string[] = ["23.7618195, 90.3833253","Amin Bazar", "Chashara"]; - - - - useEffect(() => { - getAllSTS(); -console.log(stsRoute); - - - }, []); - useEffect(() => { - const coordinateArray: string[] = stsRoute.map(route => route.coordinate); - setCoordinates(coordinateArray); - setStsRouting(stsRoute); + const { stsList, getAllSTS, stsRoute } = useGetAllSTS(); + const [coordinates, setCoordinates] = useState([]); + const [stsName, setStsName] = useState([]); + const [stsRouting, setStsRouting] = useState([]); + const [landFIllRouting, setLandFIllRouting] = useState([]); + const { fetchAllLandfills, landFillData } = useGetAllLandfill(); + + useEffect(() => { + getAllSTS(); + fetchAllLandfills(); + }, []); + + useEffect(() => { + const coordinateArray: string[] = stsRoute.map((route) => route.coordinate); + setCoordinates(coordinateArray); + setStsRouting(stsRoute); + console.log(coordinateArray); + console.log(stsRoute); }, [stsRoute]); - - - console.log(coordinates); + useEffect(() => { + const landfilllist: StsRouteType[] = landFillData.map((route) => { + return { + coordinate: route.latitude + ", " + route.longitude, + name: route.name, + }; + }); + setLandFIllRouting(landfilllist); + console.log(landfilllist); + }, [landFillData]); + return ( - - - + + + ); } 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 1e11d75..02d78c7 100644 --- a/client/components/modals/STSVehicleReleaseModal.tsx +++ b/client/components/modals/STSVehicleReleaseModal.tsx @@ -7,7 +7,7 @@ import { DialogHeader, DialogTitle, DialogTrigger, - DialogClose + DialogClose, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; @@ -35,27 +35,32 @@ 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, - id: string, - vehicleNumber: string, - vehicleType: string, - capacity: string, - loadedFuelCostPerKm: string, - unloadedFuelCostPerKm: string, - landFillId: string, - entryTime: string, - landFillName: string, - stsLattitude: string, - stsLongitude: string, - landfillLattitude: string, - landfillLongitude: string, + entryId: string; + id: string; + vehicleNumber: string; + vehicleType: string; + capacity: string; + loadedFuelCostPerKm: string; + unloadedFuelCostPerKm: string; + landFillId: string; + entryTime: string; + landFillName: string; + stsLattitude: string; + stsLongitude: string; + landfillLattitude: string; + landfillLongitude: string; }; -export const STSVehicleRelease = ({ vehicleInfo }: { vehicleInfo: Vehicle }) => { +export const STSVehicleRelease = ({ + vehicleInfo, +}: { + vehicleInfo: Vehicle; +}) => { const [vehicleData, setVehicleData] = useState(vehicleInfo); - const [weightOfWaste , setWeightOfWaste] = useState(""); + const [weightOfWaste, setWeightOfWaste] = useState(""); const [exitTime, setExitTime] = useState(new Date().toLocaleString()); const [stsCoordinate, setStsCoordinate] = useState(""); const [landFillCoordinate, setLandFillCoordinate] = useState(""); @@ -68,29 +73,22 @@ export const STSVehicleRelease = ({ vehicleInfo }: { vehicleInfo: Vehicle }) => const handleDateChange = (date: Date) => { setSelectedDateTime(date); }; - - const handleSaveChanges = async () => { try { - const postEntry = await VehicleReleaseFromSTS({ stsVehicleId: vehicleInfo.entryId, - weightOfWaste: weightOfWaste, - exitTime: selectedDateTime.toISOString(), - distance: distance, - estimatedDuration: duration + weightOfWaste: weightOfWaste, + exitTime: selectedDateTime.toISOString(), + distance: distance, + estimatedDuration: duration, }); // window.location.reload(); - if(postEntry) return alert(postEntry); - + if(postEntry) return message.success(postEntry); } catch (error) { console.error("Error:", error); } - - }; - return ( @@ -111,7 +109,7 @@ export const STSVehicleRelease = ({ vehicleInfo }: { vehicleInfo: Vehicle }) => {vehicleInfo.vehicleNumber}

- Entry Time: + Entry Time: {vehicleInfo.entryTime}

@@ -124,18 +122,17 @@ export const STSVehicleRelease = ({ vehicleInfo }: { vehicleInfo: Vehicle }) =>

Optimized Route: -

-
@@ -152,7 +149,7 @@ export const STSVehicleRelease = ({ vehicleInfo }: { vehicleInfo: Vehicle }) => onChange={(e) => setWeightOfWaste(e.target.value)} />
- +
- - - + + + diff --git a/client/components/modals/StsVehicleEntryModal.tsx b/client/components/modals/StsVehicleEntryModal.tsx index 07ab140..fdec517 100644 --- a/client/components/modals/StsVehicleEntryModal.tsx +++ b/client/components/modals/StsVehicleEntryModal.tsx @@ -8,21 +8,32 @@ import { DialogHeader, DialogTitle, DialogTrigger, - DialogClose + DialogClose, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; -import React , {useState, useEffect} from "react"; +import React, { useState, useEffect } from "react"; -import { getCookie } from '@/lib/cookieFunctions'; +import { getCookie } from "@/lib/cookieFunctions"; import useVehicleEntry from "@/hooks/StsDashboard/useVehicleEntry"; import useVehicleList from "@/hooks/vehicles/useVehiclesData"; import DatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; +import { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectLabel, + SelectTrigger, + SelectValue, +} from "../ui/select"; + import useGetSTSAvailableVehicles from "@/hooks/vehicles/useSTSAvailableVehicles"; +import { message } from "antd"; interface DialogWrapperProps { @@ -45,62 +56,63 @@ type Vehicle = { export const StsVehicleEntryModal: React.FC = ({ children, }) => { - const { entryTime,setEntryTime, vehicleId, setVehicleId, VehicleEntry } = useVehicleEntry(); - const { vehicleList, vehicleNumberList, GetSTSAvailableVehicles } = useGetSTSAvailableVehicles(); - const [searchTerm, setSearchTerm] = useState(""); - const [showSuggestions, setShowSuggestions] = useState(false); - - const [weightOfWaste, setWeightOfWaste] = useState(""); - const callVehcilse = async () => { - const sucess = await GetSTSAvailableVehicles(); - if(!sucess) return alert("Wrong Vehicle Information"); - }; - - useEffect(() => { - callVehcilse(); + const { entryTime, setEntryTime, vehicleId, setVehicleId, VehicleEntry } = + useVehicleEntry(); + const { vehicleList, vehicleNumberList, GetSTSAvailableVehicles } = useGetSTSAvailableVehicles(); + + const [searchTerm, setSearchTerm] = useState(""); + const [showSuggestions, setShowSuggestions] = useState(false); - }, []); + const [weightOfWaste, setWeightOfWaste] = useState(""); + const callVehcilse = async () => { + const sucess = await GetSTSAvailableVehicles(); + if(!sucess) return message.error("Wrong Vehicle Information"); + }; - const [selectedDateTime, setSelectedDateTime] = useState(new Date()); + useEffect(() => { + callVehcilse(); + }, []); -const handleDateChange = (date: Date) => { - setSelectedDateTime(date); -}; + const [selectedDateTime, setSelectedDateTime] = useState(new Date()); + + const handleDateChange = (date: Date) => { + setSelectedDateTime(date); + }; + + const handleInputChange = (event: React.ChangeEvent) => { + setSearchTerm(event.target.value); + setShowSuggestions(true); + }; + const handleSuggestionClick = (suggestion: string) => { + setSearchTerm(suggestion); + setShowSuggestions(false); + }; - - const handleInputChange = (event: React.ChangeEvent) => { - setSearchTerm(event.target.value); - setShowSuggestions(true); - }; - const handleSuggestionClick = (suggestion: string) => { - setSearchTerm(suggestion); - setShowSuggestions(false); - }; - - const filteredSuggestions = vehicleNumberList.filter((suggestion) => - suggestion.toString().toLowerCase().includes(searchTerm.toString().toLowerCase()) + const filteredSuggestions = vehicleNumberList.filter((suggestion) => + suggestion + .toString() + .toLowerCase() + .includes(searchTerm.toString().toLowerCase()) ); const getVehicleIdByNumber = (vehicleNumber: string): string | undefined => { - const vehicle = vehicleList.find(vehicle => vehicle.vehicleNumber === vehicleNumber); + const vehicle = vehicleList.find( + (vehicle) => vehicle.vehicleNumber === vehicleNumber + ); if (vehicle) { - return vehicle.id.toString(); + return vehicle.id.toString(); } - + // If vehicle is not found, return undefined return "no vehicle"; -}; + }; - - - const handleSaveChanges = async () => { setVehicleId(searchTerm); - - - // console.log(vehicleId); + + // console.log(vehicleId); //console.log(entryTime); const vehicleId = getVehicleIdByNumber(searchTerm); @@ -110,15 +122,11 @@ const handleDateChange = (date: Date) => { vehicleIds: vehicleId, entryTimes: selectedDateTime.toISOString(), }); - - if(postEntry) return alert(postEntry); - + if(postEntry) return message.success(postEntry); } catch (error) { console.error("Error:", error); } }; - - return ( @@ -134,63 +142,53 @@ const handleDateChange = (date: Date) => {
-
-
- - - + + + -
); diff --git a/client/components/modals/VehicleModal.tsx b/client/components/modals/VehicleModal.tsx index 87e9ba7..b0ae6b0 100644 --- a/client/components/modals/VehicleModal.tsx +++ b/client/components/modals/VehicleModal.tsx @@ -32,6 +32,8 @@ import { } from "../ui/select"; 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; @@ -41,27 +43,26 @@ export const VehicleCreateModal: React.FC = ({ children, }) => { const [vehicleNumber, setVehicleNumber] = useState(""); - const [vehicleType, setVehicleType] = useState("Dump Truck"); - const [capacity, setCapacity] = useState(); + const [vehicleType, setVehicleType] = useState("Open Truck"); + const [capacity, setCapacity] = useState(3); const [loadedFuelCostPerKm, setLoadedFuelCostPerKm] = useState(); const [unloadedFuelCostPerKm, setUnloadedFuelCostPerKm] = useState(); const [assignedLandfill, setAssignedLandfill] = useState(""); + const [assignedSTS, setAssignedSTS] = useState(""); const {createVehicle} = useCreateVehicle(); const vehicleTypeList = [ + "Open Truck", "Dump Truck", "Compactor Truck", - "Open Truck", "Container Carrier", ]; - const { landFillData, fetchAllLandfills } = useGetAllLandfill(); + const { landFillData } = useGetAllLandfill(); + const { stsList } = useGetAllSTS(); useEffect(() => {}, [landFillData]); + 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, @@ -69,8 +70,9 @@ export const VehicleCreateModal: React.FC = ({ loadedFuelCostPerKm: loadedFuelCostPerKm || 0, unloadedFuelCostPerKm: unloadedFuelCostPerKm || 0, landFillId: assignedLandfill, + stsId: assignedSTS, }) - if(res) return alert(res); + if(res) return message.success(res); }; return ( @@ -105,7 +107,13 @@ export const VehicleCreateModal: React.FC = ({ = ({
+
+ + +
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 84d13ff..cb69c1d 100644 --- a/client/components/modals/vehicleControl/EditVehicleInfoModal.tsx +++ b/client/components/modals/vehicleControl/EditVehicleInfoModal.tsx @@ -31,6 +31,8 @@ import editSTS from "@/hooks/entityCreation/editSTS"; 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, @@ -41,20 +43,24 @@ type Vehicle = { unloadedFuelCostPerKm: string, landFillId: string, landFillName: string, + stsId: string, }; export const EditVehicleInfoModal = ({ vehicleInfo }: { vehicleInfo: Vehicle }) => { const [vehicleData, setvehicleData] = useState(vehicleInfo); const [selectedLandfill, setSelectedLandfill] = useState(vehicleInfo.landFillId); + const [selectedSTS, setSelectedSTS] = useState(vehicleInfo.stsId); const vehicleTypeList = [ + "Open Truck", "Dump Truck", "Compactor Truck", - "Open Truck", "Container Carrier", ]; const {landFillData} = useGetAllLandfill(); + const {stsList} = useGetAllSTS(); useEffect(() => {}, [landFillData]); + useEffect(() => {}, [stsList]); return ( @@ -173,7 +179,7 @@ export const EditVehicleInfoModal = ({ vehicleInfo }: { vehicleInfo: Vehicle }) - Roles + Landfill {landFillData.map((landfill) => ( {landfill.name} @@ -183,13 +189,36 @@ export const EditVehicleInfoModal = ({ vehicleInfo }: { vehicleInfo: Vehicle }) +
+ + +