1<template>
2  <b-link
3    class="btn btn-primary d-block align-self-center"
4    :download="download"
5    :href="href"
6  >
7    {{ $t('global.action.export') }}
8  </b-link>
9</template>
10
11<script>
12export default {
13  props: {
14    data: {
15      type: Array,
16      default: () => []
17    },
18    fileName: {
19      type: String,
20      default: 'data'
21    }
22  },
23  computed: {
24    dataForExport() {
25      return JSON.stringify(this.data);
26    },
27    download() {
28      return `${this.fileName}.json`;
29    },
30    href() {
31      return `data:text/json;charset=utf-8,${this.dataForExport}`;
32    }
33  }
34};
35</script>
36