<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">
                    <p>Plese enter the new order number.</p>
                </div>
            </div>
            <div class="row">
                <div class="col">
                    <validation-wrapper-component class="m-b-15" :validator="$v.parameters.reference_id">
                        <label class="text-primary">Order Number</label>
                        <input class="form-control" v-model="parameters.reference_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="submit(route('api.order.reference.update', data.id), 'post', section, true, true)">Confirm</div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    import modalFormHandler from '../../../general/mixins/modalFormHandler';
    import { required, minLength } from "vuelidate/lib/validators";

    export default {
        data() {
            return {
                parameters: {
                    id: this.data.id, 
                    reference_id: '', 
                }
            };
        },
        validations: {
            parameters: {
                reference_id: { 
                    required,
                    minLength: minLength(8)
                },
            }
        },
        methods: {
            successHandler(response) {
                window.location.replace(this.route('order.show', response.payload.data.reference));
            }
        },
        mixins: [modalFormHandler]
    }

</script>