<template>
    <div class="row" @keyup.enter="submitForm">
        <div class="col">
            <loading-component style="height: 200px; top: 0;" key="1" color="success" v-show="$store.getters.isLoading(section)"></loading-component>
            <div class="row" v-show="!$store.getters.isLoading(section)">
                <div class="col">
                    <div class="row">
                        <div class="col">
                            <file-input-component :validator="$v.parameters.files" v-model="parameters.files">
                                <template slot="label">
                                    <div class="font-heading fs-11 text-primary all-caps">Purchase Order PDF</div>
                                </template>
                            </file-input-component>
                        </div>
                    </div>
                    <div class="row m-t-20">
                        <div class="col">
                            <div class="row">
                                <div class="col">
                                    <button type="button" class="btn btn-sm btn-block p-t-10 p-b-10 p-r-35 p-l-35 btn-success b-rad-none" @click="submitForm">Upload</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import { required } from "vuelidate/lib/validators";
    import formHandler from '../../../general/mixins/formHandler';
    export default {
        data(){
            return {
                parameters: {
                    files: []
                }
            }
        },
        validations: {
            parameters: {
                files: {
                    required
                }
            }
        },
        methods: {
            submitForm(){
                this.submit(this.route('api.booking.po.pdf', this.data.id), 'post', this.section, true, false)
            }
        },
        mixins: [formHandler]
    }
</script>