All files / src/utils inviteRequests.js

100% Statements 28/28
40% Branches 2/5
100% Functions 2/2
100% Lines 28/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321x   1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 7x 7x 7x 7x 7x 7x 1x   1x 1x 6x 6x 6x 6x 1x  
// Invite request -> invitation (SB-1312).
 
const INVITE_TYPE_LABELS = {
  club_manager: 'Club Manager',
  club_fan: 'Club Fan',
  team_manager: 'Team Manager',
  team_player: 'Team Player',
  team_fan: 'Team Fan',
};
 
/**
 * What AdminInvites needs to open its form pre-filled from a request.
 * The invite form has no name field, so the name goes in the note.
 * Invite type and club/team are left for the admin to pick.
 */
export const invitePrefillFromRequest = request => ({
  request: { id: request.id, name: request.name, email: request.email },
  form: {
    email: request.email || '',
    note: request.name || '',
    iosBeta: Boolean(request.wants_ios_beta),
  },
});
 
/** One-line summary of the invitation linked to a request. */
export const linkedInviteSummary = invitation =>
  [
    invitation.invite_code,
    INVITE_TYPE_LABELS[invitation.invite_type] || invitation.invite_type,
    invitation.status,
  ].join(' ยท ');