<div class="flex flex-col py-4 px-6">
  <header class="mb-4">
    <nav>
      <ul class="flex flex-row gap-x-4">
        <li>
          <.link class={[@kind == :blog && "underline"]} patch={~p"/admin/writing"}>
            writing
          </.link>
        </li>
        <li>
          <.link class={[@kind == :status && "underline"]} patch={~p"/admin/microblog"}>
            microblog
          </.link>
        </li>
      </ul>
    </nav>
  </header>

  <main class="flex flex-col">
    <.link class="mb-4" navigate={~p"/admin/posts/new?kind=#{@kind}"}>new {@kind}</.link>
    <%= case @kind do %>
      <% :blog -> %>
        <.table id="blog-posts" stream={@streams.posts}>
          <:col :let={blog} label="title">{blog.title}</:col>
          <:col :let={blog} label="status">
            <.post_status post={blog} />
          </:col>
          <:col :let={blog}>
            <.post_actions post={blog} />
          </:col>
        </.table>
      <% :status -> %>
        <.table id="status-posts" stream={@streams.posts}>
          <:col :let={status} label="content">
            {status.body}
          </:col>
          <:col :let={status} label="status">
            <.post_status post={status} />
          </:col>
          <:col :let={status}>
            <.post_actions post={status} />
          </:col>
        </.table>
    <% end %>
    <footer class="flex flex-row justify-between mt-2">
      <%= if @meta.has_previous_page? do %>
        <.link patch={build_path(@kind, Flop.to_previous_cursor(@meta))}>prev</.link>
      <% else %>
        <div />
      <% end %>

      <%= if @meta.has_next_page? do %>
        <.link patch={build_path(@kind, Flop.to_next_cursor(@meta))}>next</.link>
      <% else %>
        <div />
      <% end %>
    </footer>
  </main>
</div>