2026-02-18 21:23:15 +00:00
|
|
|
defmodule BerrypodWeb.Admin.ProductShow do
|
|
|
|
|
use BerrypodWeb, :live_view
|
2026-02-16 08:48:51 +00:00
|
|
|
|
2026-02-18 21:23:15 +00:00
|
|
|
alias Berrypod.Products
|
|
|
|
|
alias Berrypod.Products.{Product, ProductImage, ProductVariant}
|
|
|
|
|
alias Berrypod.Cart
|
2026-02-16 08:48:51 +00:00
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
|
def mount(%{"id" => id}, _session, socket) do
|
|
|
|
|
case Products.get_product(id, preload: [:provider_connection, images: :image, variants: []]) do
|
|
|
|
|
nil ->
|
|
|
|
|
socket =
|
|
|
|
|
socket
|
|
|
|
|
|> put_flash(:error, "Product not found")
|
|
|
|
|
|> push_navigate(to: ~p"/admin/products")
|
|
|
|
|
|
|
|
|
|
{:ok, socket}
|
|
|
|
|
|
|
|
|
|
product ->
|
|
|
|
|
form =
|
|
|
|
|
product
|
|
|
|
|
|> Product.storefront_changeset(%{})
|
|
|
|
|
|> to_form(as: "product")
|
|
|
|
|
|
|
|
|
|
socket =
|
|
|
|
|
socket
|
|
|
|
|
|> assign(:page_title, product.title)
|
|
|
|
|
|> assign(:product, product)
|
|
|
|
|
|> assign(:form, form)
|
|
|
|
|
|
|
|
|
|
{:ok, socket}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
|
def handle_event("validate_storefront", %{"product" => params}, socket) do
|
|
|
|
|
form =
|
|
|
|
|
socket.assigns.product
|
|
|
|
|
|> Product.storefront_changeset(params)
|
|
|
|
|
|> Map.put(:action, :validate)
|
|
|
|
|
|> to_form(as: "product")
|
|
|
|
|
|
|
|
|
|
{:noreply, assign(socket, :form, form)}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
|
def handle_event("save_storefront", %{"product" => params}, socket) do
|
|
|
|
|
case Products.update_storefront(socket.assigns.product, params) do
|
|
|
|
|
{:ok, updated} ->
|
|
|
|
|
product = %{
|
|
|
|
|
updated
|
|
|
|
|
| provider_connection: socket.assigns.product.provider_connection,
|
|
|
|
|
images: socket.assigns.product.images,
|
|
|
|
|
variants: socket.assigns.product.variants
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
form =
|
|
|
|
|
product
|
|
|
|
|
|> Product.storefront_changeset(%{})
|
|
|
|
|
|> to_form(as: "product")
|
|
|
|
|
|
|
|
|
|
socket =
|
|
|
|
|
socket
|
|
|
|
|
|> assign(:product, product)
|
|
|
|
|
|> assign(:form, form)
|
|
|
|
|
|> put_flash(:info, "Product updated")
|
|
|
|
|
|
|
|
|
|
{:noreply, socket}
|
|
|
|
|
|
|
|
|
|
{:error, changeset} ->
|
|
|
|
|
{:noreply, assign(socket, :form, to_form(changeset, as: "product"))}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
|
def handle_event("resync", _params, socket) do
|
|
|
|
|
product = socket.assigns.product
|
|
|
|
|
|
|
|
|
|
if product.provider_connection do
|
|
|
|
|
Products.enqueue_sync(product.provider_connection)
|
|
|
|
|
|
|
|
|
|
{:noreply, put_flash(socket, :info, "Sync queued for #{product.provider_connection.name}")}
|
|
|
|
|
else
|
|
|
|
|
{:noreply, put_flash(socket, :error, "No provider connection")}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
|
def render(assigns) do
|
|
|
|
|
~H"""
|
|
|
|
|
<.header>
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
<.link navigate={~p"/admin/products"} class="admin-back-link">
|
2026-02-16 08:48:51 +00:00
|
|
|
← Products
|
|
|
|
|
</.link>
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
<div class="admin-product-header">
|
|
|
|
|
<span class="admin-product-title">{@product.title}</span>
|
2026-02-16 08:48:51 +00:00
|
|
|
<.visibility_badge visible={@product.visible} />
|
|
|
|
|
<.status_badge status={@product.status} />
|
|
|
|
|
</div>
|
|
|
|
|
<:actions>
|
|
|
|
|
<.link
|
|
|
|
|
:if={provider_edit_url(@product)}
|
|
|
|
|
href={provider_edit_url(@product)}
|
|
|
|
|
target="_blank"
|
|
|
|
|
rel="noopener"
|
2026-02-17 23:05:01 +00:00
|
|
|
class="admin-btn admin-btn-ghost admin-btn-sm"
|
2026-02-16 08:48:51 +00:00
|
|
|
>
|
|
|
|
|
Edit on {provider_label(@product)}
|
|
|
|
|
<.icon name="hero-arrow-top-right-on-square-mini" class="size-4" />
|
|
|
|
|
</.link>
|
2026-02-17 23:05:01 +00:00
|
|
|
<.link
|
|
|
|
|
navigate={~p"/products/#{@product.slug}"}
|
|
|
|
|
class="admin-btn admin-btn-ghost admin-btn-sm"
|
|
|
|
|
>
|
2026-02-16 08:48:51 +00:00
|
|
|
View on shop <.icon name="hero-arrow-top-right-on-square-mini" class="size-4" />
|
|
|
|
|
</.link>
|
|
|
|
|
</:actions>
|
|
|
|
|
</.header>
|
|
|
|
|
|
|
|
|
|
<%!-- images + details --%>
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
<div class="admin-product-grid">
|
|
|
|
|
<div>
|
|
|
|
|
<div class="admin-product-image-grid">
|
2026-02-16 08:48:51 +00:00
|
|
|
<div
|
|
|
|
|
:for={image <- sorted_images(@product)}
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
class="admin-product-image-tile"
|
2026-02-16 08:48:51 +00:00
|
|
|
>
|
|
|
|
|
<img
|
2026-02-16 17:47:41 +00:00
|
|
|
src={ProductImage.url(image, 400)}
|
2026-02-16 08:48:51 +00:00
|
|
|
alt={image.alt || @product.title}
|
|
|
|
|
loading="lazy"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
<p
|
|
|
|
|
:if={@product.images == []}
|
|
|
|
|
class="admin-help-text"
|
|
|
|
|
>
|
|
|
|
|
No images
|
|
|
|
|
</p>
|
2026-02-16 08:48:51 +00:00
|
|
|
</div>
|
|
|
|
|
|
2026-02-17 23:05:01 +00:00
|
|
|
<div class="admin-card">
|
|
|
|
|
<div class="admin-card-body">
|
|
|
|
|
<h3 class="admin-card-title">Details</h3>
|
2026-02-16 08:48:51 +00:00
|
|
|
<.list>
|
|
|
|
|
<:item :if={@product.provider_connection} title="Provider">
|
|
|
|
|
{provider_label(@product)} via {@product.provider_connection.name}
|
|
|
|
|
</:item>
|
|
|
|
|
<:item title="Category">{@product.category || "—"}</:item>
|
|
|
|
|
<:item title="Price">{Cart.format_price(@product.cheapest_price)}</:item>
|
|
|
|
|
<:item title="Variants">{length(@product.variants)}</:item>
|
|
|
|
|
<:item title="Images">{length(@product.images)}</:item>
|
|
|
|
|
<:item title="Created">{format_date(@product.inserted_at)}</:item>
|
|
|
|
|
<:item
|
|
|
|
|
:if={@product.provider_connection && @product.provider_connection.last_synced_at}
|
|
|
|
|
title="Last synced"
|
|
|
|
|
>
|
|
|
|
|
{format_date(@product.provider_connection.last_synced_at)}
|
|
|
|
|
</:item>
|
|
|
|
|
</.list>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<%!-- storefront controls --%>
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
<div class="admin-card admin-card-spaced">
|
2026-02-17 23:05:01 +00:00
|
|
|
<div class="admin-card-body">
|
|
|
|
|
<h3 class="admin-card-title">Storefront controls</h3>
|
2026-02-16 08:48:51 +00:00
|
|
|
<.form
|
|
|
|
|
for={@form}
|
|
|
|
|
phx-submit="save_storefront"
|
|
|
|
|
phx-change="validate_storefront"
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
class="admin-filter-row-end"
|
2026-02-16 08:48:51 +00:00
|
|
|
>
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
<label class="admin-filter-select">
|
|
|
|
|
<span class="admin-filter-label">
|
|
|
|
|
Visibility
|
|
|
|
|
</span>
|
2026-02-16 08:48:51 +00:00
|
|
|
<select
|
|
|
|
|
name="product[visible]"
|
2026-02-17 23:05:01 +00:00
|
|
|
class="admin-select admin-select-sm"
|
2026-02-16 08:48:51 +00:00
|
|
|
aria-label="Visibility"
|
|
|
|
|
>
|
|
|
|
|
<option
|
|
|
|
|
value="true"
|
|
|
|
|
selected={@form[:visible].value == true || @form[:visible].value == "true"}
|
|
|
|
|
>
|
|
|
|
|
Visible
|
|
|
|
|
</option>
|
|
|
|
|
<option
|
|
|
|
|
value="false"
|
|
|
|
|
selected={@form[:visible].value == false || @form[:visible].value == "false"}
|
|
|
|
|
>
|
|
|
|
|
Hidden
|
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</label>
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
<label class="admin-filter-select-wide">
|
|
|
|
|
<span class="admin-filter-label">Category</span>
|
2026-02-16 08:48:51 +00:00
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
name="product[category]"
|
|
|
|
|
value={@form[:category].value}
|
2026-02-17 23:05:01 +00:00
|
|
|
class="admin-input admin-input-sm"
|
2026-02-16 08:48:51 +00:00
|
|
|
placeholder="e.g. Apparel"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
2026-02-18 23:55:42 +00:00
|
|
|
<.button type="submit" variant="primary" class="admin-btn-sm">Save</.button>
|
2026-02-16 08:48:51 +00:00
|
|
|
</.form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<%!-- variants --%>
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
<div class="admin-card admin-card-spaced">
|
2026-02-17 23:05:01 +00:00
|
|
|
<div class="admin-card-body">
|
|
|
|
|
<h3 class="admin-card-title">Variants ({length(@product.variants)})</h3>
|
2026-02-16 08:48:51 +00:00
|
|
|
<.table id="variants" rows={@product.variants}>
|
|
|
|
|
<:col :let={variant} label="Options">{ProductVariant.options_title(variant)}</:col>
|
|
|
|
|
<:col :let={variant} label="SKU">{variant.sku || "—"}</:col>
|
|
|
|
|
<:col :let={variant} label="Price">{Cart.format_price(variant.price)}</:col>
|
|
|
|
|
<:col :let={variant} label="Cost">
|
|
|
|
|
{if variant.cost, do: Cart.format_price(variant.cost), else: "—"}
|
|
|
|
|
</:col>
|
|
|
|
|
<:col :let={variant} label="Profit">
|
|
|
|
|
{if ProductVariant.profit(variant),
|
|
|
|
|
do: Cart.format_price(ProductVariant.profit(variant)),
|
|
|
|
|
else: "—"}
|
|
|
|
|
</:col>
|
|
|
|
|
<:col :let={variant} label="Available">
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
<span
|
2026-02-16 08:48:51 +00:00
|
|
|
:if={variant.is_enabled && variant.is_available}
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
class="admin-icon-positive"
|
|
|
|
|
>
|
|
|
|
|
<.icon name="hero-check-circle-mini" class="size-5" />
|
|
|
|
|
</span>
|
|
|
|
|
<span
|
2026-02-16 08:48:51 +00:00
|
|
|
:if={!variant.is_enabled || !variant.is_available}
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
class="admin-icon-muted"
|
|
|
|
|
>
|
|
|
|
|
<.icon name="hero-x-circle-mini" class="size-5" />
|
|
|
|
|
</span>
|
2026-02-16 08:48:51 +00:00
|
|
|
</:col>
|
|
|
|
|
</.table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<%!-- provider data --%>
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
<div :if={@product.provider_connection} class="admin-card admin-card-spaced">
|
2026-02-17 23:05:01 +00:00
|
|
|
<div class="admin-card-body">
|
|
|
|
|
<h3 class="admin-card-title">Provider data</h3>
|
2026-02-16 08:48:51 +00:00
|
|
|
<.list>
|
|
|
|
|
<:item title="Provider">
|
|
|
|
|
{provider_label(@product)} via {@product.provider_connection.name}
|
|
|
|
|
</:item>
|
|
|
|
|
<:item title="Provider product ID">{@product.provider_product_id}</:item>
|
|
|
|
|
<:item title="Status">{@product.status}</:item>
|
|
|
|
|
<:item title="Sync status">{@product.provider_connection.sync_status}</:item>
|
|
|
|
|
</.list>
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
<div class="admin-section-body">
|
2026-02-17 23:05:01 +00:00
|
|
|
<button phx-click="resync" class="admin-btn admin-btn-outline admin-btn-sm">
|
2026-02-16 08:48:51 +00:00
|
|
|
<.icon name="hero-arrow-path" class="size-4" /> Re-sync
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
# Helpers
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
defp sorted_images(product) do
|
|
|
|
|
(product.images || []) |> Enum.sort_by(& &1.position)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
defp visibility_badge(assigns) do
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
{color, label} =
|
2026-02-16 08:48:51 +00:00
|
|
|
if assigns.visible do
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
{"green", "visible"}
|
2026-02-16 08:48:51 +00:00
|
|
|
else
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
{"zinc", "hidden"}
|
2026-02-16 08:48:51 +00:00
|
|
|
end
|
|
|
|
|
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
assigns = assign(assigns, color: color, label: label)
|
2026-02-16 08:48:51 +00:00
|
|
|
|
|
|
|
|
~H"""
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
<span class={["admin-status-pill", "admin-status-pill-#{@color}"]}>{@label}</span>
|
2026-02-16 08:48:51 +00:00
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
defp status_badge(assigns) do
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
color =
|
2026-02-16 08:48:51 +00:00
|
|
|
case assigns.status do
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
"active" -> "green"
|
|
|
|
|
"draft" -> "amber"
|
|
|
|
|
_ -> "zinc"
|
2026-02-16 08:48:51 +00:00
|
|
|
end
|
|
|
|
|
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
assigns = assign(assigns, :color, color)
|
2026-02-16 08:48:51 +00:00
|
|
|
|
|
|
|
|
~H"""
|
complete admin CSS refactor: delete utilities.css, add layout primitives
- Delete utilities.css (701 lines / 24 KB of Tailwind utility clones)
- Add layout.css with admin-stack, admin-row, admin-cluster, admin-grid
primitives and gap variants (sm, md, lg, xl)
- Add transitions.css import and layout.css import to admin.css entry point
- Replace all Tailwind utility classes across 26 admin templates with
semantic admin-*/theme-*/page-specific CSS classes
- Replace all non-dynamic inline styles with semantic classes
- Add ~100 new semantic classes to components.css (analytics, dashboard,
order detail, settings, theme editor, generic utilities)
- Fix stray text-error → admin-text-error in media.ex
- Add missing .truncate definition to admin CSS
- Only remaining inline styles are dynamic data values (progress bars,
chart dimensions) and one JS.toggle target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:40:21 +00:00
|
|
|
<span class={["admin-status-pill", "admin-status-pill-#{@color}"]}>{@status}</span>
|
2026-02-16 08:48:51 +00:00
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
defp provider_label(%{provider_connection: %{provider_type: "printify"}}), do: "Printify"
|
|
|
|
|
defp provider_label(%{provider_connection: %{provider_type: "printful"}}), do: "Printful"
|
|
|
|
|
defp provider_label(%{provider_connection: %{provider_type: type}}), do: String.capitalize(type)
|
|
|
|
|
defp provider_label(_), do: nil
|
|
|
|
|
|
|
|
|
|
defp provider_edit_url(%{
|
|
|
|
|
provider_connection: %{provider_type: "printify", config: config},
|
|
|
|
|
provider_product_id: pid
|
|
|
|
|
}) do
|
|
|
|
|
shop_id = config["shop_id"]
|
|
|
|
|
if shop_id && pid, do: "https://printify.com/app/editor/#{shop_id}/#{pid}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
defp provider_edit_url(%{
|
|
|
|
|
provider_connection: %{provider_type: "printful"},
|
|
|
|
|
provider_product_id: pid
|
|
|
|
|
}) do
|
|
|
|
|
if pid, do: "https://www.printful.com/dashboard/sync/update?id=#{pid}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
defp provider_edit_url(_), do: nil
|
|
|
|
|
|
|
|
|
|
defp format_date(nil), do: "—"
|
|
|
|
|
defp format_date(datetime), do: Calendar.strftime(datetime, "%d %b %Y %H:%M")
|
|
|
|
|
end
|