summaryrefslogtreecommitdiff
path: root/driver/src
diff options
context:
space:
mode:
Diffstat (limited to 'driver/src')
-rw-r--r--driver/src/App.tsx173
-rw-r--r--driver/src/components/ui/button.tsx56
-rw-r--r--driver/src/components/ui/dialog.tsx120
-rw-r--r--driver/src/components/ui/input.tsx25
-rw-r--r--driver/src/components/ui/label.tsx24
-rw-r--r--driver/src/firebase/firebase_config.ts2
-rw-r--r--driver/src/index.css74
-rw-r--r--driver/src/lib/utils.ts6
-rw-r--r--driver/src/main.tsx24
9 files changed, 498 insertions, 6 deletions
diff --git a/driver/src/App.tsx b/driver/src/App.tsx
index 4970091..233b96d 100644
--- a/driver/src/App.tsx
+++ b/driver/src/App.tsx
@@ -1,11 +1,176 @@
-import Login from "./pages/Login"
-import SignUp from "./pages/SignUp"
+import { addDoc, collection } from "firebase/firestore"
+import { db } from "./firebase/firebase_config"
+import { Button } from "@/components/ui/button"
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger,
+} from "@/components/ui/dialog"
+import { Input } from "@/components/ui/input"
+import { Label } from "@/components/ui/label"
+import { useState } from "react"
+
+interface RideOrder {
+ driverName: string
+ carModel: string
+ carColor: string
+ plateNumber: string
+ status: string
+ orderTime: Date
+ fromLocation: string
+ toLocation: string
+}
+
function App() {
+
+ const [driverName, setDriverName] = useState<string>()
+ const [carModel, setCarModel] = useState<string>()
+ const [carColor, setCarColor] = useState<string>()
+ const [plateNumber, setPlateNumber] = useState<string>()
+ const [status, _setStatus] = useState<string>('Pending')
+ const [orderTime, _setOrderTime] = useState<Date>(new Date())
+ const [fromLocation, setFromLocation] = useState<string>()
+ const [toLocation, setToLocation] = useState<string>()
+
+ const [_rideOrder, _setRideOrder] = useState<RideOrder>({
+ driverName: "Mahmoud",
+ carModel: "Toyota Corolla",
+ carColor: "Red",
+ plateNumber: "ABC-123",
+ status: "Pending",
+ orderTime: new Date("2023-12-20"),
+ fromLocation: "Abdu-Basha",
+ toLocation: "5th Settlement",
+ })
+
+ const addRideOrderToFirestore = async () => {
+ try {
+ // Get a reference to the 'rideOrders' collection
+ const rideOrdersCollection = collection(db, 'Rides');
+
+ // Add a new document to the 'rideOrders' collection with the data from the RideOrder object
+ const newRideOrderRef = await addDoc(rideOrdersCollection, {
+ driverName: driverName,
+ carModel: carModel,
+ carColor: carColor,
+ plateNumber: plateNumber,
+ status: status,
+ orderTime: orderTime,
+ fromLocation: fromLocation,
+ toLocation: toLocation,
+ });
+
+ console.log('Ride order added with ID:', newRideOrderRef.id);
+ // 'newRideOrderRef.id' will give you the document ID of the added ride order
+ } catch (error) {
+ console.error('Error adding ride order:', error);
+ }
+ };
+
return (
- // <SignUp />
- <Login />
+ <div className="bg-white h-screen w-screen flex items-center justify-center">
+ <Dialog>
+ <DialogTrigger asChild>
+ <Button className="rounded-xl" variant="outline">Add Ride</Button>
+ </DialogTrigger>
+ <DialogContent className="sm:max-w-[425px]">
+ <DialogHeader>
+ <DialogTitle>Ride details</DialogTitle>
+ <DialogDescription>
+ Please enter details about your ride and click submit for the ride to appear to other students!
+ </DialogDescription>
+ </DialogHeader>
+ <div className="grid gap-4 py-4">
+ <div className="grid grid-cols-4 items-center gap-4">
+ <Label htmlFor="name" className="text-right">
+ Name
+ </Label>
+ <Input
+ id="Name"
+ defaultValue=""
+ className="col-span-3"
+ onChange={(e) => setDriverName(e.target.value)}
+ />
+ </div>
+ <div className="grid grid-cols-4 items-center gap-4">
+ <Label htmlFor="Car Model" className="text-right">
+ Car Model
+ </Label>
+ <Input
+ id="Car Model"
+ defaultValue=""
+ className="col-span-3"
+ onChange={(e) => setCarModel(e.target.value)}
+ />
+ </div>
+ <div className="grid grid-cols-4 items-center gap-4">
+ <Label htmlFor="To Location" className="text-right">
+ To Location
+ </Label>
+ <Input
+ id="To Location"
+ defaultValue=""
+ className="col-span-3"
+ onChange={(e) => setToLocation(e.target.value)}
+ />
+ </div>
+ <div className="grid grid-cols-4 items-center gap-4">
+ <Label htmlFor="From location" className="text-right">
+ From location
+ </Label>
+ <Input
+ id="From location"
+ defaultValue=""
+ className="col-span-3"
+ onChange={(e) => setFromLocation(e.target.value)}
+ />
+ </div>
+ <div className="grid grid-cols-4 items-center gap-4">
+ <Label htmlFor="Car color" className="text-right">
+ Car color
+ </Label>
+ <Input
+ id="Car color"
+ defaultValue=""
+ className="col-span-3"
+ onChange={(e) => setCarColor(e.target.value)}
+ />
+ </div>
+ <div className="grid grid-cols-4 items-center gap-4">
+ <Label htmlFor="Plate Number" className="text-right">
+ Plate Number
+ </Label>
+ <Input
+ id="Plate Number"
+ defaultValue=""
+ className="col-span-3"
+ onChange={(e) => setPlateNumber(e.target.value)}
+ />
+ </div>
+ </div>
+ <DialogFooter>
+ <Button type="submit" onClick={addRideOrderToFirestore}>Add Ride</Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ </div>
)
}
+// interface RideOrder {
+// driverName: string
+// carModel: string
+// carColor: string
+// plateNumber: string
+// status: string
+// orderTime: Date
+// fromLocation: string
+// toLocation: string
+// }
+
export default App
diff --git a/driver/src/components/ui/button.tsx b/driver/src/components/ui/button.tsx
new file mode 100644
index 0000000..0ba4277
--- /dev/null
+++ b/driver/src/components/ui/button.tsx
@@ -0,0 +1,56 @@
+import * as React from "react"
+import { Slot } from "@radix-ui/react-slot"
+import { cva, type VariantProps } from "class-variance-authority"
+
+import { cn } from "@/lib/utils"
+
+const buttonVariants = cva(
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
+ {
+ variants: {
+ variant: {
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
+ destructive:
+ "bg-destructive text-destructive-foreground hover:bg-destructive/90",
+ outline:
+ "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
+ secondary:
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80",
+ ghost: "hover:bg-accent hover:text-accent-foreground",
+ link: "text-primary underline-offset-4 hover:underline",
+ },
+ size: {
+ default: "h-10 px-4 py-2",
+ sm: "h-9 rounded-md px-3",
+ lg: "h-11 rounded-md px-8",
+ icon: "h-10 w-10",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ size: "default",
+ },
+ }
+)
+
+export interface ButtonProps
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
+ VariantProps<typeof buttonVariants> {
+ asChild?: boolean
+}
+
+const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
+ const Comp = asChild ? Slot : "button"
+ return (
+ <Comp
+ className={cn(buttonVariants({ variant, size, className }))}
+ ref={ref}
+ {...props}
+ />
+ )
+ }
+)
+Button.displayName = "Button"
+
+export { Button, buttonVariants }
diff --git a/driver/src/components/ui/dialog.tsx b/driver/src/components/ui/dialog.tsx
new file mode 100644
index 0000000..bcaf970
--- /dev/null
+++ b/driver/src/components/ui/dialog.tsx
@@ -0,0 +1,120 @@
+import * as React from "react"
+import * as DialogPrimitive from "@radix-ui/react-dialog"
+import { X } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+const Dialog = DialogPrimitive.Root
+
+const DialogTrigger = DialogPrimitive.Trigger
+
+const DialogPortal = DialogPrimitive.Portal
+
+const DialogClose = DialogPrimitive.Close
+
+const DialogOverlay = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Overlay>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Overlay
+ ref={ref}
+ className={cn(
+ "fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
+ className
+ )}
+ {...props}
+ />
+))
+DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
+
+const DialogContent = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
+>(({ className, children, ...props }, ref) => (
+ <DialogPortal>
+ <DialogOverlay />
+ <DialogPrimitive.Content
+ ref={ref}
+ className={cn(
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
+ <X className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+ </DialogPrimitive.Content>
+ </DialogPortal>
+))
+DialogContent.displayName = DialogPrimitive.Content.displayName
+
+const DialogHeader = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn(
+ "flex flex-col space-y-1.5 text-center sm:text-left",
+ className
+ )}
+ {...props}
+ />
+)
+DialogHeader.displayName = "DialogHeader"
+
+const DialogFooter = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn(
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
+ className
+ )}
+ {...props}
+ />
+)
+DialogFooter.displayName = "DialogFooter"
+
+const DialogTitle = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Title>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Title
+ ref={ref}
+ className={cn(
+ "text-lg font-semibold leading-none tracking-tight",
+ className
+ )}
+ {...props}
+ />
+))
+DialogTitle.displayName = DialogPrimitive.Title.displayName
+
+const DialogDescription = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Description>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Description
+ ref={ref}
+ className={cn("text-sm text-muted-foreground", className)}
+ {...props}
+ />
+))
+DialogDescription.displayName = DialogPrimitive.Description.displayName
+
+export {
+ Dialog,
+ DialogPortal,
+ DialogOverlay,
+ DialogClose,
+ DialogTrigger,
+ DialogContent,
+ DialogHeader,
+ DialogFooter,
+ DialogTitle,
+ DialogDescription,
+}
diff --git a/driver/src/components/ui/input.tsx b/driver/src/components/ui/input.tsx
new file mode 100644
index 0000000..677d05f
--- /dev/null
+++ b/driver/src/components/ui/input.tsx
@@ -0,0 +1,25 @@
+import * as React from "react"
+
+import { cn } from "@/lib/utils"
+
+export interface InputProps
+ extends React.InputHTMLAttributes<HTMLInputElement> {}
+
+const Input = React.forwardRef<HTMLInputElement, InputProps>(
+ ({ className, type, ...props }, ref) => {
+ return (
+ <input
+ type={type}
+ className={cn(
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
+ className
+ )}
+ ref={ref}
+ {...props}
+ />
+ )
+ }
+)
+Input.displayName = "Input"
+
+export { Input }
diff --git a/driver/src/components/ui/label.tsx b/driver/src/components/ui/label.tsx
new file mode 100644
index 0000000..683faa7
--- /dev/null
+++ b/driver/src/components/ui/label.tsx
@@ -0,0 +1,24 @@
+import * as React from "react"
+import * as LabelPrimitive from "@radix-ui/react-label"
+import { cva, type VariantProps } from "class-variance-authority"
+
+import { cn } from "@/lib/utils"
+
+const labelVariants = cva(
+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
+)
+
+const Label = React.forwardRef<
+ React.ElementRef<typeof LabelPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
+ VariantProps<typeof labelVariants>
+>(({ className, ...props }, ref) => (
+ <LabelPrimitive.Root
+ ref={ref}
+ className={cn(labelVariants(), className)}
+ {...props}
+ />
+))
+Label.displayName = LabelPrimitive.Root.displayName
+
+export { Label }
diff --git a/driver/src/firebase/firebase_config.ts b/driver/src/firebase/firebase_config.ts
index 43a458c..ca0a3e6 100644
--- a/driver/src/firebase/firebase_config.ts
+++ b/driver/src/firebase/firebase_config.ts
@@ -1,6 +1,7 @@
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
+import { getFirestore } from "firebase/firestore";
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
@@ -17,3 +18,4 @@ const firebaseConfig = {
// Initialize Firebase
const app = initializeApp(firebaseConfig);
export const auth = getAuth(app)
+export const db = getFirestore(app)
diff --git a/driver/src/index.css b/driver/src/index.css
index b5c61c9..cd4a6b1 100644
--- a/driver/src/index.css
+++ b/driver/src/index.css
@@ -1,3 +1,77 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
+
+@layer base {
+ :light {
+ --background: 0 0% 100%;
+ --foreground: 222.2 84% 4.9%;
+
+ --card: 0 0% 100%;
+ --card-foreground: 222.2 84% 4.9%;
+
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9%;
+
+ --primary: 222.2 47.4% 11.2%;
+ --primary-foreground: 210 40% 98%;
+
+ --secondary: 210 40% 96.1%;
+ --secondary-foreground: 222.2 47.4% 11.2%;
+
+ --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%;
+
+ --accent: 210 40% 96.1%;
+ --accent-foreground: 222.2 47.4% 11.2%;
+
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 40% 98%;
+
+ --border: 214.3 31.8% 91.4%;
+ --input: 214.3 31.8% 91.4%;
+ --ring: 222.2 84% 4.9%;
+
+ --radius: 0.5rem;
+ }
+
+ :root {
+ --background: 222.2 84% 4.9%;
+ --foreground: 210 40% 98%;
+
+ --card: 222.2 84% 4.9%;
+ --card-foreground: 210 40% 98%;
+
+ --popover: 222.2 84% 4.9%;
+ --popover-foreground: 210 40% 98%;
+
+ --primary: 210 40% 98%;
+ --primary-foreground: 222.2 47.4% 11.2%;
+
+ --secondary: 217.2 32.6% 17.5%;
+ --secondary-foreground: 210 40% 98%;
+
+ --muted: 217.2 32.6% 17.5%;
+ --muted-foreground: 215 20.2% 65.1%;
+
+ --accent: 217.2 32.6% 17.5%;
+ --accent-foreground: 210 40% 98%;
+
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 40% 98%;
+
+ --border: 217.2 32.6% 17.5%;
+ --input: 217.2 32.6% 17.5%;
+ --ring: 212.7 26.8% 83.9%;
+ }
+}
+
+@layer base {
+ * {
+ @apply border-border;
+ }
+
+ body {
+ @apply text-foreground;
+ }
+}
diff --git a/driver/src/lib/utils.ts b/driver/src/lib/utils.ts
new file mode 100644
index 0000000..ec79801
--- /dev/null
+++ b/driver/src/lib/utils.ts
@@ -0,0 +1,6 @@
+import { type ClassValue, clsx } from "clsx"
+import { twMerge } from "tailwind-merge"
+
+export function cn(...inputs: ClassValue[]) {
+ return twMerge(clsx(inputs))
+}
diff --git a/driver/src/main.tsx b/driver/src/main.tsx
index 3d7150d..300ddc1 100644
--- a/driver/src/main.tsx
+++ b/driver/src/main.tsx
@@ -1,10 +1,30 @@
import React from 'react'
+import { createBrowserRouter, RouterProvider } from 'react-router-dom'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
+import Login from './pages/Login.tsx'
+import SignUp from './pages/SignUp.tsx'
+
+
+
+const router = createBrowserRouter([
+ {
+ path: "/",
+ element: <App />
+ },
+ {
+ path: "/signup",
+ element: <SignUp />
+ },
+ {
+ path: "/login",
+ element: <Login />
+ },
+])
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
- <App />
- </React.StrictMode>,
+ <RouterProvider router={router} />
+ </React.StrictMode>
)