|
80 | 80 | @endif |
81 | 81 |
|
82 | 82 | <div class="bg-white p-6 border border-gray-300 rounded-lg mt-6"> |
83 | | - <h4 class="font-bold text-lg text-gray-900 mb-4">Reacties</h4> |
84 | | - |
85 | | - @foreach($ticket->comments as $comment) |
86 | | - <div class="mb-2 p-2 bg-gray-100 rounded"> |
87 | | - <strong>{{ $comment->user->name }}</strong> |
88 | | - <p>{{ $comment->body }}</p> |
89 | | - <span class="text-xs text-gray-500">{{ $comment->created_at->diffForHumans() }}</span> |
| 83 | + <h4 class="font-bold text-lg text-gray-900 mb-6">Reacties</h4> |
| 84 | + |
| 85 | + @if($ticket->comments->isEmpty()) |
| 86 | + <p class="text-sm text-gray-400 text-center py-6">Nog geen reacties. Wees de eerste!</p> |
| 87 | + @else |
| 88 | + <div class="space-y-4 mb-6"> |
| 89 | + @foreach($ticket->comments as $comment) |
| 90 | + @php |
| 91 | + $isOwn = auth()->check() && auth()->id() === $comment->user_id; |
| 92 | + $initials = collect(explode(' ', $comment->user->name)) |
| 93 | + ->map(fn($w) => strtoupper($w[0])) |
| 94 | + ->take(2) |
| 95 | + ->implode(''); |
| 96 | + $colors = ['bg-purple-500','bg-blue-500','bg-green-500','bg-pink-500','bg-orange-500','bg-teal-500']; |
| 97 | + $color = $colors[$comment->user_id % count($colors)]; |
| 98 | + @endphp |
| 99 | + <div class="flex gap-4 {{ $isOwn ? 'flex-row-reverse' : '' }}"> |
| 100 | + <div class="h-9 w-9 rounded-full {{ $color }} flex items-center justify-center text-white text-xs font-bold shrink-0"> |
| 101 | + {{ $initials }} |
| 102 | + </div> |
| 103 | + <div class="max-w-[75%] {{ $isOwn ? 'items-end' : 'items-start' }} flex flex-col"> |
| 104 | + <div class="{{ $isOwn ? 'bg-blue-50 border border-blue-200' : 'bg-gray-50 border border-gray-200' }} rounded-lg px-4 py-3"> |
| 105 | + <div class="flex items-center gap-2 mb-1 {{ $isOwn ? 'flex-row-reverse' : '' }}"> |
| 106 | + <span class="text-sm font-semibold text-gray-800"> |
| 107 | + {{ $comment->user->name }} |
| 108 | + @if($isOwn) |
| 109 | + <span class="text-xs text-blue-500 font-normal ml-1">(jij)</span> |
| 110 | + @endif |
| 111 | + </span> |
| 112 | + <span class="text-xs text-gray-400">{{ $comment->created_at->diffForHumans() }}</span> |
| 113 | + </div> |
| 114 | + <p class="text-sm text-gray-700 leading-relaxed">{{ $comment->body }}</p> |
| 115 | + </div> |
| 116 | + </div> |
| 117 | + </div> |
| 118 | + @endforeach |
90 | 119 | </div> |
91 | | - @endforeach |
| 120 | + @endif |
92 | 121 |
|
93 | 122 | @auth |
94 | | - <form action="{{ route('comments.store', $ticket) }}" method="POST" class="mt-4"> |
| 123 | + <form action="{{ route('comments.store', $ticket) }}" method="POST"> |
95 | 124 | @csrf |
96 | | - <textarea name="body" rows="3" class="w-full border rounded p-2" placeholder="Voeg een reactie toe..."></textarea> |
97 | | - <x-input-error :messages="$errors->get('body')" class="mt-1" /> |
98 | | - <button type="submit" class="mt-2 px-4 py-2 bg-blue-600 text-white rounded">Plaatsen</button> |
| 125 | + <div class="border border-gray-300 rounded-lg p-4 bg-gray-50"> |
| 126 | + <textarea |
| 127 | + name="body" |
| 128 | + rows="3" |
| 129 | + class="w-full text-sm text-gray-800 bg-transparent resize-none outline-none placeholder-gray-400" |
| 130 | + placeholder="Schrijf een reactie..."></textarea> |
| 131 | + <x-input-error :messages="$errors->get('body')" class="mt-1" /> |
| 132 | + <div class="flex justify-end mt-2"> |
| 133 | + <button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium px-4 py-2 rounded transition"> |
| 134 | + Verstuur reactie |
| 135 | + </button> |
| 136 | + </div> |
| 137 | + </div> |
99 | 138 | </form> |
100 | 139 | @endauth |
101 | 140 | </div> |
|
0 commit comments