<script setup>
const { dealer } = useStore();
const { $buildFileUrl, $copyToClipboard, $getEditRights } = useNuxtApp();

const props = defineProps({
  className: String,
  image: Object,
  editImage: Function,
  downloadImage: Function,
  openDeleteImageConfirm: Function
})

const url = $buildFileUrl(props.image.file__file);
</script>
<template>
  <div :class="['buttons is-gap-0.5', className]">
    <button
      class="button is-small is-white"
      @click="$copyToClipboard(url)"
      title="Sao chép link"
    >
      <span class="icon">
        <SvgIcon v-bind="{ name: 'copy.svg', type: 'primary' }" />
      </span>
    </button>
    <button
      v-if="!dealer && $getEditRights()"
      class="button is-small is-white"
      @click="editImage(image)"
      title="Sửa"
    >
      <span class="icon">
        <SvgIcon v-bind="{ name: 'edit.svg', type: 'primary' }" />
      </span>
    </button>
    <button
      class="button is-small is-white"
      @click.prevent="downloadImage(image)"
      title="Tải xuống"
    >
      <span class="icon">
        <SvgIcon v-bind="{ name: 'download.svg', type: 'primary' }" />
      </span>
    </button>
    <button
      v-if="!dealer && $getEditRights()"
      class="button is-small is-white"
      @click="openDeleteImageConfirm(image)"
      title="Xóa"
    >
      <span class="icon">
        <SvgIcon v-bind="{ name: 'bin.svg', type: 'primary' }" />
      </span>
    </button>
  </div>
</template>
<style>

</style>