diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index c1e0058..6d925e9 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -31,7 +31,7 @@ import Protocols from "./components/Policies/protocols.tsx"; import Rules from "./components/Policies/rules.tsx"; import ChangePassword from "./pages/ChangePassword.tsx"; import AddViolationPage from "./pages/AddViolationPage.tsx"; -// import SendNotif from "./pages/SendNotif.tsx"; +import SendNotif from "./pages/SendNotif.tsx"; const Main = () => { const { appLoading }: LoadingContextType = useLoading(); @@ -68,17 +68,38 @@ const Main = () => { {/* ADMIN ROUTES */} }> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - {/* } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } - /> */} + /> diff --git a/frontend/src/pages/SendNotif.tsx b/frontend/src/pages/SendNotif.tsx new file mode 100644 index 0000000..44435b3 --- /dev/null +++ b/frontend/src/pages/SendNotif.tsx @@ -0,0 +1,93 @@ +import { useParams } from 'react-router-dom'; +import { useState, useEffect } from 'react'; +import AdminHeader from '../components/AdminHeader'; +import useGetDriver from '../hooks/driver-hooks/useGetDriver'; +import { DriverWithVandC } from '../types/datatypes'; +import Loading from '../components/Loading'; +import { toast } from 'react-toastify'; + +const SendNotif: React.FC = () => { + const { id } = useParams<{ id: string }>(); + const [title, setTitle] = useState(''); + const [message, setMessage] = useState(''); + const { loading, driver } = useGetDriver(id!); + + const [formData, setFormData] = useState(null); + + useEffect(() => { + if (driver) { + setFormData({ + id: driver.id, + last_name: driver.last_name, + first_name: driver.first_name, + middle_name: driver.middle_name, + }); + } + }, [driver]); + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + if (!formData) return; + toast.success('Message submitted for driver'); + setTitle(''); + setMessage(''); + }; + + if (loading) { + return ; + } + + if (!formData) { + return
Error: Driver not found.
; + } + + return ( +
+ +
+
+
+

+ Send a Notification to

+

{formData.last_name}, {formData.first_name}

+
+ + +
+
+ + setTitle(e.target.value)} + className="w-full text-white px-3 py-2 bg-secondgrey border font-syke-bold border-secondgrey rounded shadow-sm focus:outline-none focus:ring-2 focus:ring-buttongreen focus:border-buttongreen" + required + /> +
+
+ + +
+ +
+
+
+
+ ); +}; + +export default SendNotif;