Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 20 additions & 34 deletions frontend/lib/components/DisplayContactCompany.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import 'package:flutter/material.dart';
import 'package:frontend/models/contact.dart';
import 'package:frontend/models/company.dart';
import 'package:frontend/components/EditContact.dart';
import 'package:frontend/services/authService.dart';
import 'package:frontend/services/contactService.dart';
import 'package:provider/provider.dart';
import 'InformationBox.dart';

class DisplayContactsCompany extends StatefulWidget {
Expand All @@ -26,38 +24,26 @@ class _DisplayContactsState extends State<DisplayContactsCompany> {
this.contact = contactService.getContact(widget.rep.contactID);
}

_isEditable(Contact cont) {
return FutureBuilder(
future: Provider.of<AuthService>(context).role,
builder: (context, snapshot) {
if (snapshot.hasData) {
Role r = snapshot.data as Role;

if (r == Role.ADMIN || r == Role.COORDINATOR || r == Role.MEMBER) {
return FloatingActionButton.extended(
onPressed: () async {
final bool? shouldRefresh = await Navigator.push<bool>(
context,
MaterialPageRoute(
builder: (context) =>
EditContact(contact: cont, person: widget.rep),
),
);
if (shouldRefresh ?? false) {
this.contact =
contactService.getContact(widget.rep.contactID);
setState(() {});
}
},
label: const Text('Edit Contacts'),
icon: const Icon(Icons.edit),
backgroundColor: Color(0xff5C7FF2),
);
} else
return Container();
} else
return Container();
});
_isEditable(Contact cont) {
return FloatingActionButton.extended(
onPressed: () async {
final bool? shouldRefresh = await Navigator.push<bool>(
context,
MaterialPageRoute(
builder: (context) =>
EditContact(contact: cont, person: widget.rep),
),
);
if (shouldRefresh ?? false) {
this.contact =
contactService.getContact(widget.rep.contactID);
setState(() {});
}
},
label: const Text('Edit Contacts'),
icon: const Icon(Icons.edit),
backgroundColor: Color(0xff5C7FF2),
);
}

@override
Expand Down
5 changes: 2 additions & 3 deletions frontend/lib/routes/company/CreateRep.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,8 @@ class _CreateRepState extends State<CreateRep> {
final representative = _Reps[index];
return ListTile(
key: Key(representative.id.toString()),
leading: Icon(Icons
.person), // Add your representative image here
title: Text(representative.name ?? 'N/A'),
leading: Icon(Icons.person), // Add your representative image here
title: SelectableText(representative.name),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expand Down