Files
Kent-logistics-Laravel/resources/views/admin/chat_support.blade.php

622 lines
18 KiB
PHP
Raw Normal View History

2025-11-06 17:09:52 +05:30
@extends('admin.layouts.app')
2025-12-19 11:00:34 +05:30
@section('page-title', 'Chat Support Dashboard')
2025-11-06 17:09:52 +05:30
@section('content')
2025-12-19 11:00:34 +05:30
<style>
:root {
--primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
--success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
--danger-gradient: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
--warning-gradient: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
--info-gradient: linear-gradient(135deg, #56ccf2 0%, #2f80ed 100%);
2025-12-19 16:20:43 +05:30
--card-shadow: 0 3px 10px rgba(0,0,0,0.05);
--card-shadow-hover: 0 6px 16px rgba(0,0,0,0.10);
--border-radius: 8px;
--transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
2025-12-19 11:00:34 +05:30
}
2025-12-15 11:03:30 +05:30
2025-12-19 11:00:34 +05:30
* {
box-sizing: border-box;
}
2025-12-15 11:03:30 +05:30
2025-12-19 11:00:34 +05:30
.chat-dashboard {
min-height: 100vh;
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
2025-12-19 16:20:43 +05:30
padding: 0.75rem;
2025-12-19 11:00:34 +05:30
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
2025-12-15 11:03:30 +05:30
2025-12-19 11:00:34 +05:30
.dashboard-header {
text-align: center;
2025-12-19 16:20:43 +05:30
margin-bottom: 1rem;
2025-12-19 11:00:34 +05:30
position: relative;
}
2025-12-15 11:03:30 +05:30
2025-12-19 11:00:34 +05:30
.dashboard-title {
2025-12-19 16:20:43 +05:30
font-size: clamp(1.4rem, 2.5vw, 2rem);
2025-12-19 11:00:34 +05:30
font-weight: 800;
background: var(--primary-gradient);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
2025-12-19 16:20:43 +05:30
margin: 0 0 0.4rem 0;
2025-12-19 11:00:34 +05:30
position: relative;
display: inline-block;
}
2025-12-15 11:03:30 +05:30
2025-12-19 11:00:34 +05:30
.dashboard-title::before {
content: '💬';
position: absolute;
2025-12-19 16:20:43 +05:30
left: -1.6rem;
2025-12-19 11:00:34 +05:30
top: 50%;
transform: translateY(-50%);
2025-12-19 16:20:43 +05:30
font-size: 1.3rem;
2025-12-19 11:00:34 +05:30
animation: bounce 2s infinite;
}
2025-12-15 11:03:30 +05:30
2025-12-19 11:00:34 +05:30
@keyframes bounce {
0%, 20%, 50%, 80%, 100% { transform: translateY(-50%) translateY(0); }
2025-12-19 16:20:43 +05:30
40% { transform: translateY(-50%) translateY(-5px); }
60% { transform: translateY(-50%) translateY(-2px); }
2025-12-19 11:00:34 +05:30
}
2025-12-15 11:03:30 +05:30
2025-12-19 11:00:34 +05:30
.dashboard-subtitle {
color: #64748b;
2025-12-19 16:20:43 +05:30
font-size: 0.8rem;
max-width: 380px;
2025-12-19 11:00:34 +05:30
margin: 0 auto;
2025-12-19 16:20:43 +05:30
line-height: 1.3;
2025-12-19 11:00:34 +05:30
}
2025-12-15 11:03:30 +05:30
2025-12-19 16:20:43 +05:30
/* 🔔 GLOBAL NEW MESSAGE COUNTER */
.global-notify {
margin: 0 auto 0.75rem auto;
max-width: 320px;
padding: 0.35rem 0.7rem;
border-radius: 999px;
background: rgba(15,23,42,0.03);
border: 1px dashed #cbd5f5;
2025-12-19 11:00:34 +05:30
display: flex;
align-items: center;
2025-12-19 16:20:43 +05:30
justify-content: center;
gap: 0.4rem;
font-size: 0.78rem;
color: #1e293b;
2025-12-19 11:00:34 +05:30
}
2025-12-15 11:03:30 +05:30
2025-12-19 16:20:43 +05:30
.global-notify-badge {
background: #ef4444;
color: #fff;
min-width: 18px;
padding: 0 0.35rem;
height: 18px;
border-radius: 999px;
display: inline-flex;
2025-12-19 11:00:34 +05:30
align-items: center;
justify-content: center;
2025-12-19 16:20:43 +05:30
font-size: 0.7rem;
font-weight: 700;
box-shadow: 0 0 0 2px rgba(254, 226, 226, 0.8);
2025-12-19 11:00:34 +05:30
}
2025-12-15 11:03:30 +05:30
2025-12-19 16:20:43 +05:30
.global-notify.d-none {
display: none;
2025-12-19 11:00:34 +05:30
}
2025-12-15 11:03:30 +05:30
2025-12-19 11:00:34 +05:30
.tickets-container {
background: rgba(255, 255, 255, 0.95);
2025-12-19 16:20:43 +05:30
backdrop-filter: blur(12px);
2025-12-19 11:00:34 +05:30
border-radius: var(--border-radius);
2025-12-19 16:20:43 +05:30
padding: 0.75rem 0.9rem;
2025-12-19 11:00:34 +05:30
box-shadow: var(--card-shadow);
border: 1px solid rgba(255, 255, 255, 0.3);
2025-12-19 16:20:43 +05:30
/* max-height / overflow काढले, जेणेकरून बाहेरचा page scroll वापरला जाईल */
display: block;
2025-12-19 11:00:34 +05:30
}
2025-12-15 11:03:30 +05:30
2025-12-19 11:00:34 +05:30
.tickets-header {
display: flex;
justify-content: space-between;
align-items: center;
2025-12-19 16:20:43 +05:30
margin-bottom: 0.6rem;
padding-bottom: 0.45rem;
2025-12-19 11:00:34 +05:30
border-bottom: 1px solid #f1f5f9;
}
.tickets-title {
2025-12-19 16:20:43 +05:30
font-size: 1rem;
2025-12-19 11:00:34 +05:30
font-weight: 700;
color: #1e293b;
display: flex;
align-items: center;
2025-12-19 16:20:43 +05:30
gap: 0.3rem;
2025-12-19 11:00:34 +05:30
}
.tickets-count {
background: var(--primary-gradient);
color: white;
2025-12-19 16:20:43 +05:30
padding: 0.1rem 0.45rem;
border-radius: 12px;
font-size: 0.7rem;
2025-12-19 11:00:34 +05:30
font-weight: 600;
}
.ticket-item {
background: white;
2025-12-19 16:20:43 +05:30
border-radius: 6px;
padding: 0.4rem 0.6rem;
margin-bottom: 0.3rem;
border: 1px solid #e5e7eb;
2025-12-19 11:00:34 +05:30
transition: var(--transition);
position: relative;
overflow: hidden;
}
.ticket-item::before {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
2025-12-19 16:20:43 +05:30
width: 2px;
2025-12-19 11:00:34 +05:30
background: var(--primary-gradient);
transform: scaleY(0);
transition: var(--transition);
}
.ticket-item:hover {
2025-12-19 16:20:43 +05:30
transform: translateY(-1px);
2025-12-19 11:00:34 +05:30
box-shadow: var(--card-shadow-hover);
2025-12-19 16:20:43 +05:30
border-color: rgba(102, 126, 234, 0.35);
2025-12-19 11:00:34 +05:30
}
.ticket-item:hover::before {
transform: scaleY(1);
}
.ticket-header {
display: flex;
align-items: flex-start;
2025-12-19 16:20:43 +05:30
gap: 0.4rem;
margin-bottom: 0.25rem;
2025-12-19 11:00:34 +05:30
}
.ticket-avatar {
2025-12-19 16:20:43 +05:30
width: 26px;
height: 26px;
border-radius: 6px;
2025-12-19 11:00:34 +05:30
background: var(--info-gradient);
display: flex;
align-items: center;
justify-content: center;
2025-12-19 16:20:43 +05:30
font-size: 0.75rem;
2025-12-19 11:00:34 +05:30
font-weight: 700;
color: white;
flex-shrink: 0;
2025-12-19 16:20:43 +05:30
box-shadow: 0 3px 8px rgba(86, 204, 242, 0.25);
2025-12-19 11:00:34 +05:30
position: relative;
overflow: hidden;
}
.ticket-avatar::after {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
2025-12-19 16:20:43 +05:30
transition: left 0.4s;
2025-12-19 11:00:34 +05:30
}
.ticket-item:hover .ticket-avatar::after {
left: 100%;
}
.ticket-content {
flex: 1;
min-width: 0;
}
.ticket-name {
2025-12-19 16:20:43 +05:30
font-size: 0.8rem;
2025-12-19 11:00:34 +05:30
font-weight: 700;
color: #1e293b;
2025-12-19 16:20:43 +05:30
margin: 0 0 0.08rem 0;
2025-12-19 11:00:34 +05:30
display: flex;
align-items: center;
2025-12-19 16:20:43 +05:30
gap: 0.25rem;
2025-12-19 11:00:34 +05:30
}
.unread-count {
background: #ef4444;
color: white;
2025-12-19 16:20:43 +05:30
min-width: 16px;
height: 16px;
border-radius: 999px;
2025-12-19 11:00:34 +05:30
display: flex;
align-items: center;
justify-content: center;
2025-12-19 16:20:43 +05:30
font-size: 0.6rem;
2025-12-19 11:00:34 +05:30
font-weight: 700;
2025-12-19 16:20:43 +05:30
box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
2025-12-19 11:00:34 +05:30
animation: pulse 2s infinite;
}
@keyframes pulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.05); }
}
.ticket-preview {
color: #64748b;
2025-12-19 16:20:43 +05:30
font-size: 0.7rem;
line-height: 1.25;
margin-bottom: 0.1rem;
2025-12-19 11:00:34 +05:30
display: flex;
align-items: center;
2025-12-19 16:20:43 +05:30
gap: 0.25rem;
max-height: 1.8em;
overflow: hidden;
2025-12-19 11:00:34 +05:30
}
.ticket-time {
2025-12-19 16:20:43 +05:30
font-size: 0.65rem;
2025-12-19 11:00:34 +05:30
color: #94a3b8;
display: flex;
align-items: center;
2025-12-19 16:20:43 +05:30
gap: 0.18rem;
2025-12-19 11:00:34 +05:30
}
.ticket-time svg {
2025-12-19 16:20:43 +05:30
width: 10px;
height: 10px;
2025-12-19 11:00:34 +05:30
flex-shrink: 0;
}
.ticket-footer {
display: flex;
align-items: center;
justify-content: space-between;
2025-12-19 16:20:43 +05:30
padding-top: 0.3rem;
border-top: 1px dashed #e5e7eb;
margin-top: 0.2rem;
2025-12-19 11:00:34 +05:30
}
.status-badge {
2025-12-19 16:20:43 +05:30
padding: 0.14rem 0.45rem;
border-radius: 999px;
font-size: 0.6rem;
2025-12-19 11:00:34 +05:30
font-weight: 700;
text-transform: uppercase;
2025-12-19 16:20:43 +05:30
letter-spacing: 0.2px;
2025-12-19 11:00:34 +05:30
}
.status-open { background: var(--success-gradient); color: white; }
.status-closed{ background: var(--danger-gradient); color: white; }
.chat-btn {
background: var(--primary-gradient);
color: white;
border: none;
2025-12-19 16:20:43 +05:30
padding: 0.25rem 0.6rem;
border-radius: 999px;
2025-12-19 11:00:34 +05:30
font-weight: 600;
2025-12-19 16:20:43 +05:30
font-size: 0.7rem;
display: inline-flex;
2025-12-19 11:00:34 +05:30
align-items: center;
2025-12-19 16:20:43 +05:30
gap: 0.25rem;
2025-12-19 11:00:34 +05:30
text-decoration: none;
transition: var(--transition);
2025-12-19 16:20:43 +05:30
box-shadow: 0 3px 10px rgba(102, 126, 234, 0.25);
white-space: nowrap;
2025-12-19 11:00:34 +05:30
}
.chat-btn:hover {
transform: translateY(-1px);
2025-12-19 16:20:43 +05:30
box-shadow: 0 6px 16px rgba(102, 126, 234, 0.35);
2025-12-19 11:00:34 +05:30
color: white;
}
.chat-btn::after {
content: '→';
2025-12-19 16:20:43 +05:30
transition: margin-left 0.25s ease;
2025-12-19 11:00:34 +05:30
margin-left: 0;
}
.chat-btn:hover::after {
2025-12-19 16:20:43 +05:30
margin-left: 0.18rem;
2025-12-19 11:00:34 +05:30
}
.empty-state {
text-align: center;
2025-12-19 16:20:43 +05:30
padding: 1.6rem 1rem;
2025-12-19 11:00:34 +05:30
background: rgba(255, 255, 255, 0.6);
border-radius: var(--border-radius);
border: 2px dashed #e2e8f0;
}
.empty-icon {
2025-12-19 16:20:43 +05:30
font-size: 2.8rem;
margin-bottom: 0.9rem;
2025-12-19 11:00:34 +05:30
display: block;
animation: float 3s ease-in-out infinite;
}
@keyframes float {
0%, 100% { transform: translateY(0px); }
2025-12-19 16:20:43 +05:30
50% { transform: translateY(-8px); }
2025-12-19 11:00:34 +05:30
}
.empty-title {
2025-12-19 16:20:43 +05:30
font-size: 1.05rem;
2025-12-19 11:00:34 +05:30
font-weight: 700;
color: #1e293b;
2025-12-19 16:20:43 +05:30
margin-bottom: 0.4rem;
2025-12-19 11:00:34 +05:30
}
.empty-subtitle {
color: #64748b;
2025-12-19 16:20:43 +05:30
font-size: 0.85rem;
margin-bottom: 1rem;
line-height: 1.35;
2025-12-19 11:00:34 +05:30
}
.ticket-id {
2025-12-19 16:20:43 +05:30
background: rgba(102, 126, 234, 0.08);
2025-12-19 11:00:34 +05:30
color: #667eea;
2025-12-19 16:20:43 +05:30
padding: 0.12rem 0.5rem;
border-radius: 999px;
font-size: 0.65rem;
2025-12-19 11:00:34 +05:30
font-weight: 600;
display: inline-flex;
align-items: center;
2025-12-19 16:20:43 +05:30
gap: 0.18rem;
2025-12-19 11:00:34 +05:30
}
.new-message-dot {
position: absolute;
2025-12-19 16:20:43 +05:30
top: 0.45rem;
right: 0.5rem;
width: 7px;
height: 7px;
2025-12-19 11:00:34 +05:30
background: #ef4444;
border-radius: 50%;
border: 2px solid white;
box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3);
animation: blink 1.5s infinite;
z-index: 10;
}
@keyframes blink {
0%, 100% { opacity: 1; transform: scale(1); }
2025-12-19 16:20:43 +05:30
50% { opacity: 0.5; transform: scale(1.1); }
}
/* इथे आता inner scroll नाही */
.tickets-list {
/* flex: 1; काढला, overflow काढला, parent + body scroll वापरेल */
padding-right: 0;
}
.tickets-list::-webkit-scrollbar {
width: 3px;
}
.tickets-list::-webkit-scrollbar-track {
background: #f1f5f9;
border-radius: 6px;
}
.tickets-list::-webkit-scrollbar-thumb {
background: var(--primary-gradient);
border-radius: 6px;
2025-12-19 11:00:34 +05:30
}
@media (max-width: 768px) {
.chat-dashboard {
2025-12-19 16:20:43 +05:30
padding: 0.6rem;
2025-12-19 11:00:34 +05:30
}
2025-12-19 16:20:43 +05:30
.tickets-container {
/* max-height काढलेले, mobile वरही outer scroll */
2025-12-19 11:00:34 +05:30
}
2025-12-19 16:20:43 +05:30
2025-12-19 11:00:34 +05:30
.ticket-header {
flex-direction: column;
2025-12-19 16:20:43 +05:30
gap: 0.35rem;
2025-12-19 11:00:34 +05:30
}
2025-12-19 16:20:43 +05:30
2025-12-19 11:00:34 +05:30
.ticket-footer {
flex-direction: column;
2025-12-19 16:20:43 +05:30
gap: 0.35rem;
2025-12-19 11:00:34 +05:30
align-items: stretch;
}
2025-12-19 16:20:43 +05:30
2025-12-19 11:00:34 +05:30
.chat-btn {
justify-content: center;
}
}
</style>
<div class="chat-dashboard">
<!-- Header -->
<div class="dashboard-header">
<h1 class="dashboard-title">Live Chat Dashboard</h1>
<p class="dashboard-subtitle">
Monitor customer conversations with real-time updates
</p>
</div>
2025-12-19 16:20:43 +05:30
<!-- 🔔 GLOBAL NEW MESSAGES NOTIFICATION -->
<div id="globalNewMessageBox" class="global-notify d-none">
<span>New messages:</span>
<span id="globalNewMessageCount" class="global-notify-badge">0</span>
2025-12-19 11:00:34 +05:30
</div>
<!-- Tickets Container -->
<div class="tickets-container">
<div class="tickets-header">
<div>
<h2 class="tickets-title">
📋 Active Conversations
<span class="tickets-count">{{ $tickets->count() }}</span>
</h2>
</div>
2025-12-15 11:03:30 +05:30
</div>
2025-12-19 11:00:34 +05:30
@if($tickets->count() === 0)
<!-- Empty State -->
<div class="empty-state">
<div class="empty-icon">💬</div>
<h3 class="empty-title">No Active Conversations</h3>
<p class="empty-subtitle">
Customer conversations will appear here with real-time notifications.
</p>
<div class="ticket-id">Ready for support requests</div>
</div>
@else
<!-- Tickets List -->
<div class="tickets-list">
@foreach($tickets as $ticket)
<div class="ticket-item" data-ticket-id="{{ $ticket->id }}">
@if($ticket->unread_count > 0)
<div class="new-message-dot"></div>
@endif
<div class="ticket-header">
<div class="ticket-avatar">
{{ strtoupper(substr($ticket->user->customer_name ?? $ticket->user->name, 0, 1)) }}
</div>
<div class="ticket-content">
<div class="ticket-name">
{{ $ticket->user->customer_name ?? $ticket->user->name }}
@if($ticket->unread_count > 0)
<span id="badge-{{ $ticket->id }}" class="unread-count">
{{ $ticket->unread_count }}
</span>
@endif
</div>
2025-12-19 16:20:43 +05:30
2025-12-19 11:00:34 +05:30
@php
$lastMsg = $ticket->messages()->latest()->first();
@endphp
2025-12-19 16:20:43 +05:30
2025-12-19 11:00:34 +05:30
<div class="ticket-preview">
@if($lastMsg)
@if($lastMsg->message)
2025-12-19 16:20:43 +05:30
{{ Str::limit($lastMsg->message, 45) }}
2025-12-19 11:00:34 +05:30
@elseif(Str::startsWith($lastMsg->file_type, 'image'))
📷 Photo shared
@else
📎 File attached
@endif
@else
<em>Conversation started</em>
@endif
</div>
@if($lastMsg)
<div class="ticket-time">
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 16">
<path d="M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71V3.5z"/>
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0z"/>
</svg>
{{ $lastMsg->created_at->diffForHumans() }}
</div>
@endif
</div>
</div>
<div class="ticket-footer">
<span class="status-badge status-{{ $ticket->status }}">
{{ ucfirst($ticket->status) }}
</span>
<a href="{{ route('admin.chat.open', $ticket->id) }}" class="chat-btn">
Open Chat
</a>
</div>
</div>
@endforeach
</div>
@endif
2025-12-15 11:03:30 +05:30
</div>
2025-11-06 17:09:52 +05:30
</div>
2025-12-19 11:00:34 +05:30
@endsection
2025-12-15 11:03:30 +05:30
@section('scripts')
<script>
// -------------------------------
// WAIT FOR ECHO READY (DEFINE IT)
// -------------------------------
function waitForEcho(callback, retries = 40) {
if (window.Echo) {
console.log('%c[ECHO] Ready (Admin List)', 'color: green; font-weight: bold;');
callback();
return;
}
if (retries <= 0) {
console.error('[ECHO] Failed to initialize');
return;
}
setTimeout(() => waitForEcho(callback, retries - 1), 200);
}
// -------------------------------
// LISTEN FOR REALTIME MESSAGES
// -------------------------------
waitForEcho(() => {
console.log('[ADMIN LIST] Listening for new messages...');
2025-12-19 16:20:43 +05:30
const globalBox = document.getElementById('globalNewMessageBox');
const globalCount = document.getElementById('globalNewMessageCount');
let totalNewMessages = 0;
2025-12-15 11:03:30 +05:30
window.Echo.private('admin.chat')
.listen('.NewChatMessage', (event) => {
// only USER → ADMIN messages
if (event.sender_type !== 'App\\Models\\User') return;
2025-12-19 16:20:43 +05:30
const ticketId = event.ticket_id;
// 1) UPDATE PER-TICKET BADGE
const badge = document.getElementById(`badge-${ticketId}`);
if (badge) {
let count = parseInt(badge.innerText || 0);
badge.innerText = count + 1;
badge.classList.remove('d-none');
}
// 2) UPDATE GLOBAL NEW MESSAGE COUNTER
totalNewMessages++;
if (globalBox && globalCount) {
globalBox.classList.remove('d-none');
globalCount.innerText = totalNewMessages;
}
// 3) त्या ticket ला यादीत सर्वात वर आणा आणि स्क्रोल करा
const listContainer = document.querySelector('.tickets-list');
const ticketEl = document.querySelector(`.ticket-item[data-ticket-id="${ticketId}"]`);
if (listContainer && ticketEl) {
if (ticketEl.previousElementSibling) {
listContainer.insertBefore(ticketEl, listContainer.firstElementChild);
}
const topOffset = ticketEl.offsetTop;
window.scrollTo({
top: listContainer.offsetTop + topOffset - 20,
behavior: 'smooth'
});
}
console.log('[ADMIN LIST] Badge/global counter updated for ticket', ticketId);
2025-12-15 11:03:30 +05:30
});
});
</script>
2025-12-19 16:20:43 +05:30
@endsection