<template>
    <div class="row m-b-15 parentContainer">
        <div class="col">
            <div class="row">
                <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="text-primary">Email Like</label>
                                        <input type="text" class="form-control" v-model="email" @keyup.enter="search"/>
                                    </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 class="col"></div>
                    </div>
                </div>
            </div>
            <list-component :key="currentKey" :section="section" :endpoint="route('api.account.user.list')" :options="options">
                <template slot="list" slot-scope="{data}">
                    <user-component :data="data"></user-component>
                </template>
            </list-component>
        </div>
    </div>
</template>

<script>
    import componentHandler from '../../../general/mixins/componentHandler';
    export default {
        props: {
            section: {
                type: String,
                required: true
            }
        },
        data() {
            return {
                expanded: false,
                currentKey: 1,
                email: '',
                options: {
                    'type_in': this.$store.getters.isSuperAdmin ? [1, 2] : [2],
                }
            }
        },
        methods: {
            search() {
                this.options['email_like'] = this.email;
                this.currentKey+=1;
            },
            reset() {
                this.email = '';
                delete(this.options['email_like']);
                this.currentKey+=1;
            },
        },
        mixins: [componentHandler]
    }
</script>