<script>
  import { _ } from "svelte-i18n";
  export let donations;
</script>

{#if !donations || donations.length == 0}
  {$_("donor-has-no-associated-donations")}
{:else}
  {#each donations as donation}
    {#if donation.responseType === "DISTANCEDONATION"}
      <a
        href="../donations/{donation.id}"
        class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-blue-600 text-white mr-1"
        >{donation.runner.firstname}
        {donation.runner.middlename || ""}
        {donation.runner.lastname}</a
      >
    {:else}
      <a
        href="../donations/{donation.id}"
        class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full border border-current bg-green-700 text-white mr-1"
        >{$_("fixed-donation")}:
        {(donation.amount / 100)
          .toFixed(2)
          .toLocaleString("de-DE", { valute: "EUR" })}€</a
      >
    {/if}
  {/each}
{/if}
