Merge pull request 'Sender Invitation' (#245) from SEND024 into main
All checks were successful
ci/woodpecker/push/gateway_tgsettle Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/discovery Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/gateway_mntx Pipeline was successful
ci/woodpecker/push/gateway_chain Pipeline was successful
All checks were successful
ci/woodpecker/push/gateway_tgsettle Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/discovery Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/gateway_mntx Pipeline was successful
ci/woodpecker/push/gateway_chain Pipeline was successful
Reviewed-on: #245 Reviewed-by: tech <tech.sendico@proton.me>
This commit was merged in pull request #245.
This commit is contained in:
64
frontend/pshared/lib/provider/invitations.dart
Normal file
64
frontend/pshared/lib/provider/invitations.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:pshared/data/mapper/invitation/invitation.dart';
|
||||
import 'package:pshared/models/invitation/invitation.dart';
|
||||
import 'package:pshared/models/invitation/status.dart';
|
||||
import 'package:pshared/provider/organizations.dart';
|
||||
import 'package:pshared/provider/template.dart';
|
||||
import 'package:pshared/service/invitation/service.dart';
|
||||
|
||||
|
||||
class InvitationsProvider extends GenericProvider<Invitation> {
|
||||
InvitationsProvider() : super(service: InvitationService.basicService);
|
||||
|
||||
late OrganizationsProvider _organizations;
|
||||
String? _loadedOrganizationId;
|
||||
|
||||
List<Invitation> get invitations => List<Invitation>.unmodifiable(items);
|
||||
|
||||
void updateProviders(OrganizationsProvider organizations) {
|
||||
_organizations = organizations;
|
||||
if (_organizations.isOrganizationSet) {
|
||||
final organizationId = _organizations.current.id;
|
||||
if (_loadedOrganizationId != organizationId) {
|
||||
_loadedOrganizationId = organizationId;
|
||||
load(organizationId, organizationId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<Invitation> sendInvitation({
|
||||
required String email,
|
||||
required String roleRef,
|
||||
required String inviterRef,
|
||||
String name = '',
|
||||
String comment = '',
|
||||
DateTime? expiresAt,
|
||||
}) async {
|
||||
final invitation = newInvitation(
|
||||
organizationRef: _organizations.current.id,
|
||||
roleRef: roleRef,
|
||||
inviterRef: inviterRef,
|
||||
email: email,
|
||||
name: name,
|
||||
comment: comment,
|
||||
expiresAt: expiresAt,
|
||||
);
|
||||
|
||||
return createObject(_organizations.current.id, invitation.toDTO().toJson());
|
||||
}
|
||||
|
||||
Future<void> updateInvitation(Invitation invitation) {
|
||||
return update(invitation.toDTO().toJson());
|
||||
}
|
||||
|
||||
Future<void> revokeInvitation(Invitation invitation) {
|
||||
return updateInvitation(invitation.copyWith(status: InvitationStatus.revoked));
|
||||
}
|
||||
|
||||
Future<void> setInvitationArchived(Invitation invitation, bool archived) {
|
||||
return setArchived(
|
||||
organizationRef: _organizations.current.id,
|
||||
objectRef: invitation.id,
|
||||
newIsArchived: archived,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user