extends ../../layouts/room
block content

  include ../../../kaleidoscope/components/event
  include ../../../user/components/attribution-header

  form(
    method="POST",
    action=`/chat/room/${invite.room._id}/invite/${invite._id}/action`,
    onsubmit='return dtp.app.submitForm(event, "chat-invite-action");'
  ).uk-height-1-1
    .uk-card.uk-card-default.uk-card-small.uk-flex.uk-flex-column.uk-height-1-1
      .uk-card-header
        div(uk-grid).uk-grid-small
          .uk-width-auto
            a(href= getUserProfileUrl(invite.room.owner))
              +renderProfileIcon(invite.room.owner, invite.room.owner.displayName || invite.room.owner.username, 'small')
          .uk-width-expand
            h1.uk-card-title.uk-margin-remove.dtp-text-tight #{invite.room.name}
            if invite.room.description && (invite.room.description.length > 0)
              .uk-text-small.dtp-text-tight
                div!= marked.parse(invite.room.description)
            div(uk-grid).uk-text-small.uk-text-muted
              .uk-width-auto
                div(title= "Member count").no-select
                  span
                    i.fas.fa-users
                  span.uk-margin-small-left= formatCount(invite.room.members.length)

      .uk-card-body.uk-flex-1.uk-overflow-auto
        .uk-margin
          .uk-text-bold Status
          div(class={
            'uk-text-info': (invite.status === 'new'),
            'uk-text-success': (invite.status === 'accepted'),
            'uk-text-error': (invite.status === 'rejected'),
            'uk-text-muted': (invite.status === 'deleted'),
          })= invite.status

        .uk-margin
          .uk-text-bold Invite message
          div!= marked.parse(invite.message)

        if invite.room.policy && (invite.room.policy.length > 0)
          .uk-margin
            .uk-text-bold Room policy
            div!= marked.parse(invite.room.policy)
      
      .uk-card-footer
        div(uk-grid)
          .uk-width-expand
            +renderBackButton()

          .uk-width-auto(hidden= invite.status !== 'new')
            div(uk-grid).uk-grid-small
              .uk-width-auto
                button(type="submit", name="response", value="reject").uk-button.uk-button-danger.uk-border-rounded Reject
              .uk-width-auto
                button(type="submit", name="response", value="accept").uk-button.uk-button-primary.uk-border-rounded Accept