defmodule OutlookWeb.ArticleLive.NewComponents do
  use Phoenix.Component
  use OutlookWeb, :html

  alias Outlook.{InternalTree,HtmlPreparations}

  def import_raw_html(assigns) do
    ~H"""
    <div>
      <div>Import article</div>

      <.simple_form
        :let={f}
        for={@changeset}
        id="raw-html-input-form"
        phx-change="validate_raw_html_input"
        phx-submit="convert_raw_html_input"
      >
        <.input field={{f, :content}} type="textarea" label="text to import" phx-debounce="500"
          class="h-96" />
        <:actions>
          <.button phx-disable-with="Importing...">HTML importieren</.button>
        </:actions>
      </.simple_form>
    </div>
    """
  end

  def review_raw_internaltree(assigns) do
    ~H"""
      <div>Review Raw InternalTree</div>
      <div class="flex">
        <div id="html-preview" class="article">
          <%= InternalTree.render_html_preview(@raw_internal_tree) |> raw %>
        </div>
        <div id="html-tree">
          <.render_tree tree={@raw_internal_tree} ></.render_tree>
        </div>
      </div>
      <.button phx-click="approve_raw_internaltree">Continue</.button>
    """
  end

  def review_translation_units(assigns) do
    ~H"""
      <div>Review Translation Units</div>
      <.button phx-click="approve_translation_units">Continue</.button>
    """
  end

  def final_form(assigns) do
    ~H"""
      <div>Final Form</div>
      <!-- this should eventually become the first stage because url will be needed for processing of images -->
      <.button phx-click="save">Save</.button>
    """
  end
end
