@extends('Template::layouts.master')

@section('content')
    <div class="dashboard-body">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col-xl-12 col-xxl-12">
                    <div class="card custom--card">
                        <div class="card-body">
                            <form action="{{ route('user.auction.update', $domain->id) }}" method="POST">
                                @csrf
                                <div class="row gy-3">
                                    <div class="col-sm-12 form-group">
                                        <label class="form--label">@lang('Domain name')</label>
                                        <input type="text" name="name" autocomplete="off" class="form--control"
                                            placeholder="@lang('e.g. dummydomain.com')" value="{{ $domain->name }}" required>
                                    </div>
                                    <div class="col-sm-6 form-group">
                                        <label class="form--label">@lang('Domain Category')</label>
                                        <select class="form-select form--select select2" name="category_id" required>
                                            <option value="" selected disabled>@lang('Select One')</option>
                                            @foreach ($categories as $item)
                                                <option value="{{ __($item->id) }}"
                                                    {{ $domain->category_id == $item->id ? 'selected' : '' }}>
                                                    {{ __($item->name) }}</option>
                                            @endforeach
                                            <option value="0" {{ $domain->category_id == 0 ? 'selected' : '' }}>
                                                @lang('Other')
                                            </option>
                                        </select>
                                    </div>
                                    <div class="col-sm-6 form-group">
                                        <label class="form--label">@lang('Domain Price')</label>
                                        <div class="input-group input--group">
                                            <input type="number" step="any" name="price" autocomplete="off"
                                                class="form-control form--control" value="{{ $domain->price }}" required>
                                            <span class="input-group-text">{{ __(gs('cur_text')) }}</span>
                                        </div>
                                    </div>
                                    <div class="col-sm-6 form-group">
                                        <label class="form--label">@lang('When did you register the domain?')</label>
                                        <input type="text" name="register_date"
                                            class="datepicker-here form-control form--control" data-language='en'
                                            data-date-format="yyyy-mm-dd" data-position='top left'
                                            placeholder="@lang('Select date')" value="{{ $domain->register_date }}" required>
                                    </div>
                                    <div class="col-sm-6 form-group">
                                        <label class="form--label">@lang('Auction End Time')</label>
                                        <input type="text" name="end_time" id='dateAndTimePicker'
                                            class="form-control form--control" data-language='en'
                                            data-date-format="yyyy-mm-dd" data-position='top left'
                                            placeholder="@lang('Select date')" value="{{ $domain->end_time }}" required>
                                    </div>
                                    <div class="col-sm-6 form-group">
                                        <label class="form--label">@lang('Your location')</label>
                                        <select class="form-select form--select select2" name="location" required>
                                            <option value="" selected disabled>@lang('Select One')</option>
                                            @foreach ($countries as $item)
                                                <option value="{{ __($item->country) }}"
                                                    {{ $item->country == $domain->location ? 'selected' : '' }}>
                                                    {{ __($item->country) }}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                    <div class="col-sm-6 form-group">
                                        <label class="form--label">@lang('Domain Traffic')</label>
                                        <input type="number" name="traffic" autocomplete="off"
                                            class="form-control form--control" value="{{ $domain->traffic ?? '' }}"
                                            required>
                                    </div>
                                    <div class="col-sm-12 form-group">
                                        <label class="form--label">@lang('About the domain')</label>
                                        <textarea rows="5" class="form-control form--control nicEdit" name="description" required>{{ $domain->description ?? '' }}</textarea>
                                        <small class="d-inline-block mt-1"><i class="las la-info-circle"></i>
                                            @lang(
                                                'Add a summary to briefly introduce your business. Be impactful. Use keywords that                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  help a buyer’s search.'
                                            )
                                        </small>
                                    </div>
                                    <div class="col-sm-12">
                                        <label
                                            class="form--label">@lang('Seller Note')&nbsp;<span>@lang('[optional]')</span></label>
                                        <textarea name="note" class="form-control form--control" placeholder="@lang('write your note....')">{{ $domain->note ?? '' }}</textarea>
                                    </div>
                                    <div class="col-sm-12">
                                        <button class="btn btn--base-two w-100">
                                            @lang('Submit')
                                        </button>
                                    </div>
                                </div>

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

@push('style-lib')
    <link rel="stylesheet" href="{{ asset('assets/admin/css/vendor/datepicker.min.css') }}">
@endpush

@push('script-lib')
    <script src="{{ asset('assets/admin/js/vendor/datepicker.min.js') }}"></script>
    <script src="{{ asset('assets/admin/js/vendor/datepicker.en.js') }}"></script>
    <script src="{{ asset('assets/global/js/nicEdit.js') }}"></script>
@endpush


@push('script')
    <script>
        "use strict";

        bkLib.onDomLoaded(function() {
            $(".nicEdit").each(function(index) {
                $(this).attr("id", "nicEditor" + index);
                new nicEditor({
                    fullPanel: true
                }).panelInstance('nicEditor' + index, {
                    hasPanel: true
                });
            });
        });
        var start = new Date(),
            prevDay,
            startHours = 9;

        start.setHours(9);
        start.setMinutes(0);

        if ([6, 0].indexOf(start.getDay()) != -1) {
            start.setHours(10);
            startHours = 10
        }
        $('#dateAndTimePicker').datepicker({
            timepicker: true,
            language: 'en',
            dateFormat: 'dd/mm/yyyy',
            startDate: start,
            minHours: startHours,
            maxHours: 18,
            onSelect: function(fd, d, picker) {
                // Do nothing if selection was cleared
                if (!d) return;

                var day = d.getDay();

                // Trigger only if date is changed
                if (prevDay != undefined && prevDay == day) return;
                prevDay = day;

                // If chosen day is Saturday or Sunday when set
                // hour value for weekends, else restore defaults
                if (day == 6 || day == 0) {
                    picker.update({
                        minHours: 10,
                        maxHours: 16
                    })
                } else {
                    picker.update({
                        minHours: 9,
                        maxHours: 18
                    })
                }
            }
        })

        (function($) {
            $(document).on('mouseover ', '.nicEdit-main,.nicEdit-panelContain', function() {
                $('.nicEdit-main').focus();
            });
        })(jQuery);
    </script>
@endpush
