@extends('layouts.user')

@section('title', 'Checkout')

@section('content')
<div class="container mt-4">
    <h2>🛒 Checkout</h2>

    <table class="table table-bordered">
        <thead>
            <tr>
                <th>Pizza</th>
                <th>Jumlah</th>
                <th>Harga (Satuan)</th>
                <th>Total Harga</th>
            </tr>
        </thead>
        <tbody>
            @foreach($cartItems as $item)
                <tr>
                    <td>{{ $item->pizza->nama }}</td>
                    <td>{{ $item->jumlah }}</td>
                    <td>Rp {{ number_format($item->pizza->harga,0,',','.') }}</td>
                    <td>Rp {{ number_format($item->jumlah * $item->pizza->harga,0,',','.') }}</td>
                </tr>
            @endforeach
        </tbody>
    </table>

    <h4>Total Belanja: Rp {{ number_format($total,0,',','.') }}</h4>

    <form action="{{ route('user.checkout.process') }}" method="POST">
        @csrf
        <div class="mb-3">
            <label>Nama Penerima</label>
            <input type="text" name="nama_pelanggan" class="form-control" required>
        </div>
        <div class="mb-3">
            <label>Alamat</label>
            <textarea name="alamat" class="form-control" required></textarea>
        </div>
        <div class="mb-3">
            <label>Metode Pembayaran</label>
            <select name="metode_pembayaran" class="form-control" required>
                <option value="cod">COD</option>
                <option value="qris">QRIS</option>
            </select>
        </div>
        <button type="submit" class="btn btn-success">Konfirmasi Pesanan</button>
    </form>
</div>
@endsection
