@extends('layout')

@section('content')
    <div class="columns is-centered">
        <div class="column is-6">
            <div class="box">
                <h3 class="title is-3 has-text-centered">Edit Purchasing</h3>
                <form method="POST" action="/devices/{{ $purchasing->device->device_id }}/purchasing">
                    @method('PUT')
                    @csrf

                    <div class="field">
                        <label for="price" class="label">price</label>
                        <div class="control">
                            <input class="input" type="text" id="price" name="price"
                                value="{{$purchasing->price}}" required />
                        </div>
                        @error('price')
                            <p class="help is-danger">{{ $message }}</p>
                        @enderror
                    </div>

                    <div class="field">
                        <label for="timestamp_warranty_end" class="label">timestamp_warranty_end</label>
                        <div class="control">
                            <input class="input" type="text" id="timestamp_warranty_end" name="timestamp_warranty_end"
                                value="{{$purchasing->timestamp_warranty_end}}" required />
                        </div>
                        @error('timestamp_warranty_end')
                            <p class="help is-danger">{{ $message }}</p>
                        @enderror
                    </div>

                    <div class="field">
                        <label for="timestamp_purchase" class="label">timestamp_purchase</label>
                        <div class="control">
                            <input class="input" type="text" id="timestamp_purchase" name="timestamp_purchase"
                                value="{{$purchasing->timestamp_purchase}}" required />
                        </div>
                        @error('timestamp_purchase')
                            <p class="help is-danger">{{ $message }}</p>
                        @enderror
                    </div>

                    <div class="field">
                        <label for="cost_centre" class="label">cost_centre</label>
                        <div class="control">
                            <input class="input" type="text" id="cost_centre" name="cost_centre"
                                value="{{$purchasing->cost_centre}}" required />
                        </div>
                        @error('cost_centre')
                            <p class="help is-danger">{{ $message }}</p>
                        @enderror
                    </div>

                    <div class="field">
                        <label for="seller" class="label">seller</label>
                        <div class="control">
                            <input class="input" type="text" id="seller" name="seller"
                                value="{{$purchasing->seller}}" required />
                        </div>
                        @error('seller')
                            <p class="help is-danger">{{ $message }}</p>
                        @enderror
                    </div>

                    <div class="field is-grouped is-grouped-centered">
                        <div class="control">
                            <button class="button is-success" type="submit">Submit</button>
                        </div>
                        {{-- TODO: make a link to go back to device --}}
                        {{-- <div class="control">
                            <a class="button is-success is-light" href="/devices/{{ $device->device_id }}">Cancel</a>
                        </div> --}}
                    </div>

                </form>

            </div>
        </div>
    </div>
@endsection