<template>
    <div class="row text-center">
        <div class="col">
            <loading-component style="height: 300px; top: 0;" key="1" color="success" v-show="isLoading" ></loading-component>
            <div class="row justify-content-center" v-show="!isLoading">
                <div class="col">
                    <div class="row m-b-20">
                        <div class="col">
                            <h3 class="all-caps">Are you Sure?</h3>
                            <div class="fs-11">Are you sure you want to activate this Supplier?</div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col p-r-5">
                            <div class="btn btn-sm btn-success btn-block b-rad-none" data-dismiss="modal">Cancel</div>
                        </div>
                        <div class="col p-l-5">
                            <div class="btn btn-sm btn-danger btn-block b-rad-none" @click="submitForm()">Confirm</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { useComponentHandler } from '@/composables/useComponentHandler';
import { useFormHandler } from '@/composables/useFormHandler';
import route from '@/general/functions/router';

interface Prop {
    data: any;
    section?: string;
}

const props = withDefaults(defineProps<Prop>(), {
    section: 'suppliersSection'
});

const { item } = useComponentHandler(props);
const { parameters, submit, isLoading, closeModal } = useFormHandler({
    section: props.section
});

const submitForm = () => {
    parameters.value.status = 1;
    submit(route('api.company.status.update', item.value.id), 'put', props.section, true, false, parameters.value);
};
</script>
