<script>
import { exitSession } from "@/components/session/Session.vue";
import Swal from "sweetalert2";

//

export const showAuthSignOutForm = async () => {
  await Swal.fire({
    title: 'Vil du logge ud?',
    showConfirmButton: true,
    confirmButtonText: 'Log ud',
    showCancelButton: true,
    cancelButtonText: 'Annuller',
    focusCancel: true,
    confirmButtonColor: '#d33',
    preConfirm: () => {
      exitSession().then(() => {
        Swal.fire('Signed out successfully');
        // Send user to login page
        window.location.href = '/login';
      }).catch((e) => {
        Swal.fire('Error', e.response.data.error ?? e.response, 'error');
      });
    }
  });
};

</script>