@extends('admin.admin_master')

@section('admin')
<div class="page-content">
    <div class="container-fluid">
        <div class="row mb-4">
            <div class="col-12">
                <h4 class="page-title mb-1">Workflow Task Details</h4>
            </div>
        </div>
        <div class="card">
            <div class="card-body">
                <h5>Task ID: {{ $task->id }}</h5>
                <p><strong>Status:</strong> {{ $task->status }}</p>
                <p><strong>Workflow:</strong> {{ $task->workflow ? $task->workflow->name : '-' }}</p>
                <p><strong>Assigned User:</strong> {{ $task->assignedUser ? $task->assignedUser->name : '-' }}</p>
                <p><strong>Assigned Role:</strong> {{ $task->assignedRole ? $task->assignedRole->name : '-' }}</p>
                <p><strong>Created At:</strong> {{ $task->created_at }}</p>
                <p><strong>Updated At:</strong> {{ $task->updated_at }}</p>
                <hr>
                <h6>Document</h6>
                @if($task->document)
                    <p><strong>Title:</strong> {{ $task->document->title }}</p>
                    <p><strong>Description:</strong> {{ $task->document->description }}</p>
                    <a href="{{ route('workflow.documents.show', $task->document->id) }}" class="btn btn-primary text-white">View Document</a>
                @else
                    <p>No document attached.</p>
                @endif
                <hr>
                <h6>Transition</h6>
                @if($task->transition)
                    <p><strong>Name:</strong> {{ $task->transition->name }}</p>
                    <p><strong>From:</strong> {{ $task->transition->fromStep ? $task->transition->fromStep->name : '-' }}</p>
                    <p><strong>To:</strong> {{ $task->transition->toStep ? $task->transition->toStep->name : '-' }}</p>
                @else
                    <p>No transition info.</p>
                @endif
            </div>
        </div>
    </div>
</div>
@endsection
