You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
227 lines
8.0 KiB
227 lines
8.0 KiB
1 year ago
|
import 'dart:convert';
|
||
|
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter/services.dart';
|
||
|
import 'package:healthcare_pharmacy/models/pending_suppliers_model.dart';
|
||
|
import 'package:healthcare_pharmacy/settings.dart';
|
||
|
|
||
|
|
||
|
|
||
|
class PendingCustomers extends StatefulWidget {
|
||
|
|
||
|
|
||
|
|
||
|
@override
|
||
|
State<PendingCustomers> createState() => _PendingCustomersState();
|
||
|
}
|
||
|
|
||
|
class _PendingCustomersState extends State<PendingCustomers> {
|
||
|
|
||
|
TextEditingController tankerNameController = TextEditingController();
|
||
|
TextEditingController tankerPhoneController = TextEditingController();
|
||
|
TextEditingController tankerAlterPhoneController = TextEditingController();
|
||
|
|
||
|
bool isPendingDataLoading=false;
|
||
|
List<PendingSuppliersModel> pendingSuppliersList = [];
|
||
|
bool isSereverIssuePending = false;
|
||
|
bool isLoading=false;
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
Future<void> getPendingSuppliersData() async {
|
||
|
isPendingDataLoading = true;
|
||
|
|
||
|
try {
|
||
|
/* var response = await AppSettings.getPendingSuppliers();
|
||
|
|
||
|
setState(() {
|
||
|
pendingSuppliersList =
|
||
|
((jsonDecode(response)['data']) as List).map((dynamic model) {
|
||
|
return PendingSuppliersModel.fromJson(model);
|
||
|
}).toList();
|
||
|
isPendingDataLoading = false;
|
||
|
});*/
|
||
|
|
||
|
|
||
|
} catch (e) {
|
||
|
setState(() {
|
||
|
isPendingDataLoading = false;
|
||
|
isSereverIssuePending = true;
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
isLoading=true;
|
||
|
getPendingSuppliersData();
|
||
|
super.initState();
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
Widget renderzUi(){
|
||
|
if(pendingSuppliersList.length!=0){
|
||
|
|
||
|
return Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||
|
children: [
|
||
|
Expanded(child:ListView.builder(
|
||
|
padding: EdgeInsets.all(0),
|
||
|
itemCount: pendingSuppliersList.length,
|
||
|
itemBuilder: (BuildContext context, int index) {
|
||
|
return Card(
|
||
|
child: Padding(
|
||
|
padding:EdgeInsets.all(8) ,
|
||
|
child: Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||
|
children: [
|
||
|
Container(
|
||
|
width: MediaQuery.of(context).size.width * .50,
|
||
|
child: Row(
|
||
|
children: [
|
||
|
Column(
|
||
|
mainAxisAlignment:
|
||
|
MainAxisAlignment.spaceBetween,
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Text('username :',
|
||
|
style: labelTextStyle()),
|
||
|
|
||
|
SizedBox(height: 10,),
|
||
|
Text('contactNumber:',
|
||
|
style: labelTextStyle()),
|
||
|
SizedBox(height: 10,),
|
||
|
Text('address:',
|
||
|
style: labelTextStyle()),
|
||
|
],
|
||
|
),
|
||
|
SizedBox(width: 10,),
|
||
|
Expanded(child:Column(
|
||
|
mainAxisAlignment:
|
||
|
MainAxisAlignment.spaceBetween,
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Text(
|
||
|
pendingSuppliersList[index]
|
||
|
.customer_name
|
||
|
.toUpperCase(),
|
||
|
style: valuesTextStyle()),
|
||
|
SizedBox(height: 10,),
|
||
|
Text(
|
||
|
pendingSuppliersList[index]
|
||
|
.customer_phone_number
|
||
|
.toUpperCase(),
|
||
|
style: valuesTextStyle()),
|
||
|
SizedBox(height: 10,),
|
||
|
Text(
|
||
|
pendingSuppliersList[index]
|
||
|
.customer_address
|
||
|
.toUpperCase(),
|
||
|
style: valuesTextStyle())
|
||
|
],
|
||
|
),)
|
||
|
],
|
||
|
)
|
||
|
),
|
||
|
|
||
|
|
||
|
TextButton(
|
||
|
child: Text(
|
||
|
'Accept',
|
||
|
style: TextStyle(fontSize: 15,
|
||
|
color:primaryColor/*FilteredList[index].text_color*/ ),
|
||
|
),
|
||
|
onPressed: () async{
|
||
|
var payload = new Map<String, dynamic>();
|
||
|
payload["supplierId"] =AppSettings.pharmacyId;
|
||
|
payload["customerId"] = pendingSuppliersList[index].customer_id;
|
||
|
/* bool requestStatus = await AppSettings.acceptRequest(payload);
|
||
|
|
||
|
if(requestStatus){
|
||
|
AppSettings.longSuccessToast("Request Accepted Successfully");
|
||
|
// await getConnectedSuppliersData();
|
||
|
await getPendingSuppliersData();
|
||
|
|
||
|
}
|
||
|
else{
|
||
|
}*/
|
||
|
|
||
|
},
|
||
|
),
|
||
|
|
||
|
TextButton(
|
||
|
child: Text(
|
||
|
'Reject',
|
||
|
style: TextStyle(fontSize: 15,
|
||
|
color:primaryColor/*FilteredList[index].text_color*/ ),
|
||
|
),
|
||
|
onPressed: () async{
|
||
|
var payload = new Map<String, dynamic>();
|
||
|
payload["supplierId"] =AppSettings.pharmacyId;
|
||
|
payload["customerId"] = pendingSuppliersList[index].customer_id;
|
||
|
|
||
|
/* bool requestStatus = await AppSettings.rejectRequest(payload);
|
||
|
if(requestStatus){
|
||
|
AppSettings.longSuccessToast("Request Sent Successfully");
|
||
|
await getPendingSuppliersData();
|
||
|
|
||
|
}
|
||
|
else{
|
||
|
|
||
|
}*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
},
|
||
|
),
|
||
|
],
|
||
|
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}) ),
|
||
|
]);
|
||
|
}
|
||
|
else{
|
||
|
return Center(
|
||
|
child: Padding(
|
||
|
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
|
||
|
child: Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||
|
children: [
|
||
|
SizedBox(height: MediaQuery.of(context).size.height * .25,),
|
||
|
Text('No Data Found'),
|
||
|
SizedBox(
|
||
|
height: 20,
|
||
|
),
|
||
|
|
||
|
],
|
||
|
),
|
||
|
)
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return SafeArea(
|
||
|
child: Scaffold(
|
||
|
appBar: AppSettings.appBar('Pending Customers'),
|
||
|
body: isPendingDataLoading?Center(
|
||
|
child: CircularProgressIndicator(
|
||
|
color: primaryColor,
|
||
|
strokeWidth: 5.0,
|
||
|
),
|
||
|
):renderzUi(),
|
||
|
));
|
||
|
}
|
||
|
}
|