defmodule LiveBeatsWeb.SettingsLive do use LiveBeatsWeb, :live_view alias LiveBeats.Accounts def render(assigns) do ~H""" <.title_bar> Profile Settings
<.form :let={f} id="settings-form" for={@changeset} phx-change={ JS.push("validate", loading: "#settings-form, #settings-form button, #settings-form input, #settings-form [phx-feedback-for]" ) } phx-submit="save" class="space-y-8 divide-y divide-gray-200" >

This information will be displayed publicly so be careful what you share.

<%= URI.parse(LiveBeatsWeb.Endpoint.url()).host %>/ <%= text_input(f, :username, class: "flex-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full min-w-0 rounded-none rounded-r-md sm:text-sm border-gray-300" ) %> <.error field={:username} input_name="user[username]" errors={f.errors} class="pt-2 pl-4 pr-4 ml-2 text-center" />
<%= text_input(f, :email, disabled: true, class: "flex-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full min-w-0 rounded-md sm:text-sm border-gray-300 bg-gray-50" ) %>
<%= text_input(f, :profile_tagline, class: "flex-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full min-w-0 rounded-md sm:text-sm border-gray-300" ) %> <.error field={:profile_tagline} input_name="user[profile_tagline]" errors={f.errors} class="pt-2 pl-4 pr-4 ml-2 text-center" />

Write a short tagline for your beats page.

""" end def mount(_params, _session, socket) do changeset = Accounts.change_settings(socket.assigns.current_user, %{}) {:ok, assign(socket, changeset: changeset)} end def handle_params(_, _, socket), do: {:noreply, socket} def handle_event("validate", %{"user" => params}, socket) do changeset = Accounts.change_settings(socket.assigns.current_user, params) {:noreply, assign(socket, changeset: Map.put(changeset, :action, :validate))} end def handle_event("save", %{"user" => params}, socket) do case Accounts.update_public_settings(socket.assigns.current_user, params) do {:ok, user} -> {:noreply, socket |> assign(current_user: user) |> put_flash(:info, "settings updated!")} {:error, changeset} -> {:noreply, assign(socket, changeset: changeset)} end end end