<script lang='ts' setup>
import IcRoundDownload from "~icons/ic/round-download";
import { client, safeClient } from "@/api";

const props = defineProps<{
  fileIds: string[];
}>();

const { data } = safeClient(client.api.file_storage.access_urls.post({ fileIds: props.fileIds }));

function handleDownload(item) {
  window.open(item.url, "_blank");
}
</script>

<template>
  <div class="flex flex-col gap-2">
    <div v-for="item in data" :key="item.id" class="p-3 bg-faint rounded-md flex items-center justify-between" @click="handleDownload(item)">
      <div class="text-success font-medium">
        {{ item.fileName }}
      </div>

      <div><IcRoundDownload /></div>
    </div>
  </div>
</template>

<style lang='css' scoped></style>
