.header>
{if @live_action == :new,
do: "Connect to #{provider_label(@provider_type)}",
else: "#{provider_label(@provider_type)} settings"}
<%= if @live_action == :new do %>
{provider_label(@provider_type)} is a print-on-demand service that prints and ships products for you.
Connect your account to automatically import your products into your shop.
<%= if @provider_type == "printify" do %>
Get your API key from Printify:
Log in to Printify
(or create a free account )
Click Account (top right)
Select Connections from the dropdown
Find API tokens and click Generate
Enter a name (e.g. "My Shop"), keep all scopes
selected, and click Generate token
Click Copy to clipboard and paste it below
<% else %>
Get your API key from Printful:
Log in to Printful
(or create a free account )
Go to Settings → API access
Click Create API key
Give it a name and select all scopes
Copy the token and paste it below
<% end %>
<% end %>
<.form for={@form} id="provider-form" phx-change="validate" phx-submit="save">
<.input
field={@form[:api_key]}
type="password"
label={"#{provider_label(@provider_type)} API key"}
placeholder={
if @live_action == :edit,
do: "Leave blank to keep current key",
else: "Paste your key here"
}
autocomplete="off"
/>
<.icon
name={if @testing, do: "hero-arrow-path", else: "hero-signal"}
class={if @testing, do: "size-4 animate-spin", else: "size-4"}
/>
{if @testing, do: "Checking...", else: "Check connection"}
<%= case @test_result do %>
<% {:ok, _info} -> %>
<.icon name="hero-check-circle" class="size-4" />
Connected to {connection_name(@test_result) || provider_label(@provider_type)}
<% {:error, reason} -> %>
<.icon name="hero-x-circle" class="size-4" />
{format_error(reason)}
<% end %>
<%= if @live_action == :edit do %>
<.input field={@form[:enabled]} type="checkbox" label="Connection enabled" />
<% end %>
<.button type="submit" disabled={@testing}>
{if @live_action == :new,
do: "Connect to #{provider_label(@provider_type)}",
else: "Save changes"}
<.link navigate={~p"/admin/providers"} class="admin-btn admin-btn-ghost">
Cancel