mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 18:48:57 +03:30
Fix approve and reject in item result
This commit is contained in:
@@ -139,87 +139,8 @@ class ItemItemBox extends StatelessWidget {
|
|||||||
// SizedBox(
|
// SizedBox(
|
||||||
// width: 5.0,
|
// width: 5.0,
|
||||||
// ),
|
// ),
|
||||||
userData['roles']?.contains('Admin') ?? false
|
item?.status == "suspended" || item?.status == "rejected"
|
||||||
? InkWell(
|
? userData['roles']?.contains('Admin') ?? false
|
||||||
customBorder: CircleBorder(),
|
|
||||||
onTap: () {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text(
|
|
||||||
'Are you Confirm this item?',
|
|
||||||
),
|
|
||||||
actions: <Widget>[
|
|
||||||
Consumer<ItemProvider>(builder:
|
|
||||||
(context, itemProvider, _) {
|
|
||||||
return itemProvider.isloadingButton
|
|
||||||
? CircularProgressIndicator(
|
|
||||||
color: Colors.black,
|
|
||||||
)
|
|
||||||
: TextButton(
|
|
||||||
onPressed: () async {
|
|
||||||
itemProvider
|
|
||||||
.setLoadingButton();
|
|
||||||
await Provider.of<
|
|
||||||
ItemProvider>(
|
|
||||||
context,
|
|
||||||
listen: false)
|
|
||||||
.changeStatus(item!.id,
|
|
||||||
"approved")
|
|
||||||
.then(
|
|
||||||
(value) {
|
|
||||||
if (value) {
|
|
||||||
print('true');
|
|
||||||
}
|
|
||||||
Navigator.of(context)
|
|
||||||
.pop();
|
|
||||||
Navigator.of(context)
|
|
||||||
.popAndPushNamed(Routes
|
|
||||||
.itemResultScreen);
|
|
||||||
Fluttertoast.showToast(
|
|
||||||
msg:
|
|
||||||
"Item is Confirmed.",
|
|
||||||
toastLength: Toast
|
|
||||||
.LENGTH_SHORT,
|
|
||||||
gravity: ToastGravity
|
|
||||||
.BOTTOM,
|
|
||||||
);
|
|
||||||
itemProvider
|
|
||||||
.resetLoadingButton();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Text('Yes'),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
child: Text('No'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.all(7),
|
|
||||||
width: 8 * _deviceBlockSize,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: kLightBlue,
|
|
||||||
),
|
|
||||||
child: Icon(
|
|
||||||
Icons.check,
|
|
||||||
size: 4 * _deviceBlockSize,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: userData['roles']?.contains('Supervisor')
|
|
||||||
? item!.packageId != null
|
|
||||||
? InkWell(
|
? InkWell(
|
||||||
customBorder: CircleBorder(),
|
customBorder: CircleBorder(),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@@ -245,8 +166,7 @@ class ItemItemBox extends StatelessWidget {
|
|||||||
await Provider.of<
|
await Provider.of<
|
||||||
ItemProvider>(
|
ItemProvider>(
|
||||||
context,
|
context,
|
||||||
listen:
|
listen: false)
|
||||||
false)
|
|
||||||
.changeStatus(
|
.changeStatus(
|
||||||
item!.id,
|
item!.id,
|
||||||
"approved")
|
"approved")
|
||||||
@@ -306,8 +226,183 @@ class ItemItemBox extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
: userData['roles']?.contains('Supervisor')
|
||||||
|
? item!.packageId != null
|
||||||
|
? InkWell(
|
||||||
|
customBorder: CircleBorder(),
|
||||||
|
onTap: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(
|
||||||
|
'Are you Confirm this item?',
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
Consumer<ItemProvider>(
|
||||||
|
builder: (context,
|
||||||
|
itemProvider, _) {
|
||||||
|
return itemProvider
|
||||||
|
.isloadingButton
|
||||||
|
? CircularProgressIndicator(
|
||||||
|
color:
|
||||||
|
Colors.black,
|
||||||
|
)
|
||||||
|
: TextButton(
|
||||||
|
onPressed:
|
||||||
|
() async {
|
||||||
|
itemProvider
|
||||||
|
.setLoadingButton();
|
||||||
|
await Provider.of<
|
||||||
|
ItemProvider>(
|
||||||
|
context,
|
||||||
|
listen:
|
||||||
|
false)
|
||||||
|
.changeStatus(
|
||||||
|
item!
|
||||||
|
.id,
|
||||||
|
"approved")
|
||||||
|
.then(
|
||||||
|
(value) {
|
||||||
|
if (value) {
|
||||||
|
print(
|
||||||
|
'true');
|
||||||
|
}
|
||||||
|
Navigator.of(
|
||||||
|
context)
|
||||||
|
.pop();
|
||||||
|
Navigator.of(
|
||||||
|
context)
|
||||||
|
.popAndPushNamed(
|
||||||
|
Routes.itemResultScreen);
|
||||||
|
Fluttertoast
|
||||||
|
.showToast(
|
||||||
|
msg:
|
||||||
|
"Item is Confirmed.",
|
||||||
|
toastLength:
|
||||||
|
Toast
|
||||||
|
.LENGTH_SHORT,
|
||||||
|
gravity:
|
||||||
|
ToastGravity
|
||||||
|
.BOTTOM,
|
||||||
|
);
|
||||||
|
itemProvider
|
||||||
|
.resetLoadingButton();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child:
|
||||||
|
Text('Yes'),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context)
|
||||||
|
.pop();
|
||||||
|
},
|
||||||
|
child: Text('No'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.all(7),
|
||||||
|
width: 8 * _deviceBlockSize,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: kLightBlue,
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
Icons.check,
|
||||||
|
size: 4 * _deviceBlockSize,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
: Container()
|
: Container()
|
||||||
: Container(),
|
: Container()
|
||||||
|
: InkWell(
|
||||||
|
customBorder: CircleBorder(),
|
||||||
|
onTap: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text('Are you Reject this item?'),
|
||||||
|
actions: <Widget>[
|
||||||
|
Consumer<ItemProvider>(
|
||||||
|
builder: (context, itemProvider, _) {
|
||||||
|
return itemProvider.isloadingButton
|
||||||
|
? CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
)
|
||||||
|
: TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
itemProvider
|
||||||
|
.setLoadingButton();
|
||||||
|
await Provider.of<
|
||||||
|
ItemProvider>(
|
||||||
|
context,
|
||||||
|
listen: false)
|
||||||
|
.changeStatus(
|
||||||
|
item!.id,
|
||||||
|
"rejected")
|
||||||
|
.then(
|
||||||
|
(value) {
|
||||||
|
if (value) {
|
||||||
|
print('true');
|
||||||
|
}
|
||||||
|
Navigator.of(context)
|
||||||
|
.pop();
|
||||||
|
Navigator.of(context)
|
||||||
|
.popAndPushNamed(
|
||||||
|
Routes
|
||||||
|
.itemResultScreen);
|
||||||
|
Fluttertoast
|
||||||
|
.showToast(
|
||||||
|
msg:
|
||||||
|
"Item is rejected.",
|
||||||
|
toastLength: Toast
|
||||||
|
.LENGTH_SHORT,
|
||||||
|
gravity:
|
||||||
|
ToastGravity
|
||||||
|
.BOTTOM,
|
||||||
|
);
|
||||||
|
itemProvider
|
||||||
|
.resetLoadingButton();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Text('Yes'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: Text('No'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.all(7),
|
||||||
|
width: 8 * _deviceBlockSize,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: Colors.black),
|
||||||
|
child: Icon(
|
||||||
|
Icons.close,
|
||||||
|
size: 4 * _deviceBlockSize,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 5.0,
|
width: 5.0,
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user