<template>
    <div class="row parentContainer" @keyup.enter="search">
        <div class="col">
            <div class="row m-b-15">
                <div class="col">
                    <div class="row">
                        <div class="col p-r-0">
                            <div class="form-group no-margin form-group-default b-rad-none">
                                <label class="font-heading all-caps fs-8 muted">Marking</label>
                                <input type="text" class="form-control" v-model="marking" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-auto p-l-0 p-r-0">
                    <div class="btn btn-primary b-rad-none" @click="search">
                        <i class="fa fa-search lh-40"></i>
                    </div>
                </div>
                <div class="col-auto p-l-0">
                    <div class="btn btn-secondary b-rad-none" @click="reset">
                        <i class="fa fa-remove lh-40"></i>
                    </div>
                </div>
            </div>
            <list-component :key="currentKey" section="seasonalSegment" :endpoint="route('api.company.list')" :options="options">
                <template slot="list" slot-scope="{data}">
                    <seasonal-segment-component :data="data"></seasonal-segment-component>
                </template>
            </list-component>
        </div>
    </div>
</template>

<script>
    import componentHandler from '../../../general/mixins/componentHandler';
    export default {
        data(){
            return {
                marking: '',
                currentKey: 1,
                options: {'per_page': 5, 'where_has_seasonal_segment': true},
            }
        },
        methods: {
            search() {
                this.options['reference_like'] = this.marking;
                this.currentKey+=1;
            },
            reset() {
                this.marking = '';
                delete(this.options['reference_like']);
                this.currentKey+=1;
            },
        },  
        mixins: [componentHandler]
    }
</script>