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();
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_id = json['customerId'] ?? '';
return rtvm;

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

@ -93,6 +93,8 @@ class AppSettings {
static String updateDeliveryboyUrl = host + 'updatedeliveryboy';
static String deleteDeliveryboyUrl = host + 'deletedeliveryboy';
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*/

Loading…
Cancel
Save