defmodule PlausibleWeb.Live.CustomerSupport.User do
@moduledoc """
User coordinator LiveView for Customer Support interface.
Manages tab-based navigation and delegates rendering to specialized
components: Overview and API Keys.
"""
use PlausibleWeb.CustomerSupport.Live
import Ecto.Query
alias Plausible.Repo
alias PlausibleWeb.CustomerSupport.User.Components.{
Overview,
Keys
}
def handle_params(%{"id" => user_id} = params, _uri, socket) do
tab = params["tab"] || "overview"
user = Resource.User.get(user_id)
if user do
keys_count = count_keys(user)
socket =
socket
|> assign(:user, user)
|> assign(:tab, tab)
|> assign(:keys_count, keys_count)
{:noreply, go_to_tab(socket, tab, params, :user, tab_component(tab))}
else
{:noreply, redirect(socket, to: Routes.customer_support_path(socket, :index))}
end
end
def render(assigns) do
~H"""
{@user.email}