parent
45ed63be9c
commit
35c4ea57aa
@ -0,0 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:watermanagement/settings.dart';
|
||||
|
||||
|
||||
class PendingSuppliersModel {
|
||||
String customer_name = '';
|
||||
String customer_phone_number='';
|
||||
String customer_address='';
|
||||
String customer_id='';
|
||||
Color text_color=Colors.black;
|
||||
|
||||
|
||||
PendingSuppliersModel();
|
||||
|
||||
factory PendingSuppliersModel.fromJson(Map<String, dynamic> json){
|
||||
PendingSuppliersModel rtvm = new PendingSuppliersModel();
|
||||
|
||||
rtvm.customer_name = json['username'] ?? '';
|
||||
rtvm.customer_phone_number = json['contactNumber'] ?? '';
|
||||
rtvm.customer_address = json['profile']['address1'] ?? '';
|
||||
rtvm.customer_id = json['customerId'] ?? '';
|
||||
return rtvm;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,237 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:watermanagement/addtankers.dart';
|
||||
import 'package:watermanagement/models/pending_suppliers_model.dart';
|
||||
|
||||
import 'package:watermanagement/settings.dart';
|
||||
|
||||
import 'models/tankersview_model.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('address1:',
|
||||
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(
|
||||
'Connect',
|
||||
style: TextStyle(fontSize: 15,
|
||||
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);
|
||||
|
||||
if(requestStatus){
|
||||
AppSettings.longSuccessToast("Request Sent Successfully");
|
||||
await getAllSuppliersData();
|
||||
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["customerId"] =AppSettings.customerId;
|
||||
payload["supplierId"] = FilteredList[index].supplier_id;
|
||||
|
||||
bool requestStatus = await AppSettings.connectRequest(payload);
|
||||
|
||||
if(requestStatus){
|
||||
AppSettings.longSuccessToast("Request Sent Successfully");
|
||||
await getAllSuppliersData();
|
||||
await getConnectedSuppliersData();
|
||||
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: isLoading?Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: primaryColor,
|
||||
strokeWidth: 5.0,
|
||||
),
|
||||
):renderzUi(),
|
||||
));
|
||||
}
|
||||
}
|
Loading…
Reference in new issue