@extends('layouts.app')

@section('content')
<div class="container mt-5">
    <h2>{{ isset($comment) ? 'Edit comment' : 'Manager Comment Section' }}</h2>
    @include('commons.notifications')
    <form action="{{ isset($comment) ? route('comments.update', $comment->id) : route('comments.store') }}" method="POST">
        <input type="hidden" name="user_id" value="{{ \Auth::user()->id }}">
        @csrf
        @if (isset($comment_body))
            @method('PUT')
        @endif
        <div class="card w-100">
          <div class="card-body">
            <h3>Project Details</h3>
            <h5 class="card-title">{{ $project_arr->project->name }}</h5>
            <p class="card-text">{{ $project_arr->project->description }} </p>
          </div>
        </div>
        <hr>
        <h3>Latest Update</h3>
        <table class="table">
          <thead>
            <tr>
              <th scope="col">Status Description</th>
              <th scope="col">Current Status</th>
              <th scope="col">Date Updated</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>{{ $project_arr->description }}</td>
              <td>{{ $project_arr->status }}</td>
              <td>{{ $project_arr->created_at }}</td>
            </tr>
          </tbody>
        </table>
        <hr>
        <div class="mb-3">
            <label for="commnetBody" class="form-label">Comment Body</label>
            <textarea class="form-control" id="commnetBody" name="comment_body" rows="4" required>{{ $comment->body ?? '' }}</textarea>
        </div>
        <button type="submit" class="btn btn-primary">Create comment</button>
    </form>
</div>
@endsection