34 lines
1.1 KiB
Elixir
34 lines
1.1 KiB
Elixir
|
|
defmodule SimpleshopTheme.Setup do
|
||
|
|
@moduledoc """
|
||
|
|
Aggregates setup status checks for the admin setup flow.
|
||
|
|
"""
|
||
|
|
|
||
|
|
alias SimpleshopTheme.{Accounts, Products, Settings}
|
||
|
|
|
||
|
|
@doc """
|
||
|
|
Returns a map describing the current setup status.
|
||
|
|
|
||
|
|
Used by the admin setup checklist and ThemeHook gate to determine
|
||
|
|
what's been completed and whether the shop can go live.
|
||
|
|
"""
|
||
|
|
def setup_status do
|
||
|
|
conn = Products.get_provider_connection_by_type("printify")
|
||
|
|
product_count = Products.count_products_for_connection(conn && conn.id)
|
||
|
|
|
||
|
|
printify_connected = conn != nil and conn.api_key_encrypted != nil
|
||
|
|
products_synced = product_count > 0
|
||
|
|
stripe_connected = Settings.has_secret?("stripe_api_key")
|
||
|
|
site_live = Settings.site_live?()
|
||
|
|
|
||
|
|
%{
|
||
|
|
admin_created: Accounts.has_admin?(),
|
||
|
|
printify_connected: printify_connected,
|
||
|
|
products_synced: products_synced,
|
||
|
|
product_count: product_count,
|
||
|
|
stripe_connected: stripe_connected,
|
||
|
|
site_live: site_live,
|
||
|
|
can_go_live: printify_connected and products_synced and stripe_connected
|
||
|
|
}
|
||
|
|
end
|
||
|
|
end
|