import 'package:pshared/models/invitation/invitation.dart';
import 'package:pshared/models/invitation/status.dart';

import 'package:pweb/models/invitation/invitation_filter.dart';

import 'package:pweb/generated/i18n/app_localizations.dart';


String invitationFilterLabel(InvitationFilter filter, AppLocalizations loc) {
  switch (filter) {
    case InvitationFilter.all:
      return loc.invitationFilterAll;
    case InvitationFilter.pending:
      return loc.invitationFilterPending;
    case InvitationFilter.accepted:
      return loc.invitationFilterAccepted;
    case InvitationFilter.declined:
      return loc.invitationFilterDeclined;
    case InvitationFilter.revoked:
      return loc.invitationFilterRevoked;
    case InvitationFilter.expired:
      return loc.invitationFilterExpired;
    case InvitationFilter.archived:
      return loc.invitationFilterArchived;
  }
}

bool invitationFilterMatches(InvitationFilter filter, Invitation inv) {
  switch (filter) {
    case InvitationFilter.pending:
      return inv.isPending && !inv.isExpired;
    case InvitationFilter.accepted:
      return inv.status == InvitationStatus.accepted;
    case InvitationFilter.declined:
      return inv.status == InvitationStatus.declined;
    case InvitationFilter.revoked:
      return inv.status == InvitationStatus.revoked;
    case InvitationFilter.expired:
      return inv.isExpired && inv.isPending;
    case InvitationFilter.archived:
      return inv.isArchived;
    case InvitationFilter.all:
      return true;
  }
}
