@extends('layouts.app')

@section('content')
<div class="container">
    <h2>Editar Propiedad</h2>

    <form action="{{ route('properties.update', $property) }}" method="POST" class="form-base">
        @csrf
        @method('PUT')

        <div class="mb-3">
            <label>Código</label>
            <input type="text" name="code" class="form-control" value="{{ $property->code }}" required>
        </div>

        <div class="mb-3">
            <label>Nombre</label>
            <input type="text" name="name" class="form-control" value="{{ $property->name }}" required>
        </div>
 <!--
        <div class="mb-3">
            <label>Área (m²)</label>
            <input type="number" step="0.01" name="area" class="form-control" value="{{ $property->area }}" required>
        </div>

        <div class="mb-3">
            <label>Precio</label>
            <input type="number" step="0.01" name="price" class="form-control" value="{{ $property->price }}" required>
        </div>
-->

        <div class="mb-3">
            <label>Estado</label>
            <select name="status" class="form-control">
                <option value="available" {{ $property->status === 'available' ? 'selected' : '' }}>Disponible</option>
                <option value="reserved" {{ $property->status === 'reserved' ? 'selected' : '' }}>Reservada</option>
                <option value="sold" {{ $property->status === 'sold' ? 'selected' : '' }}>Vendida</option>
            </select>
        </div>

        <div class="mb-3">
            <label>Fractional</label>
            <select name="fractional_id" class="form-control">
                @foreach($fractionals as $fractional)
                    <option value="{{ $fractional->id }}" {{ $property->fractional_id === $fractional->id ? 'selected' : '' }}>
                        {{ $fractional->name }}
                    </option>
                @endforeach
            </select>
        </div>

        <div class="mb-3">
            <label>Tipo de Propiedad</label>
            <select name="property_type_id" class="form-control">
                @foreach($propertyTypes as $type)
                    <option value="{{ $type->id }}" {{ $property->property_type_id === $type->id ? 'selected' : '' }}>
                        {{ $type->name }}
                    </option>
                @endforeach
            </select>
        </div>

        <button class="btn btn-primary" type="submit">Actualizar</button>
    </form>
</div>
@endsection
