This commit is contained in:
2026-06-11 12:26:32 +05:45
parent 7f6ae57c3a
commit 7bad51659b
5 changed files with 263 additions and 79 deletions
+96 -28
View File
@@ -34,11 +34,10 @@
</div>
</div>
<!-- TABLE -->
<div class="bg-white border rounded-xl overflow-hidden">
<table class="w-full text-sm">
<div class="bg-white border rounded-xl overflow-x-auto">
<table class="min-w-[1200px] w-full text-sm">
<thead class="bg-slate-50 border-b">
<tr>
<th class="px-5 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider w-16">ID</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Name</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Phone</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Email</th>
@@ -76,9 +75,6 @@
data-country-flag="{{ $reg->country?->country_flag ?? '' }}"
data-status="{{ $reg->status ?? 'warm' }}"
data-comments="{{ json_encode($commentData) }}">
<td class="px-5 py-3.5">
<span class="text-xs font-mono text-slate-400">#{{ str_pad($reg->id, 4, '0', STR_PAD_LEFT) }}</span>
</td>
<td class="px-5 py-3.5">
<div class="flex items-center gap-3">
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center shrink-0">
@@ -96,34 +92,64 @@
src="{{ $reg->country?->country_flag ?? '' }}"
class="w-5 h-3.5 object-cover rounded-sm {{ $reg->country_id ? '' : 'hidden' }}"
alt="">
<select class="country-select text-xs border border-slate-200 rounded-lg px-2 py-1.5 bg-white
@if(auth()->user()->role === 'admin')
<select class="country-select text-xs border border-slate-200 rounded-lg px-2 py-1.5 bg-white
text-slate-700 focus:outline-none focus:ring-2 focus:ring-indigo-400 cursor-pointer max-w-[140px]"
data-reg-id="{{ $reg->id }}"
data-flag-target="flag-{{ $reg->id }}">
<option value=""> Select </option>
@foreach($countries as $country)
<option value="{{ $country->id }}"
data-flag="{{ $country->country_flag }}"
{{ $reg->country_id == $country->id ? 'selected' : '' }}>
{{ $country->title }}
</option>
@endforeach
</select>
data-reg-id="{{ $reg->id }}"
data-flag-target="flag-{{ $reg->id }}">
<option value=""> Select </option>
@foreach($countries as $country)
<option value="{{ $country->id }}"
data-flag="{{ $country->country_flag }}"
{{ $reg->country_id == $country->id ? 'selected' : '' }}>
{{ $country->title }}
</option>
@endforeach
</select>
@else
<span class="text-sm text-slate-600">
{{ $reg->country?->title ?? '—' }}
</span>
@endif
</div>
</td>
{{-- Status TD (read-only badge) --}}
<td class="px-5 py-3.5 text-center" onclick="event.stopPropagation()">
@php $status = $reg->status ?? 'warm'; @endphp
<span class="text-xs font-semibold rounded-full px-2.5 py-1
{{ match($status) {
'hot' => 'bg-red-50 text-red-600',
'warm' => 'bg-amber-50 text-amber-600',
'cold' => 'bg-blue-50 text-blue-600',
default => 'bg-amber-50 text-amber-600',
} }}">
{{ match($status) { 'hot' => '🔥 Hot', 'warm' => '☀️ Warm', 'cold' => '❄️ Cold', default => '☀️ Warm' } }}
</span>
@if(auth()->user()->role === 'counselor')
<select class="status-select text-xs px-2 py-1 rounded border cursor-pointer"
data-reg-id="{{ $reg->id }}">
<option value="hot" {{ $status=='hot'?'selected':'' }}>🔥 Hot</option>
<option value="warm" {{ $status=='warm'?'selected':'' }}>☀️ Warm</option>
<option value="cold" {{ $status=='cold'?'selected':'' }}>❄️ Cold</option>
</select>
@else
<span class="text-xs font-semibold rounded-full px-2.5 py-1
{{ match($status) {
'hot' => 'bg-red-50 text-red-600',
'warm' => 'bg-amber-50 text-amber-600',
'cold' => 'bg-blue-50 text-blue-600',
default => 'bg-amber-50 text-amber-600'
} }}">
{{ match($status) {
'hot' => '🔥 Hot',
'warm' => '☀️ Warm',
'cold' => '❄️ Cold',
default => '☀️ Warm'
} }}
</span>
@endif
</td>
<td class="px-5 py-3.5 text-center">
@@ -327,7 +353,7 @@ function openDetailPanel(row) {
statusEl.className='text-xs px-2 py-1 rounded-full '+cls;
statusEl.textContent=txt;
document.getElementById('detailPanel').classList.remove('translate-x-full');
document.getElementById('detailPanelOverlay').classList.remove('hidden');
}
@@ -433,4 +459,46 @@ document.querySelectorAll('.country-select').forEach(sel => {
});
});
</script>
<script>
const statusColors = {
hot: 'bg-red-50 text-red-600 border-red-200',
warm: 'bg-amber-50 text-amber-600 border-amber-200',
cold: 'bg-blue-50 text-blue-600 border-blue-200',
};
document.querySelectorAll('.status-select').forEach(sel => {
const current = sel.value;
if(statusColors[current]){
statusColors[current].split(' ').forEach(cls => sel.classList.add(cls));
}
sel.addEventListener('change', function () {
const regId = this.dataset.regId;
const status = this.value;
Object.values(statusColors).forEach(c =>
c.split(' ').forEach(cls => this.classList.remove(cls))
);
statusColors[status].split(' ').forEach(cls =>
this.classList.add(cls)
);
$.ajax({
url: '{{ route("registrations.update-status", ":id") }}'.replace(':id', regId),
method: 'POST',
data: {
_token: '{{ csrf_token() }}',
status: status
},
error: function () {
alert('Failed to update status.');
}
});
});
});
</script>
@endpush