<template>
    <div class="row" @keyup.enter="submitForm">
        <div class="col">
            <div class="row m-b-20 text-info">
                <div class="col">
                    <h3 class="text-left">Create Shipping Packing List</h3>
                </div>
            </div>
            <error-message-component class="m-b-20" :error="error"></error-message-component>
            <div class="row">
                <div class="col">
                    <package-form-component :section="section" :packages="parameters.packages"></package-form-component>
                    <div class="row m-t-15 align-items-center justify-content-center">
                        <div class="col">
                            <div class="btn btn-block btn-lg btn-primary b-rad-none no-border" @click="submitForm">Submit</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    import componentHandler from '../../../general/mixins/componentHandler';
    import modalFormHandler from '../../../general/mixins/modalFormHandler';

    export default {
        props: {
            id: {
                type: Number,
                required: true
            },
            section:{
                type: String,
                required: true
            }
        },
        data() {
            return {
                error: '',
                parameters: {
                    order_id: this.id,
                    packages: []
                }
            };
        },
        watch: {
            'id': function () {
                this.parameters.order_id = this.id;
            }
        },
        methods: {
            submitForm(){
                this.submit(this.route('api.order.create.shipping.packing_list'), 'post', this.section, true, true)
            }
        },
        mixins: [componentHandler, modalFormHandler]
    }

</script>