@extends('backend.dashboard')

@section('content')

<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">

                <div class="card card-primary">

                    {{-- Header --}}
                    <div class="card-header position-relative">
                        <div class="w-100 text-center p-4">
                            <h3 style="display:inline-block;font-weight:700;font-size:30px;
                                padding-bottom:6px;border-bottom:3px solid #a74a28;margin:0;">
                                Update Bestsellers & Quotation
                            </h3>
                        </div>

                        <a href="{{ route('bestsellers.index') }}"
                           class="btn btn-primary position-absolute"
                           style="right:15px; top:50%; transform:translateY(-50%);">
                            <i class="fas fa-arrow-left"></i> Back
                        </a>
                    </div>

                    {{-- SINGLE FORM --}}
                    <form action="{{ route('bestsellers.update', $bestsellers->id) }}"
                          method="POST"
                          enctype="multipart/form-data">

                        @csrf
                        @method('PUT')

                        <div class="card-body">

                            {{-- ================= BESTSELLER ================= --}}

                            <div class="row">

                                <div class="col-md-6">
                                    <label><h5>Image</h5></label>
                                    <input type="file" name="image" class="form-control" accept="image/*">
                                    @error('image') <span class="text-danger">{{ $message }}</span> @enderror

                                    @if(!empty($bestsellers->image))
                                        <img src="{{ asset($bestsellers->image) }}"
                                             width="120" class="mt-2">
                                    @endif
                                </div>

                                <div class="col-md-6">
                                    <label><h5>Alt Text</h5></label>
                                    <input type="text" name="alt_text"
                                           value="{{ old('alt_text', $bestsellers->alt_text ?? '') }}"
                                           class="form-control">
                                    @error('alt_text') <span class="text-danger">{{ $message }}</span> @enderror
                                </div>

                                {{-- <div class="col-md-4">
                                    <label><h5>Price</h5></label>
                                    <input type="number" step="0.01"
                                           name="price"
                                           value="{{ old('price', $bestsellers->price ?? '') }}"
                                           class="form-control">
                                    @error('price') <span class="text-danger">{{ $message }}</span> @enderror
                                </div> --}}

                            </div>

                            <div class="row mt-3">

                                <div class="col-md-6">
                                    <label><h5>Title</h5></label>
                                    <input type="text" name="title"
                                           value="{{ old('title', $bestsellers->title ?? '') }}"
                                           class="form-control">
                                    @error('title') <span class="text-danger">{{ $message }}</span> @enderror
                                </div>

                                <div class="col-md-6">
                                    <label><h5>Author</h5></label>
                                    <input type="text" name="author"
                                           value="{{ old('author', $bestsellers->author ?? '') }}"
                                           class="form-control">
                                    @error('author') <span class="text-danger">{{ $message }}</span> @enderror
                                </div>

                            </div>

                            <div class="row mt-3">
                                <div class="col-md-12">
                                    <label><h5>Book Link</h5></label>
                                    <input type="text" name="amazon_link"
                                           value="{{ old('amazon_link', $bestsellers->amazon_link ?? '') }}"
                                           class="form-control">
                                    @error('amazon_link') <span class="text-danger">{{ $message }}</span> @enderror
                                </div>
                            </div>

                            <div class="row mt-3">
                                <div class="col-md-12">
                                    <label><h5>Description</h5></label>
                                    <textarea name="description"
                                              class="form-control"
                                              rows="4">{{ old('description', $bestsellers->description ?? '') }}</textarea>
                                    @error('description') <span class="text-danger">{{ $message }}</span> @enderror
                                </div>
                            </div>

                            <hr class="my-4">
                         <div class="w-100 text-center p-3">
                            <h5 style="
                                display: inline-block;
                                font-weight: 700;
                                font-size: 30px;
                                padding-bottom: 6px;
                                border-bottom: 3px solid #007bff;

                            ">
                                Quotation Details
                            </h5>
                        </div>

                            {{-- ================= QUOTATION ================= --}}


                            <div class="row">

                                <div class="col-md-6">
                                    <label><b><h5>Quotation Title</h5></b></label>
                                    <input type="text" name="quta_title"
                                           value="{{ old('quta_title', $bestsellers->quta_title ?? '') }}"
                                           class="form-control">
                                    @error('quta_title') <span class="text-danger">{{ $message }}</span> @enderror
                                </div>

                                <div class="col-md-6">
                                    <label><b><h5>Quotation Author</h5></b></label>
                                    <input type="text" name="quta_author"
                                           value="{{ old('quta_author', $bestsellers->quta_author ?? '') }}"
                                           class="form-control">
                                    @error('quta_author') <span class="text-danger">{{ $message }}</span> @enderror
                                </div>

                            </div>

                            <div class="row mt-3">
                                <div class="col-md-12">
                                    <label><h5>Quotation Description</h5></label>

                                    <textarea name="quta_description"
                                              class="form-control"
                                              rows="4">{{ old('quta_description', $bestsellers->quta_description ?? '') }}</textarea>

                                    @error('quta_description')
                                        <span class="text-danger">{{ $message }}</span>
                                    @enderror
                                </div>
                            </div>

                        </div>

                        {{-- Footer --}}
                       <div class="card-footer d-flex justify-content-end">
                            <button type="submit" class="btn btn-primary">
                               <i class="fas fa-edit"></i> Update
                            </button>
                        </div>

                    </form>

                </div>

            </div>
        </div>
    </div>
</section>

@endsection
