<.header>
  uploaded by <%= @image.user.email %>
  <:actions>
    <%= if(@current_user && @image.user.email == @current_user.email) do %>
      <.link patch={~p"/images/#{@image.file}/show/edit"} phx-click={JS.push_focus()}>
        <.button>Edit image</.button>
      </.link>
    <% end %>
  </:actions>
</.header>

<a target="_blank" href={"https://s3.zoeys.computer/imgs/uploads/#{@image.file}.png"}>
  <img src={"https://s3.zoeys.computer/imgs/uploads/#{@image.file}.png"} />
</a>

<%= if(@current_user) do %>
  <.back navigate={~p"/images"}>Back to images</.back>
<% end %>

<.modal
  :if={@live_action == :edit}
  id="image-modal"
  show
  on_cancel={JS.patch(~p"/images/#{@image.file}")}
>
  <.live_component
    module={ZoeyscomputerWeb.ImageLive.FormComponent}
    id={@image.id}
    title={@page_title}
    action={@live_action}
    image={@image}
    patch={~p"/images/#{@image.file}"}
  />
</.modal>
