<template>
  <k-button @click="send($event)" variant="filled" icon="plane">{{
    text
  }}</k-button>
</template>

<script setup>
import { ref } from "vue";

const { pageUri } = defineProps({
  pageUri: String,
});

const text = ref("Envoyer");

const headers = {
  method: "POST",
  body: JSON.stringify({
    pageUri,
  }),
};

async function send(event) {
  event.preventDefault();
  const response = await fetch("/send-newsletter.json", headers);
  const data = await response.json();
  console.log(data);
}
</script>

<style scoped>
@media screen and (min-width: 533px) {
  button {
    margin-top: 2.15rem;
  }
}
</style>
