updated the code for request_customers

dev
suresh 2 years ago
parent 35c4ea57aa
commit 90a9f5919a

@ -16,7 +16,7 @@ class PendingSuppliersModel {
PendingSuppliersModel rtvm = new PendingSuppliersModel(); PendingSuppliersModel rtvm = new PendingSuppliersModel();
rtvm.customer_name = json['username'] ?? ''; rtvm.customer_name = json['username'] ?? '';
rtvm.customer_phone_number = json['contactNumber'] ?? ''; rtvm.customer_phone_number = json['phone'] ?? '';
rtvm.customer_address = json['profile']['address1'] ?? ''; rtvm.customer_address = json['profile']['address1'] ?? '';
rtvm.customer_id = json['customerId'] ?? ''; rtvm.customer_id = json['customerId'] ?? '';
return rtvm; return rtvm;

@ -100,7 +100,7 @@ class _PendingCustomersState extends State<PendingCustomers> {
Text('contactNumber:', Text('contactNumber:',
style: labelTextStyle()), style: labelTextStyle()),
SizedBox(height: 10,), SizedBox(height: 10,),
Text('address1:', Text('address:',
style: labelTextStyle()), style: labelTextStyle()),
], ],
), ),
@ -141,25 +141,18 @@ class _PendingCustomersState extends State<PendingCustomers> {
color:primaryColor/*FilteredList[index].text_color*/ ), color:primaryColor/*FilteredList[index].text_color*/ ),
), ),
onPressed: () async{ onPressed: () async{
/* var payload = new Map<String, dynamic>(); var payload = new Map<String, dynamic>();
payload["customerId"] =AppSettings.customerId; payload["supplierId"] =AppSettings.supplierId;
payload["supplierId"] = FilteredList[index].supplier_id; bool requestStatus = await AppSettings.acceptRequest(payload);
bool requestStatus = await AppSettings.connectRequest(payload);
if(requestStatus){ if(requestStatus){
AppSettings.longSuccessToast("Request Sent Successfully"); AppSettings.longSuccessToast("Request Accepted Successfully");
await getAllSuppliersData(); // await getConnectedSuppliersData();
await getConnectedSuppliersData();
await getPendingSuppliersData(); await getPendingSuppliersData();
} }
else{ else{
}
}*/
}, },
), ),
@ -226,7 +219,7 @@ class _PendingCustomersState extends State<PendingCustomers> {
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
appBar: AppSettings.appBar('Pending Customers'), appBar: AppSettings.appBar('Pending Customers'),
body: isLoading?Center( body: isPendingDataLoading?Center(
child: CircularProgressIndicator( child: CircularProgressIndicator(
color: primaryColor, color: primaryColor,
strokeWidth: 5.0, strokeWidth: 5.0,

@ -93,6 +93,8 @@ class AppSettings {
static String updateDeliveryboyUrl = host + 'updatedeliveryboy'; static String updateDeliveryboyUrl = host + 'updatedeliveryboy';
static String deleteDeliveryboyUrl = host + 'deletedeliveryboy'; static String deleteDeliveryboyUrl = host + 'deletedeliveryboy';
static String pendingCustomersUrl = host + 'pendingCustomers'; static String pendingCustomersUrl = host + 'pendingCustomers';
static String acceptRequestUrl = host + 'friend-request/{id}/accept';
@ -577,6 +579,43 @@ class AppSettings {
} }
static Future<bool> acceptRequest( payload) async {
var uri = Uri.parse(acceptRequestUrl );
try {
var response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return true;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.put(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
} catch (e) {
print(e);
return false;
}
}
/*Apis ends here*/ /*Apis ends here*/

Loading…
Cancel
Save