Fix patient file api call issue

This commit is contained in:
2024-09-05 09:37:30 +02:00
parent 9de9fb0e33
commit 44332286eb
2 changed files with 20 additions and 94 deletions

View File

@@ -98,76 +98,6 @@ class _HomeState extends State<Home> {
return HomeArguments(userData, bUserData, busData, userPic);
}
Future<AppUser> getUserDetails() async {
//print("pat man drawer: " + endpointUserData + widget.userEmail);
var uid = await SuperTokens.getUserId();
var response = await http.get(Uri.parse("$baseAPI/user/$uid"));
// print(response.statusCode);
// print(response.body);
if (response.statusCode == 200) {
// print("here");
String body = response.body;
var decodedData = jsonDecode(body);
AppUser u = AppUser.fromJson(decodedData);
// print(u.email);
//setState(() {
//_widgetOptions = setLayout(u);
//});
return u;
} else {
throw Exception("Error: GetUserData status code ${response.statusCode}");
}
}
Future<BusinessUser?> getBusinessUserDetails() async {
var uid = await SuperTokens.getUserId();
var response = await http.get(Uri.parse("$baseAPI/business-user/$uid"));
if (response.statusCode == 200) {
String body = response.body;
var decodedData = jsonDecode(body);
BusinessUser business_User = BusinessUser.fromJson(decodedData);
return business_User;
} else {
return null;
}
}
Future<Business?> getBusinessDetails() async {
var uid = await SuperTokens.getUserId();
var response = await http.get(Uri.parse("$baseAPI/business/app_id/$uid"));
if (response.statusCode == 200) {
String body = response.body;
var decodedData = jsonDecode(body);
Business business = Business.fromJson(decodedData);
return business;
} else {
return null;
}
}
Future<String> getFileUrlApiCall(AppUser signedInUser) async {
if (signedInUser.pro_pic_path == "") {
return "";
} else if (AppEnviroment.getEnv() == "Dev") {
return "${AppEnviroment.baseFileUrl}/mih/${signedInUser.pro_pic_path}";
} else {
var url =
"${AppEnviroment.baseApiUrl}/minio/pull/file/${signedInUser.pro_pic_path}/prod";
var response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
String body = response.body;
var decodedData = jsonDecode(body);
return decodedData['minioURL'];
} else {
throw Exception(
"Error: GetUserData status code ${response.statusCode}");
}
}
}
@override
void dispose() {
// TODO: implement dispose