fix/feat: búsqueda móvil, chat solo amigos y bloqueo si se eliminó amistad
- Header: búsqueda móvil con panel deslizable (fixed bajo la topbar), comparte la lógica AJAX con desktop via initSearchWidget() - ChatController: index muestra solo amigos; show pasa isFriend y friendship a la vista; send valida amistad con abort_unless - chat/index: muestra amigos con @forelse y mensaje vacío si no tiene - chat/show: si no son amigos muestra banner de bloqueo con botón contextual (enviar solicitud / cancelar / aceptar según estado) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,20 +9,28 @@
|
||||
<h5 class="mb-0"><i class="fas fa-comments"></i> Chats</h5>
|
||||
</div>
|
||||
<div class="card-body p-0" style="overflow-y: auto;">
|
||||
@foreach($users as $user)
|
||||
<a href="{{ route('chat.show', $user) }}" class="text-decoration-none">
|
||||
@forelse($friends as $friend)
|
||||
<a href="{{ route('chat.show', $friend) }}" class="text-decoration-none">
|
||||
<div class="d-flex align-items-center p-3 border-bottom chat-user-item">
|
||||
<img src="{{ $user->profile_photo_url }}"
|
||||
<img src="{{ $friend->profile_photo_url }}"
|
||||
class="rounded-circle mr-3"
|
||||
width="45" height="45"
|
||||
style="object-fit:cover">
|
||||
<div>
|
||||
<div class="font-weight-bold text-dark">{{ $user->name }}</div>
|
||||
<small class="text-muted">{{ $user->getRoleNames()->first() }}</small>
|
||||
<div class="font-weight-bold text-dark">{{ $friend->name }}</div>
|
||||
<small class="text-muted">{{ $friend->getRoleNames()->first() }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
@endforeach
|
||||
@empty
|
||||
<div class="text-center text-muted py-5">
|
||||
<i class="fas fa-user-friends fa-3x mb-3 d-block"></i>
|
||||
<p class="mb-2">Aún no tienes amigos para chatear.</p>
|
||||
<a href="{{ route('feed') }}" class="btn btn-primary btn-sm">
|
||||
<i class="fas fa-search mr-1"></i> Buscar personas
|
||||
</a>
|
||||
</div>
|
||||
@endforelse
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -51,23 +51,51 @@
|
||||
</div>
|
||||
|
||||
<div class="card-footer p-2">
|
||||
<form id="chat-form" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<input type="hidden" name="receiver_id" value="{{ $user->id }}">
|
||||
<div class="input-group">
|
||||
<input type="text" name="body" id="chat-input"
|
||||
class="form-control rounded-pill mr-2"
|
||||
placeholder="Escribe un mensaje..." autocomplete="off">
|
||||
<label class="btn btn-light mr-1 mb-0" title="Adjuntar archivo">
|
||||
<i class="fas fa-paperclip"></i>
|
||||
<input type="file" name="attachment" id="attachment" hidden>
|
||||
</label>
|
||||
<button type="submit" class="btn btn-primary rounded-pill px-4">
|
||||
<i class="fas fa-paper-plane"></i>
|
||||
</button>
|
||||
@if($isFriend)
|
||||
<form id="chat-form" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<input type="hidden" name="receiver_id" value="{{ $user->id }}">
|
||||
<div class="input-group">
|
||||
<input type="text" name="body" id="chat-input"
|
||||
class="form-control rounded-pill mr-2"
|
||||
placeholder="Escribe un mensaje..." autocomplete="off">
|
||||
<label class="btn btn-light mr-1 mb-0" title="Adjuntar archivo">
|
||||
<i class="fas fa-paperclip"></i>
|
||||
<input type="file" name="attachment" id="attachment" hidden>
|
||||
</label>
|
||||
<button type="submit" class="btn btn-primary rounded-pill px-4">
|
||||
<i class="fas fa-paper-plane"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div id="attachment-preview" class="mt-1 text-muted small"></div>
|
||||
</form>
|
||||
@else
|
||||
<div class="text-center py-3">
|
||||
<p class="text-muted small mb-2">
|
||||
<i class="fas fa-lock mr-1"></i>
|
||||
Ya no son amigos. No puedes enviar mensajes.
|
||||
</p>
|
||||
@if($friendship && $friendship->status === 'pending' && $friendship->sender_id === auth()->id())
|
||||
<span class="btn btn-sm btn-outline-secondary disabled">
|
||||
<i class="fas fa-user-clock mr-1"></i> Solicitud enviada
|
||||
</span>
|
||||
@elseif($friendship && $friendship->status === 'pending' && $friendship->receiver_id === auth()->id())
|
||||
<form action="{{ route('friendships.accept', $friendship) }}" method="POST" class="d-inline">
|
||||
@csrf
|
||||
<button class="btn btn-sm btn-success">
|
||||
<i class="fas fa-check mr-1"></i> Aceptar solicitud
|
||||
</button>
|
||||
</form>
|
||||
@else
|
||||
<form action="{{ route('friendships.send', $user) }}" method="POST" class="d-inline">
|
||||
@csrf
|
||||
<button class="btn btn-sm btn-primary">
|
||||
<i class="fas fa-user-plus mr-1"></i> Enviar solicitud de amistad
|
||||
</button>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
<div id="attachment-preview" class="mt-1 text-muted small"></div>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user