summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRishi-k-s <rishikrishna.sr@gmail.com>2021-08-17 22:43:39 +0530
committerRishi-k-s <rishikrishna.sr@gmail.com>2021-08-17 22:43:39 +0530
commit56daf49aee4eb3347eca7b5fd7d55664d111f496 (patch)
tree1baffd793cf426311d2ee0e6a2e503e2ca5c4018
parentea34e7fae5145bae88fc945ff3c1ea441647adf3 (diff)
Added List
-rw-r--r--lib/CheckDocPatient.dart4
-rw-r--r--lib/gogl cal/calhelper.dart1
-rw-r--r--lib/main_UI/Doctor/doctorDashboard.dart4
-rw-r--r--lib/main_UI/Patient/PatientDashboard.dart17
-rw-r--r--lib/main_UI/Patient/createP2P.dart5
-rw-r--r--lib/models/calModel.dart4
-rw-r--r--lib/services/authService.dart2
-rw-r--r--lib/services/database.dart24
8 files changed, 56 insertions, 5 deletions
diff --git a/lib/CheckDocPatient.dart b/lib/CheckDocPatient.dart
index 7e98ebc..c7d1071 100644
--- a/lib/CheckDocPatient.dart
+++ b/lib/CheckDocPatient.dart
@@ -1,8 +1,8 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:healthtastic/auth/LoginPage.dart';
-import 'package:healthtastic/main_UI/PatientDashboard.dart';
-import 'package:healthtastic/main_UI/doctorDashboard.dart';
+import 'package:healthtastic/main_UI/Patient/PatientDashboard.dart';
+import 'package:healthtastic/main_UI/Doctor/doctorDashboard.dart';
import 'package:healthtastic/services/authService.dart';
import 'package:healthtastic/services/database.dart';
diff --git a/lib/gogl cal/calhelper.dart b/lib/gogl cal/calhelper.dart
index 29d92d4..5948bc0 100644
--- a/lib/gogl cal/calhelper.dart
+++ b/lib/gogl cal/calhelper.dart
@@ -9,6 +9,7 @@ class CalendarClient {
required String description,
required String location,
required String docName,
+ required String docUid,
required String allergies,
required bool hasConferenceSupport,
required DateTime startTime,
diff --git a/lib/main_UI/Doctor/doctorDashboard.dart b/lib/main_UI/Doctor/doctorDashboard.dart
index 76e3519..47c597e 100644
--- a/lib/main_UI/Doctor/doctorDashboard.dart
+++ b/lib/main_UI/Doctor/doctorDashboard.dart
@@ -16,6 +16,7 @@ class DoctorDashboard extends StatefulWidget {
class _DoctorDashboardState extends State<DoctorDashboard> {
Storage storage = Storage();
+ String? docUid;
int _currentIndex = 0;
@override
@@ -60,6 +61,7 @@ class _DoctorDashboardState extends State<DoctorDashboard> {
builder: (context, snapshot) {
if (snapshot.hasData) {
if (snapshot.data!.docs.length > 0) {
+ if (snapshot.data!.docs.contains('$docUid')) {}
return ListView.builder(
physics: BouncingScrollPhysics(),
itemCount: snapshot.data!.docs.length,
@@ -223,7 +225,7 @@ class _DoctorDashboardState extends State<DoctorDashboard> {
backgroundColor: Colors.lightBlue[900],
),
BottomNavigationBarItem(
- icon: Icon(Icons.add),
+ icon: Icon(Icons.edit),
label: 'New',
backgroundColor: Colors.lightBlue[900],
),
diff --git a/lib/main_UI/Patient/PatientDashboard.dart b/lib/main_UI/Patient/PatientDashboard.dart
index e46ca6a..8eb0273 100644
--- a/lib/main_UI/Patient/PatientDashboard.dart
+++ b/lib/main_UI/Patient/PatientDashboard.dart
@@ -7,6 +7,7 @@ import 'package:healthtastic/main_UI/Patient/createP2P.dart';
import 'package:healthtastic/models/calModel.dart';
import 'package:healthtastic/services/authService.dart';
import 'package:healthtastic/gogl%20cal/calhelper.dart';
+import 'package:healthtastic/services/database.dart';
import 'package:intl/intl.dart';
import 'package:url_launcher/url_launcher.dart';
@@ -18,6 +19,22 @@ class PatientDashboard extends StatefulWidget {
class _PatientDashboardState extends State<PatientDashboard> {
Storage storage = Storage();
int _currentIndex = 0;
+ List<String> uidList = <String>[];
+ Future<void> getDocData() async {
+ List<String> doctorUidFromFirestore = await UserHelper.getDoctorUid();
+ setState(() {
+ uidList = doctorUidFromFirestore;
+ });
+ }
+
+ @override
+ void initState() {
+ WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
+ getDocData();
+ });
+ // TODO: implement initState
+ super.initState();
+ }
@override
Widget build(BuildContext context) {
diff --git a/lib/main_UI/Patient/createP2P.dart b/lib/main_UI/Patient/createP2P.dart
index 1871a9e..17ec3a6 100644
--- a/lib/main_UI/Patient/createP2P.dart
+++ b/lib/main_UI/Patient/createP2P.dart
@@ -1,3 +1,4 @@
+import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:googleapis/analyticsreporting/v4.dart';
import 'package:googleapis/calendar/v3.dart' as calendar;
@@ -6,6 +7,7 @@ import 'package:healthtastic/main_UI/Patient/PatientDetails.dart';
import 'package:healthtastic/models/calModel.dart';
import 'package:healthtastic/gogl%20cal/calDatabase.dart';
import 'package:healthtastic/gogl%20cal/calhelper.dart';
+import 'package:healthtastic/services/database.dart';
import 'package:intl/intl.dart';
class CreateAppoin extends StatefulWidget {
@@ -30,6 +32,7 @@ class _CreateAppoinState extends State<CreateAppoin> {
String title = '';
String docName = '';
+ String docUid = '';
String desc = '';
String location = '';
String allergies = '';
@@ -176,6 +179,7 @@ class _CreateAppoinState extends State<CreateAppoin> {
description: desc,
location: location,
docName: docName,
+ docUid: docUid,
allergies: allergies,
hasConferenceSupport: true,
shouldNotifyAttendees: true,
@@ -201,6 +205,7 @@ class _CreateAppoinState extends State<CreateAppoin> {
hasConfereningSupport: true,
startTimeInEpoch: startTimeInEpoch,
endTimeInEpoch: endTimeInEpoch,
+ docUid: docUid,
);
await storage.storeEventData(eventInfo).whenComplete(() => Navigator.of(context).pop());
diff --git a/lib/models/calModel.dart b/lib/models/calModel.dart
index 68de017..426bf05 100644
--- a/lib/models/calModel.dart
+++ b/lib/models/calModel.dart
@@ -6,6 +6,7 @@ class EventInfo {
final String description;
final String location;
final String link;
+ final String docUid;
final String docName;
final String allergies;
final List<dynamic> attendeeEmails;
@@ -27,6 +28,7 @@ class EventInfo {
required this.hasConfereningSupport,
required this.startTimeInEpoch,
required this.endTimeInEpoch,
+ required this.docUid,
});
EventInfo.fromMap(Map snapshot)
@@ -41,6 +43,7 @@ class EventInfo {
shouldNotifyAttendees = snapshot['should_notify'],
hasConfereningSupport = snapshot['has_conferencing'],
startTimeInEpoch = snapshot['start'],
+ docUid = snapshot['docUid'],
endTimeInEpoch = snapshot['end'];
toJson() {
@@ -57,6 +60,7 @@ class EventInfo {
'has_conferencing': hasConfereningSupport,
'start': startTimeInEpoch,
'end': endTimeInEpoch,
+ 'docUid': docUid,
};
}
}
diff --git a/lib/services/authService.dart b/lib/services/authService.dart
index 3638b31..16380ad 100644
--- a/lib/services/authService.dart
+++ b/lib/services/authService.dart
@@ -36,7 +36,7 @@ class AuthService {
try {
UserCredential result = await _auth.createUserWithEmailAndPassword(email: email!, password: password!);
- await UserHelper(uid: result.user!.uid).addStudentRegisToFirebase(name!, email, aadar!, result.user!.uid, role!);
+ await UserHelper(uid: result.user!.uid).addUserRegisToFirebase(name!, email, aadar!, result.user!.uid, role!);
// add role to firebase
return 'SignedUp';
} on FirebaseAuthException catch (e) {
diff --git a/lib/services/database.dart b/lib/services/database.dart
index a341ff6..c160111 100644
--- a/lib/services/database.dart
+++ b/lib/services/database.dart
@@ -12,7 +12,7 @@ class UserHelper {
static FirebaseAuth auth = FirebaseAuth.instance;
static FirebaseFirestore _database = FirebaseFirestore.instance;
- Future<void> addStudentRegisToFirebase(String name, String email, String aadar, String uid, String role) async {
+ Future<void> addUserRegisToFirebase(String name, String email, String aadar, String uid, String role) async {
return await _database.collection('users').doc(uid).set({
"name": name,
"email": email,
@@ -31,4 +31,26 @@ class UserHelper {
});
return role;
}
+
+ // Get Doctor Uid
+ static getDoctorUid() async {
+ final User user = auth.currentUser!;
+ final uid = user.uid;
+ List<String> uidList = <String>[];
+ try {
+ await FirebaseFirestore.instance.collection("users").doc('$uid').get().then((value) {
+ // first add the data to the Offset object
+ List.from(value.data()!['Appoiments']).forEach((element) {
+ String data = element;
+ //then add the data to the List<Offset>, now we have a type Offset
+ uidList.add(data);
+ });
+ });
+ print('uvvvvvv +$uidList');
+ return uidList;
+ } catch (e) {
+ print('uvvvvvv + null');
+ return null;
+ }
+ }
}