<template>
    <div class="row justify-content-center" @keyup.enter="submitForm">
        <div class="col col-md-8">
            <div class="row m-b-20 text-info">
                <div class="col">
                    <h3 class="text-left">Create Load Container</h3>
                </div>
            </div>
            <error-message-component class="m-b-20" :error="error"></error-message-component>
            <div class="row">
                <div class="col">
                    <div class="row m-b-10">
                        <div class="col">
                            <div class="row m-b-0 text-primary">
                                <div class="col">
                                    <label class="text-primary fs-11 all-caps">Select the warehouse</label>
                                </div>
                            </div>
                            <div class="row text-center justify-content-center">
                                <div class="col p-r-5">
                                    <div class="b-a b-thick p-t-15 p-b-15 p-l-35 p-r-35 pointer" :class="{ 'b-primary': parameters.company_module_id === 3, 'b-grey': parameters.company_module_id !== 3 }"  @click="parameters.company_module_id = 3">
                                        <div class="row m-b-15 justify-content-center">
                                            <div class="col-8">
                                                <img src="/images/guangzhou-map.png" class="w-100">
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col">
                                                <h5 class="no-margin" :class="{ 'text-primary': parameters.company_module_id === 3, 'semi-bold': parameters.company_module_id === 3 }">Guangzhou</h5>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col p-l-5">
                                    <div class="b-a b-thick p-t-15 p-b-15 p-l-35 p-r-35 pointer" :class="{ 'b-primary': parameters.company_module_id === 4, 'b-grey': parameters.company_module_id !== 4 }"  @click="parameters.company_module_id = 4">
                                        <div class="row m-b-15 justify-content-center">
                                            <div class="col-8">
                                                <img src="/images/yiwu-map.png" class="w-100">
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col">
                                                <h5 class="no-margin" :class="{ 'text-primary': parameters.company_module_id === 4, 'semi-bold': parameters.company_module_id === 4}">Yiwu</h5>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <validation-wrapper-component class="m-b-15" :validator="$v.parameters.container_reference">
                        <label class="text-primary">Container Reference</label>
                        <input type="text" class="form-control fs-12" v-model.trim="parameters.container_reference">
                    </validation-wrapper-component>

                     <validation-wrapper-component class="m-b-15" :validator="$v.parameters.container_number">
                        <label class="text-primary">Container Number</label>
                        <input type="text" class="form-control fs-12" v-model.trim="parameters.container_number">
                    </validation-wrapper-component>

                     <validation-wrapper-component class="m-b-15" :validator="$v.parameters.seal_reference">
                        <label class="text-primary">Seal Reference</label>
                        <input type="text" class="form-control fs-12" v-model.trim="parameters.seal_reference">
                    </validation-wrapper-component>

                    <div class="row">
                        <div class="col">
                            <validation-wrapper-component class="m-b-10" :validator="$v.parameters.etd">
                                <label class="text-primary">ETD</label>
                                <date-picker-component :parameters="parameters" :value="'etd'"></date-picker-component>
                            </validation-wrapper-component>
                        </div>

                        <div class="col">
                            <validation-wrapper-component class="m-b-10" :validator="$v.parameters.eta">
                                <label class="text-primary">ETA</label>
                                <date-picker-component :parameters="parameters" :value="'eta'"></date-picker-component>
                            </validation-wrapper-component>
                        </div>
                    </div>

                    <div class="row m-t-15 align-items-center justify-content-center">
                        <div class="col">
                            <div class="btn btn-block btn-lg btn-default b-rad-none" @click="$store.dispatch('toggleSection', {name: 'createContainerFormSection', status: false})">Cancel</div>
                        </div>
                        <div class="col">
                            <div class="btn btn-block btn-lg btn-primary b-rad-none" @click="submitForm">Submit</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    import createContainerFormValidation from '../../../general/mixins/containers/validation/createContainerFormValidation';
    import componentHandler from '../../../general/mixins/componentHandler';
    import modalFormHandler from '../../../general/mixins/modalFormHandler';

    export default {
        data() {
            return {
                error: '',
                parameters: {
                    container_reference: this.container_reference,
                    container_number: this.container_number,
                    seal_reference: this.seal_reference,
                    container_type: 1,
                    company_module_id: this.company_module_id,
                    etd: this.etd, 
                    eta: this.eta, 
                }
            };
        },
        methods: {
            submitForm(){
                this.submit(this.route('api.packing_list.container.create.load'), 'post', this.section, true, true)
            },
        },
        mixins: [createContainerFormValidation, componentHandler, modalFormHandler]
    }

</script>