@php
/** @var \App\Models\User $user */
@endphp

<div class="card">
  <div class="card-header card-header-extra">
    @icon(fa-user-circle-o fa-pr fa-large)
    <h1>
      @if(authed() && user()->is($user))
        @sr(Your dashboard -)
      @else
        @sr(User's page -)
      @endif
      {{ $user->title }}
    </h1>

    @if(authed() && user()->is($user))
      <a href="{{route('profile.edit')}}" class="btn ml-auto" aria-label="Edit Profile">Edit</a>
    @endif
  </div>

  <div class="card-body">
    @if($user->bio)
      <div class="mb-3">
        {!! Widget::collapsible($user->bio, 350, '8em')->srPrefix('About me:') !!}
      </div>
    @endif

    <div class="mb-3">
      @if($tables_count)
        <a href="{{ route('profile.view', $user->name) }}" class="btn btn-sm btn-outline-primary">
          @icon(fa-table fa-pr)Tables <span class="badge">{{$tables_count}}</span>
        </a>
      @endif

      @if($favourites_count)
        <a href="{{ route('profile.view-favourites', $user->name) }}" class="btn btn-sm btn-outline-primary">
          @icon(fa-star fa-pr)Favourites <span class="badge">{{$favourites_count}}</span>
        </a>
      @endif
    </div>

    <table class="bio-table">
      <tbody>
      @if($user->website)
        <tr>
          <td class="text-center pr-2">@icon(fa-link, User's Website:)</td>
          <td>{!! Widget::tryLink($user->website) !!}</td>
        </tr>
      @endif

      <tr>
        <td class="text-center pr-2">@icon(fa-vcard-o, User's handle:)</td>
        <td>{{ $user->handle }}</td>
      </tr>

      <tr>
        <td class="text-center pr-2">@icon(fa-calendar, Join date:)</td>
        <td>
          <span class="pr-1" data-toggle="tooltip" data-placement="right"
                title="{{ $user->created_at->format('M n, Y \\a\\t G:i') }}">
            Joined {{ $user->created_at->diffForHumans() }}
          </span>
        </td>
      </tr>
      </tbody>
    </table>
  </div>
</div>