@extends('layout.app')

@section('content')
    <div class="card">
        <div class="card-header">
            <h3 class="card-title">Edit TJ Box</h3>
        </div>
        <div class="card-body">
            <form action="{{ route('tj-box-map.update', $tjBox->id) }}" method="POST">
                @csrf
                @method('PUT')

                <div class="form-group">
                    <label for="name">Name <span class="text-danger">*</span></label>
                    <input type="text" name="name" id="name" class="form-control"
                        value="{{ old('name', $tjBox->name) }}" required>
                    @error('name')
                        <span class="text-danger">{{ $message }}</span>
                    @enderror
                </div>

                <div class="form-group">
                    <label for="coordinates">Coordinates (JSON) <span class="text-danger">*</span></label>
                    <textarea name="coordinates" id="coordinates" rows="4" class="form-control" required>{{ old('coordinates', $tjBox->coordinates) }}</textarea>
                    <small class="form-text text-muted">
                        Store coordinates as valid JSON. Example: <code>{"lat": 23.8103, "lng": 90.4125}</code>
                    </small>
                    @error('coordinates')
                        <span class="text-danger">{{ $message }}</span>
                    @enderror
                </div>

                <div class="form-group">
                    <label for="remarks">Remarks</label>
                    <textarea name="remarks" id="remarks" rows="3" class="form-control">{{ old('remarks', $tjBox->remarks) }}</textarea>
                    @error('remarks')
                        <span class="text-danger">{{ $message }}</span>
                    @enderror
                </div>

                <div class="form-group mt-3">
                    <button type="submit" class="btn btn-primary">Update</button>
                    <a href="{{ route('tj-box-map.index') }}" class="btn btn-secondary">Back</a>
                </div>
            </form>
        </div>
    </div>
@endsection

