<template>
    <div class="row parentContainer" @keyup.enter="search">
        <div class="col">
            <div class="row">
                <div class="col p-r-0">
                    <div class="row">
                        <!-- <div class="col">
                            <div class="form-group no-margin form-group-default b-rad-none">
                                <label class="text-primary">Customer Marking</label>
                                <input type="text" class="form-control" v-model="parameters.customerMarking"
                                    @click="clearAll('customerMarking')" />
                            </div>
                        </div>
                        <div class="col">
                            <div class="form-group no-margin form-group-default b-rad-none">
                                <label class="text-primary">Email</label>
                                <input type="text" class="form-control" v-model="parameters.email"
                                    @click="clearAll('email')" />
                            </div>
                        </div> -->
                        <div class="col">
                            <div class="form-group no-margin form-group-default b-rad-none">
                                <label class="text-primary">Order No</label>
                                <input type="text" class="form-control" v-model="parameters.orderNo"
                                    @click="clearAll('orderNo')" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-auto p-l-0">
                    <div class="btn btn-primary b-rad-none" @click="search">
                        <i class="fa fa-search lh-40"></i>
                    </div>
                    <div class="btn btn-default b-rad-none lh-40" @click="reset">
                        Reset
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: {
        section: {
            default: 'addressList'
        },
    },
    data() {
        return {
            isLoading: false,
            parameters: {
                customerMarking: null,
                email: null,
                orderNo: null,
            }
        }
    },
    methods: {
        clearAll(input) {
            var parameters = this.parameters;
            $.each(this.parameters, function (key, value) {
                if (key != input) {
                    parameters[key] = null;
                }
            });
            this.parameters = parameters;
        },
        reset() {
            this.parameters.customerMarking = null;
            this.parameters.email = null;
            this.parameters.orderNo = null;
        },
        search() {
            if (this.parameters.orderNo) {
                window.location.href = this.route('order.show', this.parameters.orderNo);
                return;
            }
        }
    },
}
</script>