<script lang="ts">
  import type Project from "../models/project";
  import type { TaskResult } from "../models/task";
  import TaskEntry from "./TaskEntry.svelte";
  import projectStore from "../stores/project";

  export let project: Project;
  export let tasks: TaskResult[];
  export let showAllOptions: boolean;
  export let header: string;
</script>

{#if tasks.length > 0}
  <h3>{header}</h3>
  {#each tasks as task (task.id)}
    <TaskEntry 
      showAllOptions={showAllOptions} 
      task={task} project={project} 
      actualProject={$projectStore.projects.find(p => p.id === task.projectId)} 
    />
  {/each}
{/if}

<style>
  h3:empty {
    display: none;
  }

  h3 {
    padding: 0;
    margin: 0;
    margin-top: 0.5em;
    font-weight: 100;
  }
</style>