<script lang="ts">
  import { Icon, Check, XMark } from 'svelte-hero-icons';

  export let data: any;
  export let type: 'string' | 'date' | 'boolean' = 'string';
  export let isLink: boolean = false;
  export let linkTarget: string = "";
</script>

<td>
  {#if type === 'date'}
    {#if data !== null && data !== undefined}
      {new Date(data).toLocaleDateString()}
    {:else}
      <!-- date undefined -->
    {/if}
  {:else if type === 'boolean'}
    {#if data}
      <Icon src={Check} mini class="w-6 h-6" />
    {:else}
      <Icon src={XMark} mini class="w-6 h-6" />
    {/if}
  {:else}
    {#if isLink}
      <a href={linkTarget}>{data}</a>
    {:else}
      {data}
    {/if}
  {/if}
</td>
