Skip to content

Commit 2d3ba65

Browse files
committed
upo
1 parent 8de3087 commit 2d3ba65

File tree

2 files changed

+173
-62
lines changed

2 files changed

+173
-62
lines changed

lib/views/Admin/Home/AssignProperty.dart

Lines changed: 86 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,33 @@ class _AssignPropertyState extends State<AssignProperty> {
116116
user1 != null
117117
? InkWell(
118118
onTap: () {
119-
setState(() {
120-
showForm = true;
121-
user1 = null;
122-
});
119+
showDialog(
120+
context: context,
121+
builder: (context) {
122+
return AlertDialog(
123+
title: Text("Remove User"),
124+
content: Text(
125+
"Do you want to remove the user?"),
126+
actions: [
127+
MaterialButton(
128+
child: Text("Yes"),
129+
onPressed: () {
130+
setState(() {
131+
showForm = true;
132+
user1 = null;
133+
});
134+
Navigator.pop(context);
135+
},
136+
),
137+
MaterialButton(
138+
child: Text("No"),
139+
onPressed: () {
140+
Navigator.pop(context);
141+
},
142+
),
143+
],
144+
);
145+
});
123146
},
124147
child: UserCard(user1),
125148
)
@@ -142,34 +165,67 @@ class _AssignPropertyState extends State<AssignProperty> {
142165
.subtitle1),
143166
),
144167
onPressed: () async {
145-
if (temp == user1) {
146-
PropertyAssignmentModel res =
147-
await PropertyAssignment
148-
.getTempAssignRowByUserId(user1.userId);
149-
List<String> res2 = res.propertyId.split(",");
150-
res2.removeWhere(
151-
(element) =>
152-
element ==
153-
widget.propertyElement.tableproperty
154-
.propertyId
155-
.toString(),
156-
);
168+
showDialog(
169+
context: context,
170+
builder: (context) {
171+
return AlertDialog(
172+
title: Text("Remove User"),
173+
content: Text(
174+
"Do you want to remove the user?"),
175+
actions: [
176+
MaterialButton(
177+
child: Text("Yes"),
178+
onPressed: () async {
179+
if (temp == user1) {
180+
PropertyAssignmentModel res =
181+
await PropertyAssignment
182+
.getTempAssignRowByUserId(
183+
user1.userId);
184+
List<String> res2 =
185+
res.propertyId.split(",");
186+
res2.removeWhere(
187+
(element) =>
188+
element ==
189+
widget
190+
.propertyElement
191+
.tableproperty
192+
.propertyId
193+
.toString(),
194+
);
157195

158-
bool res3 = await PropertyAssignment
159-
.updateTempAssignment(
160-
res2, res.userToPropertyId);
161-
if (res3) {
162-
showInSnackBar(context,
163-
"Assigne succesfully removed", 800);
164-
setState(() {
165-
showForm = true;
166-
user1 = null;
196+
bool res3 =
197+
await PropertyAssignment
198+
.updateTempAssignment(
199+
res2,
200+
res.userToPropertyId);
201+
if (res3) {
202+
showInSnackBar(
203+
context,
204+
"Assigne succesfully removed",
205+
800);
206+
setState(() {
207+
showForm = true;
208+
user1 = null;
209+
});
210+
} else {
211+
showInSnackBar(
212+
context,
213+
"Assigne removal failed2",
214+
800);
215+
}
216+
}
217+
Navigator.pop(context);
218+
},
219+
),
220+
MaterialButton(
221+
child: Text("No"),
222+
onPressed: () {
223+
Navigator.pop(context);
224+
},
225+
),
226+
],
227+
);
167228
});
168-
} else {
169-
showInSnackBar(
170-
context, "Assigne removal failed2", 800);
171-
}
172-
}
173229
},
174230
)
175231
: SizedBox(),

lib/views/Manager/Home/AssignProperty.dart

Lines changed: 87 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class _AssignPropertyState extends State<AssignProperty> {
4747
if (userList[i].userType == "manager") {
4848
List<User> tempUsers =
4949
await UserService.getAllUserUnderManger(userList[i].userId);
50-
tempUsers3.addAll(tempUsers);
50+
tempUsers3.addAll(tempUsers);
5151
}
5252
}
5353
setState(() {
@@ -128,10 +128,33 @@ class _AssignPropertyState extends State<AssignProperty> {
128128
user1 != null
129129
? InkWell(
130130
onTap: () {
131-
setState(() {
132-
showForm = true;
133-
user1 = null;
134-
});
131+
showDialog(
132+
context: context,
133+
builder: (context) {
134+
return AlertDialog(
135+
title: Text("Remove User"),
136+
content: Text(
137+
"Do you want to remove the user?"),
138+
actions: [
139+
MaterialButton(
140+
child: Text("Yes"),
141+
onPressed: () {
142+
setState(() {
143+
showForm = true;
144+
user1 = null;
145+
});
146+
Navigator.pop(context);
147+
},
148+
),
149+
MaterialButton(
150+
child: Text("No"),
151+
onPressed: () {
152+
Navigator.pop(context);
153+
},
154+
),
155+
],
156+
);
157+
});
135158
},
136159
child: UserCard(user1),
137160
)
@@ -141,7 +164,6 @@ class _AssignPropertyState extends State<AssignProperty> {
141164
height: 16,
142165
)
143166
: SizedBox(),
144-
145167
temp == user1 && user1 != null
146168
? MaterialButton(
147169
minWidth: 250,
@@ -155,34 +177,67 @@ class _AssignPropertyState extends State<AssignProperty> {
155177
.subtitle1),
156178
),
157179
onPressed: () async {
158-
if (temp == user1) {
159-
PropertyAssignmentModel res =
160-
await PropertyAssignment
161-
.getTempAssignRowByUserId(user1.userId);
162-
List<String> res2 = res.propertyId.split(",");
163-
res2.removeWhere(
164-
(element) =>
165-
element ==
166-
widget.propertyElement.tableproperty
167-
.propertyId
168-
.toString(),
169-
);
180+
showDialog(
181+
context: context,
182+
builder: (context) {
183+
return AlertDialog(
184+
title: Text("Remove User"),
185+
content: Text(
186+
"Do you want to remove the user?"),
187+
actions: [
188+
MaterialButton(
189+
child: Text("Yes"),
190+
onPressed: () async {
191+
if (temp == user1) {
192+
PropertyAssignmentModel res =
193+
await PropertyAssignment
194+
.getTempAssignRowByUserId(
195+
user1.userId);
196+
List<String> res2 =
197+
res.propertyId.split(",");
198+
res2.removeWhere(
199+
(element) =>
200+
element ==
201+
widget
202+
.propertyElement
203+
.tableproperty
204+
.propertyId
205+
.toString(),
206+
);
170207

171-
bool res3 = await PropertyAssignment
172-
.updateTempAssignment(
173-
res2, res.userToPropertyId);
174-
if (res3) {
175-
showInSnackBar(context,
176-
"Assigne succesfully removed", 800);
177-
setState(() {
178-
showForm = true;
179-
user1 = null;
208+
bool res3 =
209+
await PropertyAssignment
210+
.updateTempAssignment(
211+
res2,
212+
res.userToPropertyId);
213+
if (res3) {
214+
showInSnackBar(
215+
context,
216+
"Assigne succesfully removed",
217+
800);
218+
setState(() {
219+
showForm = true;
220+
user1 = null;
221+
});
222+
} else {
223+
showInSnackBar(
224+
context,
225+
"Assigne removal failed2",
226+
800);
227+
}
228+
}
229+
Navigator.pop(context);
230+
},
231+
),
232+
MaterialButton(
233+
child: Text("No"),
234+
onPressed: () {
235+
Navigator.pop(context);
236+
},
237+
),
238+
],
239+
);
180240
});
181-
} else {
182-
showInSnackBar(
183-
context, "Assigne removal failed2", 800);
184-
}
185-
}
186241
},
187242
)
188243
: SizedBox(),

0 commit comments

Comments
 (0)