Pagination
This commit is contained in:
@@ -17,7 +17,7 @@ final officesProvider = FutureProvider<List<Office>>((ref) async {
|
||||
});
|
||||
|
||||
class TeamsScreen extends ConsumerWidget {
|
||||
const TeamsScreen({Key? key}) : super(key: key);
|
||||
const TeamsScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
@@ -127,6 +127,7 @@ class TeamsScreen extends ConsumerWidget {
|
||||
}) async {
|
||||
final profiles = ref.read(profilesProvider).valueOrNull ?? [];
|
||||
final offices = await ref.read(officesProvider.future);
|
||||
if (!context.mounted) return;
|
||||
final itStaff = profiles.where((p) => p.role == 'it_staff').toList();
|
||||
final nameController = TextEditingController(text: team?.name ?? '');
|
||||
String? leaderId = team?.leaderId;
|
||||
@@ -204,6 +205,7 @@ class TeamsScreen extends ConsumerWidget {
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
final navigator = Navigator.of(context);
|
||||
final name = nameController.text.trim();
|
||||
if (name.isEmpty || leaderId == null) return;
|
||||
final client = Supabase.instance.client;
|
||||
@@ -247,7 +249,7 @@ class TeamsScreen extends ConsumerWidget {
|
||||
}
|
||||
ref.invalidate(teamsProvider);
|
||||
ref.invalidate(teamMembersProvider);
|
||||
Navigator.of(context).pop();
|
||||
navigator.pop();
|
||||
},
|
||||
child: Text(isEdit ? 'Save' : 'Add'),
|
||||
),
|
||||
@@ -260,6 +262,7 @@ class TeamsScreen extends ConsumerWidget {
|
||||
}
|
||||
|
||||
void _deleteTeam(BuildContext context, WidgetRef ref, String teamId) async {
|
||||
final navigator = Navigator.of(context);
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
@@ -267,11 +270,11 @@ class TeamsScreen extends ConsumerWidget {
|
||||
content: const Text('Are you sure you want to delete this team?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
onPressed: () => navigator.pop(false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
onPressed: () => navigator.pop(true),
|
||||
child: const Text('Delete'),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user