@extends('app')
@section('content')
<div class="container-fluid px-4">
    <h5 class="mt-4">Proyek</h5>
    @session('success')
    <div class="alert alert-success alert-dismissible fade show" role="alert">
        <i class="fa-solid fa-check-circle"></i>
        <strong>Berhasil!</strong> {{ session('success') }}
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    </div>
    @endsession
    @session('error')
    <div class="alert alert-danger alert-dismissible fade show" role="alert">
        <i class="fa-solid fa-triangle-exclamation"></i>
        <strong>Gagal!</strong> {{ session('error') }}
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    </div>
    @endsession
    <div class="card mb-4">
        <div class="card-header">
            <i class="fas fa-table me-1"></i>
            Daftar Proyek
            <a href="{{ route('project.create') }}" class="btn btn-primary float-end"><i class="fa-solid fa-plus"></i> Tambah Proyek</a>
        </div>
        <div class="card-body">
            <table id="datatablesSimple">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>Nama Aplikasi</th>
                        <th>Deskripsi</th>
                        <th>Tautan</th>
                        <th>Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($projects as $project)
                    <tr>
                        <td>{{ $loop->iteration }}</td>
                        <td>{{ $project->nama_aplikasi }}</td>
                        <td>{{ $project->deskripsi }}</td>
                        <td>
                            <a href="{{ $project->link }}" target="_blank">Lihat</a>
                        </td>
                        <td>
                            <a href="{{ route('project.show', $project->id) }}" class="btn btn-sm btn-info"><i
                                    class="fa-solid fa-circle-info"></i></a>
                            <a href="{{ route('project.edit', $project->id) }}" class="btn btn-sm btn-warning"><i
                                    class="fa-solid fa-pen-to-square"></i></a>
                            <form action="{{ route('project.destroy', $project->id) }}" method="POST"
                                class="d-inline">
                                @csrf
                                @method('DELETE')
                                <button type="submit" class="btn btn-sm btn-danger"
                                    onclick="return confirm('Are you sure?')">
                                    <i class="fa-solid fa-trash"></i>
                                </button>
                            </form>
                        </td>
                    </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </div>
</div>
@endsection