Files
WMS/Modules/Helpdesk/Resources/views/partials/comment-thread.blade.php
T
2026-06-17 08:39:47 +01:00

84 lines
4.8 KiB
PHP

@props(['comments', 'level' => 0])
<div class="space-y-3">
@foreach ($comments as $comment)
@php
$commentUser = $comment->relationLoaded('user') ? $comment->getRelation('user') : null;
$commentAttachments = $comment->relationLoaded('attachments') ? $comment->getRelation('attachments') : collect();
$commentReplies = $comment->relationLoaded('replies') ? $comment->getRelation('replies') : collect();
@endphp
<div class="rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-700 dark:bg-zinc-900" style="margin-left: {{ min((int) $level, 4) * 1.25 }}rem">
<div class="flex items-start justify-between gap-3">
<div>
<div class="font-medium text-zinc-900 dark:text-zinc-100">
{{ $commentUser?->name ?? 'Unknown user' }}
</div>
<div class="text-xs text-zinc-500">
{{ $comment->created_at?->format('d M Y H:i') }}
</div>
</div>
@if ($comment->is_internal)
<flux:badge color="amber">Internal</flux:badge>
@endif
</div>
<div class="prose prose-sm mt-3 max-w-none dark:prose-invert">
{!! $comment->body !!}
</div>
@if ($commentAttachments->isNotEmpty())
<div class="mt-3 flex flex-wrap gap-2">
@foreach ($commentAttachments as $attachment)
<a href="{{ $attachment->url() }}" target="_blank" class="rounded-lg border border-zinc-200 px-3 py-1 text-xs text-zinc-600 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-300 dark:hover:bg-zinc-800">
{{ $attachment->original_name }}
</a>
@endforeach
</div>
@endif
<div class="mt-3 flex justify-end">
<flux:button size="sm" variant="primary" wire:click="startReply({{ $comment->id }})" class="!bg-blue-600 !text-white hover:!bg-blue-700 focus:!ring-blue-400/60">Reply</flux:button>
</div>
@if (($reply_parent_id ?? null) === $comment->id)
<div class="mt-4 rounded-xl border border-blue-200 bg-blue-50 p-4 dark:border-blue-900 dark:bg-blue-950/40">
<div class="space-y-2">
<label for="ticket-reply-body-{{ $comment->id }}" class="block text-sm font-medium text-zinc-700 dark:text-zinc-200">Reply</label>
<textarea
id="ticket-reply-body-{{ $comment->id }}"
dusk="ticket-reply-body"
wire:key="reply-editor-{{ $comment->id }}"
wire:model.live="replyBody"
rows="4"
placeholder="Write a reply..."
class="block w-full rounded-xl border border-zinc-300 bg-white p-4 text-sm text-zinc-900 shadow-sm outline-none transition focus:border-emerald-500 focus:ring-2 focus:ring-emerald-500/30 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
></textarea>
@error('replyBody')
<div class="text-sm text-red-600">{{ $message }}</div>
@enderror
</div>
<div class="mt-4 flex justify-end gap-2">
<button type="button" wire:click.prevent="cancelReply" class="inline-flex items-center justify-center rounded-xl bg-slate-600 px-4 py-2 text-sm font-semibold text-white shadow-sm transition hover:bg-slate-700 focus:outline-none focus:ring-2 focus:ring-slate-400/60">Cancel</button>
<button type="button" wire:click.prevent="addReply" wire:target="addReply" wire:loading.attr="disabled" class="inline-flex items-center justify-center rounded-xl bg-emerald-600 px-4 py-2 text-sm font-semibold text-white shadow-sm transition hover:bg-emerald-700 focus:outline-none focus:ring-2 focus:ring-emerald-400/60 disabled:cursor-not-allowed disabled:opacity-70">
<span wire:loading.remove wire:target="addReply">Post reply</span>
<span wire:loading wire:target="addReply">Posting...</span>
</button>
</div>
</div>
@endif
@if ($commentReplies->isNotEmpty())
<div class="mt-4">
@include('helpdesk::partials.comment-thread', [
'comments' => $commentReplies,
'level' => ((int) $level) + 1,
])
</div>
@endif
</div>
@endforeach
</div>