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