summaryrefslogtreecommitdiff
path: root/mobile/lib/cart.dart
diff options
context:
space:
mode:
authoromagdy7 <omar.professional8777@gmail.com>2023-12-23 01:39:59 +0200
committeromagdy7 <omar.professional8777@gmail.com>2023-12-23 01:39:59 +0200
commitfbaae8f461ff085356670d41506cd92180227beb (patch)
treea7a6b9c83f22961c1b4e5cea02841a2f58f81116 /mobile/lib/cart.dart
parent776f680ca58d066e24284b009eb9a28ced03a6ea (diff)
downloadcarpool-fbaae8f461ff085356670d41506cd92180227beb.tar.xz
carpool-fbaae8f461ff085356670d41506cd92180227beb.zip
Final version
Diffstat (limited to 'mobile/lib/cart.dart')
-rw-r--r--mobile/lib/cart.dart46
1 files changed, 40 insertions, 6 deletions
diff --git a/mobile/lib/cart.dart b/mobile/lib/cart.dart
index 109e407..7464bb4 100644
--- a/mobile/lib/cart.dart
+++ b/mobile/lib/cart.dart
@@ -1,3 +1,5 @@
+import 'package:cloud_firestore/cloud_firestore.dart';
+import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
// Define a Ride class to represent the selected ride
@@ -5,13 +7,23 @@ class Ride {
final String name;
final String startLocation;
final String endLocation;
- final String time;
+ final String carBrand;
+ final String carModel;
+ final String carColor;
+ final String plateNumber;
+ final String status;
+ final DateTime orderTime;
Ride({
required this.name,
required this.startLocation,
required this.endLocation,
- required this.time,
+ required this.carBrand,
+ required this.carModel,
+ required this.carColor,
+ required this.plateNumber,
+ required this.status,
+ required this.orderTime,
});
}
@@ -70,7 +82,7 @@ class CartPage extends StatelessWidget {
children: [
const Icon(Icons.access_time, color: Colors.blue),
const SizedBox(width: 4),
- Text(selectedRide.time),
+ // Text(selectedRide.orderTime.toString()),
],
),
],
@@ -78,9 +90,31 @@ class CartPage extends StatelessWidget {
),
const SizedBox(height: 20),
ElevatedButton(
- onPressed: () {
- // Implement payment or confirmation logic here
- // For now, just print a message
+ onPressed: () async {
+ FirebaseFirestore firestore = FirebaseFirestore.instance;
+ User? user = FirebaseAuth.instance.currentUser;
+
+ if (user != null) {
+ String userId = user.uid;
+ CollectionReference collection =
+ firestore.collection('RideRequest');
+
+ Map<String, dynamic> data = {
+ 'dropOff': selectedRide.endLocation,
+ 'pickUp': selectedRide.startLocation,
+ 'status': "Pending",
+ 'cost': "50",
+ 'passengerID': userId,
+ };
+
+ try {
+ await collection.add(data);
+ print('Document added successfully!');
+ } catch (e) {
+ print('Error adding document: $e');
+ }
+ }
+
print('Processing Requesting Ride');
},
child: const Text('Request Ride'),