@extends('layouts.app')

@section('content')
<div class="container mt-5">
    <h2>{{ isset($project) ? 'Edit project' : 'Create project' }}</h2>
    @include('commons.notifications')
    <form action="{{ isset($project) ? route('projects.update', $project->id) : route('projects.store') }}" method="POST">
        <input type="hidden" name="user_id" value="{{ \Auth::user()->id }}">
        @csrf
        @if (isset($project))
            @method('PUT')
        @endif
        <div class="mb-3">
            <label for="name" class="form-label">Project Name</label>
            <input type="text" class="form-control" id="name" name="name" value="{{ $project->name ?? '' }}" required>
        </div>

        <div class="mb-3">
            <label for="description" class="form-label">Description</label>
            <textarea class="form-control" id="description" name="description" rows="4" required>{{ $project->description ?? '' }}</textarea>
        </div>

        <div class="mb-3">
            <label for="dependancy" class="form-label">Dependancy</label>
            <input type="text" class="form-control" id="dependancy" name="dependancy" value="{{ $project->dependancy ?? '' }}" placeholder="e.g., project ID or Name" required>
        </div>

        <div class="mb-3">
            <label for="status" class="form-label">Status</label>
            <select class="form-select" id="status" name="status" required>
                <option value="" disabled>Select Status</option>
                <option value="Active" {{ (isset($project) && $project->status == 'Active') ? 'selected' : '' }}>Active</option>
                <option value="Completed" {{ (isset($project) && $project->status == 'Completed') ? 'selected' : '' }}>Completed</option>
                <option value="Pending" {{ (isset($project) && $project->status == 'Pending') ? 'selected' : '' }}>Pending</option>
                <option value="On Hold" {{ (isset($project) && $project->status == 'On Hold') ? 'selected' : '' }}>On Hold</option>
            </select>
        </div>

        <button type="submit" class="btn btn-primary">{{ isset($project) ? 'Update project' : 'Create project' }}</button>
    </form>
</div>

@endsection