@extends('layouts.app')
@section('title', isset($weight) ? 'Edit Weight' : 'Add Weight')
@section('content')
<h4 class="mb-3">{{ isset($weight) ? 'Edit Weight' : 'Add Weight' }}</h4>
<div class="card">
    <div class="card-body">
        <form action="{{ isset($weight) ? route('weights.update', $weight) : route('weights.store') }}" method="POST">
            @csrf
            @if(isset($weight)) @method('PUT') @endif
            <div class="row g-3">
                <div class="col-md-4">
                    <label for="label" class="form-label">Weight Label</label>
                    <input type="text" name="label" id="label" class="form-control" value="{{ old('label', $weight->label ?? '') }}" required placeholder="e.g. 10KG, 15KG, 20KG, 50KG">
                </div>
                <div class="col-md-3">
                    <label for="sort_order" class="form-label">Sort Order</label>
                    <input type="number" name="sort_order" id="sort_order" class="form-control" value="{{ old('sort_order', $weight->sort_order ?? 0) }}">
                    <small class="text-muted">Lower number shows first</small>
                </div>
            </div>
            <div class="mt-3">
                <button type="submit" class="btn btn-primary">{{ isset($weight) ? 'Update' : 'Save' }}</button>
                <a href="{{ route('weights.index') }}" class="btn btn-secondary">Cancel</a>
            </div>
        </form>
    </div>
</div>
@endsection
