<script lang="ts">
  import type { IconName } from "../external/icons";
  import type { LogResult } from "../models/log";
  import type { ModalData } from "../stores/modal";
  import ChildEntry from "./ChildEntry.svelte";
  import ItemLink from "./ItemLink.svelte";
  import Option from "./Option.svelte";
  import OptionRow from "./OptionRow.svelte";

  export let log: LogResult = null;

  let taskIconName: IconName = "question";
  let itemIconName: IconName = "question";
  let mdLogEdit: ModalData;
  let mdLogDelete: ModalData;

  $: taskIconName = log.task.icon as IconName;
  $: itemIconName = log.item.icon as IconName;
  $: mdLogEdit = {name: "log.edit", log};
  $: mdLogDelete = {name: "log.delete", log};
</script>

<ChildEntry entry={log}>
  <ItemLink amount={log.itemAmount} item={log.item} />
  {#if log.secondaryItem != null}
    <ItemLink noPadding amount={log.secondaryItemAmount} item={log.secondaryItem} />
  {/if}
  <OptionRow>
    <Option open={mdLogEdit}>Edit Log</Option>
    <Option open={mdLogDelete}>Delete Log</Option>
  </OptionRow>
</ChildEntry>
