<script setup>
import { defineProps } from 'vue'
const props = defineProps(['order_id'])
import { authenticatedRequest } from "@/components/session/authenticatedRequest.vue";
import LoadButtonWhileAwait from "@/components/request/LoadButtonWhileAwait.vue";
import { handleEconomicError } from "@/components/request/HandleEconomicError.vue";
import { ref } from "vue";

const exportOrderToDraft = async () => {
  await authenticatedRequest('/economic/invoice/draft/export','post',{
    order_id: props.order_id
  }) .then((response) => {
    // Reload the page
    location.reload();
  }).catch((error) => {
    handleEconomicError(error);
  });
};
</script>

<template>
  <LoadButtonWhileAwait class="is-dark" :loadFunction="exportOrderToDraft" icon="fas fa-paper-plane"> Gennemfør </LoadButtonWhileAwait>
</template>

<style scoped>

</style>