small changes at add records page

dev
Sneha 1 year ago
parent 895626d5b5
commit 463053abc9

@ -165,7 +165,7 @@ class _AddReportsState extends State<AddReports> {
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
uiPrescriptionImages = jsonDecode(res)['precription'];
uiPrescriptionImages = jsonDecode(res)['prescription'];
});
}
@ -450,6 +450,32 @@ class _AddReportsState extends State<AddReports> {
['url'])
as ImageProvider, // picked file
fit: BoxFit.fill)),
child: Stack(children: [
Positioned(
right: 0,
child: Container(
child: IconButton(
iconSize: 30,
icon: const Icon(
Icons.cancel,
color: Colors.red,
),
onPressed: () async {
AppSettings.preLoaderDialog(context);
String fileName = uiFindingsImages[index]['url'].split('/').last;
var response = await AppSettings.deleteFindings(fileName);
print(jsonDecode(response));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
uiFindingsImages = jsonDecode(response)['findings'];
});
},
),
),
)
]),
),
),
/*Expanded(child:IconButton(
@ -595,6 +621,32 @@ class _AddReportsState extends State<AddReports> {
['url'])
as ImageProvider, // picked file
fit: BoxFit.fill)),
child: Stack(children: [
Positioned(
right: 0,
child: Container(
child: IconButton(
iconSize: 30,
icon: const Icon(
Icons.cancel,
color: Colors.red,
),
onPressed: () async {
AppSettings.preLoaderDialog(context);
String fileName = uiReportsImages[index]['url'].split('/').last;
var response = await AppSettings.deleteReports(fileName);
print(jsonDecode(response));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
uiReportsImages = jsonDecode(response)['reports'];
});
},
),
),
)
]),
),
),
/*Expanded(child:IconButton(

@ -255,6 +255,7 @@ class AppSettings {
static String deleteRecordUrl = host + 'deleteRecord';
static String deleteFindingsUrl = host + 'uploads-findings-prescription';
static String deletePrescriptionsUrl = host + 'uploads-prescription-prescription';
static String deleteReportsUrl = host + 'uploads-reports-prescription';
static String deleteRecordsUrl = host + 'delete-url';
@ -1186,32 +1187,32 @@ class AppSettings {
}
static Future<bool> deleteFindings(fileName) async {
static Future<String> deleteFindings(fileName) async {
var uri = Uri.parse(deleteFindingsUrl + '/' + customerId+'/'+fileName);
try {
var response = await http.delete(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return true;
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.delete(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return true;
return response.body;
} else {
return false;
return '';
}
} else {
return false;
return '';
}
} else {
return false;
return '';
}
} catch (e) {
print(e);
return false;
return '';
}
}
@ -1244,6 +1245,64 @@ class AppSettings {
}
}
static Future<String> deleteReports(fileName) async {
var uri = Uri.parse(deleteReportsUrl + '/' + customerId+'/'+fileName);
try {
var response = await http.delete(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.delete(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
} catch (e) {
print(e);
return '';
}
}
/*static Future<String> deleteFindings(fileName) async {
var uri = Uri.parse(deletePrescriptionsUrl + '/' + customerId+'/'+fileName);
try {
var response = await http.delete(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.delete(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
} catch (e) {
print(e);
return '';
}
}*/
static Future<bool> deleteRecords(payload, recordId) async {
var uri = Uri.parse(deleteRecordsUrl + '/' + customerId+'/'+recordId);

Loading…
Cancel
Save