forked from yaso_meth/mih-project
Update app top cater for env variables
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:patient_manager/components/BuildFileView.dart';
|
||||
import 'package:patient_manager/components/mybutton.dart';
|
||||
import 'package:patient_manager/env/env.dart';
|
||||
import 'package:patient_manager/main.dart';
|
||||
import 'package:patient_manager/objects/files.dart';
|
||||
//import 'dart:js' as js;
|
||||
@@ -56,14 +57,16 @@ class _BuildFilesListState extends State<BuildFilesList> {
|
||||
const SizedBox(height: 25.0),
|
||||
Expanded(
|
||||
child: BuildFileView(
|
||||
pdfLink: "http://localhost:9000/mih/$filename")),
|
||||
pdfLink:
|
||||
"${AppEnviroment.baseFileUrl}/mih/$filename")),
|
||||
SizedBox(
|
||||
width: 300,
|
||||
height: 100,
|
||||
child: MyButton(
|
||||
onTap: () {
|
||||
html.window.open(
|
||||
'http://localhost:9000/mih/$filename', 'download');
|
||||
'${AppEnviroment.baseFileUrl}/mih/$filename',
|
||||
'download');
|
||||
},
|
||||
buttonText: "Dowload",
|
||||
buttonColor: MzanziInnovationHub.of(context)!
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:patient_manager/components/buildMedList.dart';
|
||||
import 'package:patient_manager/components/myErrorMessage.dart';
|
||||
import 'package:patient_manager/env/env.dart';
|
||||
import 'package:patient_manager/main.dart';
|
||||
import 'package:patient_manager/objects/medicine.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
@@ -19,7 +20,7 @@ class MedicineSearch extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MedicineSearchState extends State<MedicineSearch> {
|
||||
final String endpointMeds = "http://localhost:80/users/medicine/";
|
||||
final String endpointMeds = "${AppEnviroment.baseApiUrl}/users/medicine/";
|
||||
|
||||
//TextEditingController searchController = TextEditingController();
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:patient_manager/env/env.dart';
|
||||
import 'package:patient_manager/main.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:patient_manager/objects/appUser.dart';
|
||||
@@ -15,7 +16,7 @@ class PatManAppDrawer extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PatManAppDrawerState extends State<PatManAppDrawer> {
|
||||
String endpointUserData = "http://localhost:80/users/profile/";
|
||||
String endpointUserData = "${AppEnviroment.baseApiUrl}/users/profile/";
|
||||
late Future<AppUser> signedInUser;
|
||||
|
||||
Future<AppUser> getUserDetails() async {
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:patient_manager/components/mySuccessMessage.dart';
|
||||
import 'package:patient_manager/components/myTextInput.dart';
|
||||
import 'package:patient_manager/components/mybutton.dart';
|
||||
import 'package:patient_manager/components/prescipInput.dart';
|
||||
import 'package:patient_manager/env/env.dart';
|
||||
import 'package:patient_manager/main.dart';
|
||||
import 'package:patient_manager/objects/appUser.dart';
|
||||
import 'package:patient_manager/objects/files.dart';
|
||||
@@ -32,11 +33,12 @@ class PatientFiles extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PatientFilesState extends State<PatientFiles> {
|
||||
String endpointFiles = "http://localhost:80/files/patients/";
|
||||
String endpointUser = "http://localhost:80/users/profile/";
|
||||
String endpointGenFiles = "http://localhost:80/files/generate/med-cert/";
|
||||
String endpointFileUpload = "http://localhost:80/files/upload/file/";
|
||||
String endpointInsertFiles = "http://localhost:80/files/insert/";
|
||||
String endpointFiles = "${AppEnviroment.baseApiUrl}/files/patients/";
|
||||
String endpointUser = "${AppEnviroment.baseApiUrl}/users/profile/";
|
||||
String endpointGenFiles =
|
||||
"${AppEnviroment.baseApiUrl}/files/generate/med-cert/";
|
||||
String endpointFileUpload = "${AppEnviroment.baseApiUrl}/files/upload/file/";
|
||||
String endpointInsertFiles = "${AppEnviroment.baseApiUrl}/files/insert/";
|
||||
|
||||
final startDateController = TextEditingController();
|
||||
final endDateTextController = TextEditingController();
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:patient_manager/components/myMLTextInput.dart';
|
||||
import 'package:patient_manager/components/mySuccessMessage.dart';
|
||||
import 'package:patient_manager/components/myTextInput.dart';
|
||||
import 'package:patient_manager/components/mybutton.dart';
|
||||
import 'package:patient_manager/env/env.dart';
|
||||
import 'package:patient_manager/main.dart';
|
||||
import 'package:patient_manager/objects/notes.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
@@ -20,8 +21,8 @@ class PatientNotes extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PatientNotesState extends State<PatientNotes> {
|
||||
String endpoint = "http://localhost:80/notes/patients/";
|
||||
String apiUrlAddNote = "http://localhost:80/notes/insert/";
|
||||
String endpoint = "${AppEnviroment.baseApiUrl}/notes/patients/";
|
||||
String apiUrlAddNote = "${AppEnviroment.baseApiUrl}/notes/insert/";
|
||||
final titleController = TextEditingController();
|
||||
final noteTextController = TextEditingController();
|
||||
late Future<List<Note>> futueNotes;
|
||||
|
||||
5
Frontend/patient_manager/lib/env/env.dart
vendored
5
Frontend/patient_manager/lib/env/env.dart
vendored
@@ -2,6 +2,7 @@ enum Enviroment { dev, prod }
|
||||
|
||||
abstract class AppEnviroment {
|
||||
static late String baseApiUrl;
|
||||
static late String baseFileUrl;
|
||||
static late Enviroment _enviroment;
|
||||
static Enviroment get enviroment => _enviroment;
|
||||
static setupEnv(Enviroment env) {
|
||||
@@ -9,12 +10,14 @@ abstract class AppEnviroment {
|
||||
switch (env) {
|
||||
case Enviroment.dev:
|
||||
{
|
||||
baseApiUrl = "http://localhost";
|
||||
baseApiUrl = "http://localhost:80";
|
||||
baseFileUrl = "http://localhost:9000";
|
||||
break;
|
||||
}
|
||||
case Enviroment.prod:
|
||||
{
|
||||
baseApiUrl = "api";
|
||||
baseFileUrl = "minio";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,29 +4,17 @@ import 'package:patient_manager/router/routeGenerator.dart';
|
||||
import 'package:patient_manager/theme/mihTheme.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
|
||||
// void main() async {
|
||||
// WidgetsFlutterBinding.ensureInitialized();
|
||||
// await Supabase.initialize(
|
||||
// url: "https://stzluvsyhbwtfbztarmu.supabase.co",
|
||||
// anonKey:
|
||||
// "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InN0emx1dnN5aGJ3dGZienRhcm11Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTIwNzUyMTMsImV4cCI6MjAyNzY1MTIxM30.a7VHlk63JJcAotvsqtoqiKwjNK4EbnNgKilAqt1iRio",
|
||||
// );
|
||||
// runApp(const MzanziInnovationHub());
|
||||
// }
|
||||
|
||||
final client = Supabase.instance.client;
|
||||
|
||||
class MzanziInnovationHub extends StatefulWidget {
|
||||
//final AppEnviroment appEnv;
|
||||
|
||||
const MzanziInnovationHub({
|
||||
super.key,
|
||||
//required this.appEnv,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MzanziInnovationHub> createState() => _MzanziInnovationHubState();
|
||||
|
||||
// ignore: library_private_types_in_public_api
|
||||
static _MzanziInnovationHubState? of(BuildContext context) =>
|
||||
context.findAncestorStateOfType<_MzanziInnovationHubState>();
|
||||
}
|
||||
@@ -39,20 +27,25 @@ class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
|
||||
return theme.primaryColor();
|
||||
}
|
||||
|
||||
String getTitle() {
|
||||
if (AppEnviroment.getEnv() == "Dev") {
|
||||
return "Mzansi Innovation Hub - Dev";
|
||||
} else {
|
||||
return "Mzansi Innovation Hub";
|
||||
}
|
||||
}
|
||||
|
||||
void changeTheme(ThemeMode themeMode) {
|
||||
setState(() {
|
||||
_themeMode = themeMode;
|
||||
//print(_themeMode);
|
||||
if (_themeMode == ThemeMode.light) {
|
||||
setState(() {
|
||||
theme.mode = "Light";
|
||||
});
|
||||
//print(theme.mode);
|
||||
} else {
|
||||
setState(() {
|
||||
theme.mode = "Dark";
|
||||
});
|
||||
//print(theme.mode);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -68,7 +61,7 @@ class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Mzansi Innovation Hub - ${AppEnviroment.getEnv()}',
|
||||
title: getTitle(),
|
||||
themeMode: _themeMode,
|
||||
theme: theme.darkMode(),
|
||||
darkTheme: theme.lightMode(),
|
||||
|
||||
@@ -89,20 +89,5 @@ class _HomeState extends State<Home> {
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// Scaffold(
|
||||
// appBar: MyAppBar(barTitle: "Mzanzi Innovation Hub"),
|
||||
// body: HomeTileGrid(),
|
||||
// drawer: FutureBuilder(
|
||||
// future: getUserEmail(),
|
||||
// builder: (contexts, snapshot) {
|
||||
// if (snapshot.connectionState == ConnectionState.done) {
|
||||
// return MyAppDrawer(drawerTitle: useremail);
|
||||
// } else {
|
||||
// return Center(child: CircularProgressIndicator());
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:patient_manager/components/myErrorMessage.dart';
|
||||
import 'package:patient_manager/components/mySuccessMessage.dart';
|
||||
import 'package:patient_manager/components/myTextInput.dart';
|
||||
import 'package:patient_manager/components/mybutton.dart';
|
||||
import 'package:patient_manager/env/env.dart';
|
||||
import 'package:patient_manager/main.dart';
|
||||
import 'package:patient_manager/objects/appUser.dart';
|
||||
import '../components/myAppBar.dart';
|
||||
@@ -37,8 +38,8 @@ class _AddPatientState extends State<AddPatient> {
|
||||
final medMainMemController = TextEditingController();
|
||||
final medAidCodeController = TextEditingController();
|
||||
|
||||
final docOfficeIdApiUrl = "http://localhost:80/users/profile/";
|
||||
final apiUrl = "http://localhost:80/patients/insert/";
|
||||
final docOfficeIdApiUrl = "${AppEnviroment.baseApiUrl}/users/profile/";
|
||||
final apiUrl = "${AppEnviroment.baseApiUrl}/patients/insert/";
|
||||
late int futureDocOfficeId;
|
||||
late bool medRequired;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:patient_manager/components/myErrorMessage.dart';
|
||||
import 'package:patient_manager/components/mySuccessMessage.dart';
|
||||
import 'package:patient_manager/components/myTextInput.dart';
|
||||
import 'package:patient_manager/components/mybutton.dart';
|
||||
import 'package:patient_manager/env/env.dart';
|
||||
import 'package:patient_manager/main.dart';
|
||||
import 'package:patient_manager/objects/appUser.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
@@ -39,9 +40,9 @@ class _EditPatientState extends State<EditPatient> {
|
||||
final medMainMemController = TextEditingController();
|
||||
final medAidCodeController = TextEditingController();
|
||||
|
||||
final docOfficeIdApiUrl = "http://localhost:80/users/profile/";
|
||||
final apiUrlEdit = "http://localhost:80/patients/update/";
|
||||
final apiUrlDelete = "http://localhost:80/patients/delete/";
|
||||
final docOfficeIdApiUrl = "${AppEnviroment.baseApiUrl}/users/profile/";
|
||||
final apiUrlEdit = "${AppEnviroment.baseApiUrl}/patients/update/";
|
||||
final apiUrlDelete = "${AppEnviroment.baseApiUrl}/patients/delete/";
|
||||
late int futureDocOfficeId;
|
||||
late String userEmail;
|
||||
late bool medRequired;
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:patient_manager/components/myAppBar.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:patient_manager/components/mySearchInput.dart';
|
||||
import 'package:patient_manager/components/patManAppDrawer.dart';
|
||||
import 'package:patient_manager/env/env.dart';
|
||||
import 'package:patient_manager/main.dart';
|
||||
import 'package:patient_manager/objects/patients.dart';
|
||||
|
||||
@@ -24,7 +25,7 @@ class PatientManager extends StatefulWidget {
|
||||
|
||||
class _PatientManagerState extends State<PatientManager> {
|
||||
TextEditingController searchController = TextEditingController();
|
||||
String endpoint = "http://localhost:80/patients/user/";
|
||||
String endpoint = "${AppEnviroment.baseApiUrl}/patients/user/";
|
||||
late Future<List<Patient>> futurePatients;
|
||||
|
||||
String searchString = "";
|
||||
|
||||
Reference in New Issue
Block a user