follow.blade.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. @extends('layouts.blank')
  2. @section('content')
  3. <div class="container">
  4. <div class="row">
  5. <div class="col-12 col-md-6 offset-md-3 pt-5">
  6. <p class="h3 text-center font-weight-lighter py-3 mb-4 text-secondary">Follow <span class="text-dark">{{$profile->username}}</span> on Pixelfed</p>
  7. <div class="card">
  8. <div class="card-header p-0 m-0">
  9. <div style="width: 100%;height: 140px;background: #0070b7"></div>
  10. </div>
  11. <div class="card-body">
  12. <div class="text-center mt-n5 mb-4">
  13. <img
  14. class="rounded-circle p-1 border mt-n4 bg-white shadow"
  15. src="{{$profile->avatarUrl()}}"
  16. width="90"
  17. height="90"
  18. loading="lazy"
  19. onerror="this.src='/storage/avatars/default.jpg?v=0';this.onerror=null;">
  20. </div>
  21. <p class="text-center lead font-weight-bold mb-1">{{$profile->username}}</p>
  22. <p class="text-center text-muted small text-uppercase mb-4">{{$profile->followerCount()}} followers</p>
  23. <div class="d-flex justify-content-center">
  24. @if($following == true)
  25. <button
  26. id="unfollow"
  27. type="button"
  28. class="btn btn-outline-secondary btn-sm py-1 px-4 text-uppercase font-weight-bold mr-3"
  29. style="font-weight: 500"
  30. onclick="unfollowProfile()">
  31. Unfollow
  32. </button>
  33. @else
  34. <button
  35. id="follow"
  36. type="button"
  37. class="btn btn-primary btn-sm py-1 px-4 text-uppercase font-weight-bold mr-3"
  38. style="font-weight: 500"
  39. onclick="followProfile()">
  40. Follow
  41. </button>
  42. @endif
  43. <a class="btn btn-outline-primary btn-sm py-1 px-4 text-uppercase font-weight-bold" href="{{$profile->url()}}" style="font-weight: 500">View Profile</a>
  44. </div>
  45. </div>
  46. </div>
  47. @auth
  48. <div class="d-flex justify-content-between pt-4 small">
  49. <a class="text-lighter text-decoration-none" href="/{{$user->username}}">Logged in as: <span class="font-weight-bold text-muted">{{$user->username}}</span></a>
  50. <span>
  51. <a class="text-decoration-none text-muted font-weight-bold mr-3" href="/site/help">Help</a>
  52. <a class="text-decoration-none text-muted font-weight-bold" href="{{ route('logout') }}" onclick="event.preventDefault();document.getElementById('logout-form').submit();">Logout</a>
  53. <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
  54. @csrf
  55. </form>
  56. </span>
  57. </div>
  58. @endauth
  59. </div>
  60. </div>
  61. </div>
  62. @endsection
  63. @push('scripts')
  64. <script type="text/javascript">
  65. function followProfile() {
  66. let btn = document.querySelector('#follow');
  67. btn.setAttribute('disabled', 'disabled');
  68. axios.post('/api/v1/accounts/{{$profile->id}}/follow')
  69. .then(res => {
  70. setTimeout(() => location.reload(), 1000);
  71. })
  72. .catch(err => {
  73. location.href = '/login?next=' + encodeURI(location.href);
  74. })
  75. }
  76. function unfollowProfile() {
  77. let btn = document.querySelector('#unfollow');
  78. btn.setAttribute('disabled', 'disabled');
  79. axios.post('/api/v1/accounts/{{$profile->id}}/unfollow')
  80. .then(res => {
  81. setTimeout(() => location.reload(), 1000);
  82. })
  83. .catch(err => {
  84. location.href = '/login?next=' + encodeURI(location.href);
  85. })
  86. }
  87. </script>
  88. @endpush