defmodule Kanta.DeepL.Plugin.DashboardComponent do @moduledoc """ Phoenix LiveComponent for Kanta dashboard """ use Phoenix.LiveComponent alias Kanta.DeepL.Adapter def render(assigns) do ~H"""
<%= @deep_l_usage %>%
DeepL Usage
""" end def update(assigns, socket) do {:ok, %{"character_count" => character_count, "character_limit" => character_limit}} = Adapter.usage() socket = socket |> assign(:deep_l_usage, Float.ceil(character_count / character_limit, 2)) {:ok, assign(socket, assigns)} end end