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)); print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
setState(() { setState(() {
uiPrescriptionImages = jsonDecode(res)['precription']; uiPrescriptionImages = jsonDecode(res)['prescription'];
}); });
} }
@ -450,6 +450,32 @@ class _AddReportsState extends State<AddReports> {
['url']) ['url'])
as ImageProvider, // picked file as ImageProvider, // picked file
fit: BoxFit.fill)), 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( /*Expanded(child:IconButton(
@ -595,6 +621,32 @@ class _AddReportsState extends State<AddReports> {
['url']) ['url'])
as ImageProvider, // picked file as ImageProvider, // picked file
fit: BoxFit.fill)), 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( /*Expanded(child:IconButton(

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

Loading…
Cancel
Save