Added placeholder for lastName and role addition functionality
This commit is contained in:
@@ -8,23 +8,36 @@ import 'package:pshared/models/invitation/status.dart';
|
||||
class InvitationContent {
|
||||
final String email;
|
||||
final String name;
|
||||
final String lastName;
|
||||
final String comment;
|
||||
|
||||
const InvitationContent({
|
||||
required this.email,
|
||||
required this.name,
|
||||
required this.lastName,
|
||||
required this.comment,
|
||||
});
|
||||
|
||||
InvitationContent copyWith({
|
||||
String? email,
|
||||
String? name,
|
||||
String? lastName,
|
||||
String? comment,
|
||||
}) => InvitationContent(
|
||||
email: email ?? this.email,
|
||||
name: name ?? this.name,
|
||||
lastName: lastName ?? this.lastName,
|
||||
comment: comment ?? this.comment,
|
||||
);
|
||||
|
||||
String get fullName {
|
||||
final trimmedName = name.trim();
|
||||
final trimmedLastName = lastName.trim();
|
||||
if (trimmedName.isEmpty && trimmedLastName.isEmpty) return '';
|
||||
if (trimmedName.isEmpty) return trimmedLastName;
|
||||
if (trimmedLastName.isEmpty) return trimmedName;
|
||||
return '$trimmedName $trimmedLastName';
|
||||
}
|
||||
}
|
||||
|
||||
class Invitation implements PermissionBoundStorable {
|
||||
@@ -60,7 +73,7 @@ class Invitation implements PermissionBoundStorable {
|
||||
@override
|
||||
String get organizationRef => permissionBound.organizationRef;
|
||||
|
||||
String get inviteeDisplayName => content.name.isNotEmpty ? content.name : content.email;
|
||||
String get inviteeDisplayName => content.fullName.isNotEmpty ? content.fullName : content.email;
|
||||
bool get isExpired => expiresAt.isBefore(DateTime.now().toUtc());
|
||||
bool get isPending => status == InvitationStatus.created || status == InvitationStatus.sent;
|
||||
|
||||
@@ -91,6 +104,7 @@ Invitation newInvitation({
|
||||
required String inviterRef,
|
||||
required String email,
|
||||
String name = '',
|
||||
String lastName = '',
|
||||
String comment = '',
|
||||
InvitationStatus status = InvitationStatus.created,
|
||||
DateTime? expiresAt,
|
||||
@@ -106,6 +120,6 @@ Invitation newInvitation({
|
||||
inviterRef: inviterRef,
|
||||
status: status,
|
||||
expiresAt: expiresAt ?? DateTime.now().toUtc().add(const Duration(days: 7)),
|
||||
content: InvitationContent(email: email, name: name, comment: comment),
|
||||
content: InvitationContent(email: email, name: name, lastName: lastName, comment: comment),
|
||||
isArchived: isArchived,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user