<template>
    <div class="row" style="width: 450px; margin: auto;" @keyup.enter="submitForm">
        <div class="col bg-white padding-40 b-rad-lg">
            <div class="row m-b-10">
                <div class="col text-center">
                    <h3>Edit Contact</h3>
                </div>
            </div>
            <div class="row m-b-15">
                <div class="col">
                    <validation-wrapper-component :validator="$v.parameters.reference">
                        <label>Reference</label>
                        <input class="form-control" name="street_one" v-model="parameters.reference">
                    </validation-wrapper-component>
                </div>
            </div>
            <div class="row m-b-15">
                <div class="col">
                    <validation-wrapper-component :validator="$v.parameters.phone">
                        <label>Phone</label>
                        <input class="form-control" name="street_one" v-model="parameters.phone">
                    </validation-wrapper-component>
                </div>
            </div>
            <div class="row m-b-15">
                <div class="col">
                    <validation-wrapper-component :validator="$v.parameters.email">
                        <label>Email</label>
                        <input class="form-control" name="street_one" v-model="parameters.email">
                    </validation-wrapper-component>
                </div>
            </div>
            <div class="row m-b-15">
                <div class="col">
                    <validation-wrapper-component :validator="$v.parameters.wechat_id">
                        <label>Wechat ID</label>
                        <input class="form-control" name="street_one" v-model="parameters.wechat_id">
                    </validation-wrapper-component>
                </div>
            </div>
            <div class="row m-t-15">
                <div class="col-auto p-r-5">
                    <div class="btn btn-lg btn-default b-rad-none" data-dismiss="modal">Cancel</div>
                </div>
                <div class="col p-l-5">
                    <div class="btn btn-primary w-100 btn-lg" @click="submitForm">Confirm</div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    import modalFormHandler from '../../../general/mixins/modalFormHandler';
    import { required } from "vuelidate/lib/validators";

    export default {
        props: {
            company_module_id: {
                type: Number,
                required: true
            },
        },
        data() {
            return {
                parameters: {
                    reference: this.data.reference,
                    phone: this.data.phone,
                    email: this.data.email,
                    wechat_id: this.data.wechat_id,
                }
            };
        },
        methods: {
            submitForm() {
                this.submit(this.route('api.contact.update', this.data.id), 'put', this.section, true, true)
            },
        },
        validations: {
            parameters: {
                reference: {  },
                phone: {  },
                email: {  },
                wechat_id: {  },
            }
        },
        mixins: [modalFormHandler]
    }

</script>