Skip to content
Snippets Groups Projects
Commit 1acffbe3 authored by Kerdo Kurs's avatar Kerdo Kurs
Browse files

add implementation for profile page #46

parent e2564971
No related branches found
No related tags found
2 merge requests!12Resolve "FR-30: Profile page",!10Resolve "FR-30: Profile page"
defmodule PropTrackrWeb.ProfileController do
use PropTrackrWeb, :controller
import PropTrackr.Authentication
alias PropTrackr.Repo
alias PropTrackr.Accounts.User
def index(conn, _params) do
user_id = get_session(conn, :user_id)
if user_id == nil do
conn
|> put_flash(:error, "You are not logged!")
|> redirect(to: ~p"/login")
else
user = Repo.get(User, user_id)
render(conn, "index.html", user: user)
end
end
end
defmodule PropTrackrWeb.ProfileHTML do
use PropTrackrWeb, :html
embed_templates "profile_html/*"
end
<.header>
Your profile
<:actions>
<.link href={~p"/me/details"}>
<.button>Edit details</.button>
</.link>
<.link href={~p"/me/delete"}>
<.button class="bg-red-700 hover:bg-red-500">Delete account</.button>
</.link>
</:actions>
</.header>
<p class="italic"><%= @user.name %> <%= @user.surname %></p>
<p><span class="bold">First name:</span> <%= @user.name %></p>
<p><span class="bold">Last name:</span> <%= @user.surname %></p>
<p><span class="bold">Birth date:</span> <%= @user.birth_date %></p>
<p><span class="bold">Phone number:</span> <%= @user.phone_number %></p>
<p><span class="bold">Email:</span> <%= @user.email %></p>
<p><span class="bold">Bio:</span> <%= @user.bio %></p>
......@@ -23,8 +23,10 @@ defmodule PropTrackrWeb.Router do
resources "/register", RegisterController, only: [:index, :create]
resources "/login", LoginController, only: [:index, :create]
resources "/logout", LogoutController
resources "/me", ProfileController, only: [:index]
resources "/me/details", UpdateController, only: [:index, :create]
resources "/me/password", PasswordController, only: [:index, :create]
resources "/me/details", UpdateController
end
# Other scopes may use custom stacks.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment