diff --git a/lib/atomic_web/components/sidebar.ex b/lib/atomic_web/components/sidebar.ex index 2a1ef7d45..818412d1b 100644 --- a/lib/atomic_web/components/sidebar.ex +++ b/lib/atomic_web/components/sidebar.ex @@ -191,9 +191,9 @@ defmodule AtomicWeb.Components.Sidebar do defp user_image(user) do if user.profile_picture do - Atomic.Uploaders.ProfilePicture.url({user, user.profile_picture}, :original) + Atomic.Uploaders.ProfilePicture.url({user.profile_picture, user}, :original) else - "" + nil end end diff --git a/lib/atomic_web/live/profile_live/form_component.ex b/lib/atomic_web/live/profile_live/form_component.ex index 8b1b50774..13f782021 100644 --- a/lib/atomic_web/live/profile_live/form_component.ex +++ b/lib/atomic_web/live/profile_live/form_component.ex @@ -15,7 +15,7 @@ defmodule AtomicWeb.ProfileLive.FormComponent do
- <%= if @user.profile_picture != NULL do %> + <%= if @user.profile_picture != nil do %> <%= label(f, :name, "Profile Picture", class: "mt-3 mb-1 text-sm font-medium text-gray-700") %>
<.avatar name={@user.name} color={:light_gray} class="h-36 w-36 rounded-full border-4 border-white text-4xl" type={:user} src={Uploaders.ProfilePicture.url({@user.profile_picture, @user}, :original)} /> @@ -28,10 +28,11 @@ defmodule AtomicWeb.ProfileLive.FormComponent do
-
+
<.field field={f[:name]} type="text" placeholder="Name" class="w-full" /> <.field field={f[:phone_number]} type="text" placeholder="Phone Number" class="w-full" /> <.field field={f[:email]} type="email" placeholder="Email" class="w-full" /> + <.field field={f[:slug]} type="text" placeholder="User Name" class="w-full" />
@@ -106,7 +107,7 @@ defmodule AtomicWeb.ProfileLive.FormComponent do {:noreply, socket |> put_flash(:success, flash_text) - |> push_navigate(to: ~p"/profile/#{user_params["slug"]}")} + |> push_navigate(to: ~p"/profile/#{user_params["slug"] || user.slug}")} {:error, %Ecto.Changeset{} = changeset} -> {:noreply, assign(socket, :changeset, changeset)} diff --git a/lib/atomic_web/live/profile_live/show.html.heex b/lib/atomic_web/live/profile_live/show.html.heex index ea54f1c04..8ded76bff 100644 --- a/lib/atomic_web/live/profile_live/show.html.heex +++ b/lib/atomic_web/live/profile_live/show.html.heex @@ -83,19 +83,8 @@
<% end %>
- - <%= if @is_current_user do %> -
- <.button patch={Routes.profile_edit_path(@socket, :edit, @user)}> - <%= gettext("Edit") %> - -
- <% end %>
- -
- <%= if @is_current_user do %>
<.button patch={~p"/profile/#{@user}/edit"}> diff --git a/priv/repo/migrations/20221014155230_create_users_auth_tables.exs b/priv/repo/migrations/20221014155230_create_users_auth_tables.exs index dc00ab854..5205f706d 100644 --- a/priv/repo/migrations/20221014155230_create_users_auth_tables.exs +++ b/priv/repo/migrations/20221014155230_create_users_auth_tables.exs @@ -12,6 +12,8 @@ defmodule Atomic.Repo.Migrations.CreateUsersAuthTables do add :slug, :citext add :role, :string, null: false, default: "student" + add :socials, :map + add :hashed_password, :string, null: false add :confirmed_at, :naive_datetime