-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: profile pages #528
Draft
AfonsoMartins26
wants to merge
20
commits into
develop
Choose a base branch
from
am/profile
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
feat: profile pages #528
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
64f8726
Update 22/23 Team (#249)
ruioliveira02 ef699a9
Update Felicio picture (#250)
feliciofilipe e1f06cd
Add partners (#282)
MarioRodrigues10 99b28b4
feat: initial profile page
AfonsoMartins26 ea9e7cc
fix: save redirect
AfonsoMartins26 7063235
Fix: save redirect Tiktok
AfonsoMartins26 90093c9
Chore: improve layout of profile page
AfonsoMartins26 0bab33d
Feat: Improve html
AfonsoMartins26 7cc2a00
misspell
AfonsoMartins26 95cbd6a
Fix: Profile Picture upload
AfonsoMartins26 ad5460f
format code
AfonsoMartins26 21741f0
Merge branch 'develop' into am/profile
AfonsoMartins26 07b3111
feat: preview profile image in edit page
AfonsoMartins26 d44469c
Merge branch 'am/profile' of github.com:cesium/atomic into am/profile
AfonsoMartins26 da8d768
fix: miss div
AfonsoMartins26 1854bf2
feat: add slug field
AfonsoMartins26 e9c9aec
fix: delete IO
AfonsoMartins26 85b8d58
feat: pass checks
AfonsoMartins26 95b9214
merge with main
AfonsoMartins26 4a053dd
merge develop
AfonsoMartins26 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
617 changes: 617 additions & 0 deletions
617
app/assets/images/partners/thetraditionalgreatpizza.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
defmodule AtomicWeb.ProfileLive.FormComponent do | ||
use AtomicWeb, :live_component | ||
|
||
alias Atomic.Accounts | ||
alias AtomicWeb.Components.ImageUploader | ||
import AtomicWeb.Components.Forms | ||
import AtomicWeb.Components.{Button, Avatar} | ||
|
||
@impl true | ||
def render(assigns) do | ||
~H""" | ||
<div class="px-4 pt-4"> | ||
<.form :let={f} for={@changeset} id="profile-form" phx-target={@myself} phx-change="validate" phx-submit="save"> | ||
<div class="grid grid-cols-1 gap-6 md:grid-cols-2"> | ||
<div class="flex flex-col items-center pr-4"> | ||
<%= if @user.profile_picture != nil do %> | ||
<%= label(f, :name, "Profile Picture", class: "mt-3 mb-1 text-sm font-medium text-gray-700") %> | ||
<div class="mb-4 border-4"> | ||
<.avatar name={@user.name} color={:zinc} class="h-36 w-36 rounded-full border-4 border-white text-4xl" type={:user} src={Uploaders.ProfilePicture.url({@user.profile_picture, @user}, :original)} /> | ||
</div> | ||
<.live_component module={ImageUploader} id="uploader-profile-picture" uploads={@uploads} target={@myself} /> | ||
<% else %> | ||
<%= label(f, :name, "Profile Picture", class: "mt-3 mb-1 text-sm font-medium text-gray-700") %> | ||
<.live_component module={ImageUploader} id="uploader-profile-picture" uploads={@uploads} target={@myself} /> | ||
<% end %> | ||
</div> | ||
<div class="flex flex-col gap-6"> | ||
<div class="grid grid-cols-1 gap-2"> | ||
<.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" /> | ||
</div> | ||
<div class="grid w-full gap-x-4 gap-y-4 sm:grid-cols-1 md:grid-cols-4"> | ||
<.inputs_for :let={socials_form} field={f[:socials]}> | ||
<.field field={socials_form[:instagram]} type="text" placeholder="Instagram" class="w-full" /> | ||
<.field field={socials_form[:facebook]} type="text" placeholder="Facebook" class="w-full" /> | ||
<.field field={socials_form[:x]} type="text" placeholder="X" class="w-full" /> | ||
<.field field={socials_form[:tiktok]} type="text" placeholder="TikTok" class="w-full" /> | ||
</.inputs_for> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="mt-8 flex w-full justify-end"> | ||
<.button size={:md} color={:white} icon="hero-cube">Save</.button> | ||
</div> | ||
</.form> | ||
</div> | ||
""" | ||
end | ||
|
||
@impl true | ||
def update(%{user: user} = assigns, socket) do | ||
changeset = Accounts.change_user(user) | ||
|
||
{:ok, | ||
socket | ||
|> allow_upload(:image, | ||
accept: Uploaders.ProfilePicture.extension_whitelist(), | ||
max_entries: 1 | ||
) | ||
|> assign(assigns) | ||
|> assign(:changeset, changeset)} | ||
end | ||
|
||
@impl true | ||
def handle_event("validate", %{"user" => user_params}, socket) do | ||
changeset = | ||
socket.assigns.user | ||
|> Accounts.change_user(user_params) | ||
|> Map.put(:action, :validate) | ||
|
||
{:noreply, assign(socket, :changeset, changeset)} | ||
end | ||
|
||
@impl true | ||
def handle_event("save", %{"user" => user_params}, socket) do | ||
user = socket.assigns.user | ||
|
||
flash_text = | ||
if user_params["email"] != user.email do | ||
case Accounts.apply_user_email(user, %{email: user_params["email"]}) do | ||
{:ok, applied_user} -> | ||
Accounts.deliver_update_email_instructions( | ||
applied_user, | ||
user.email, | ||
&url(~p"/users/confirm_email/#{&1}") | ||
) | ||
|
||
"Profile updated successfully, please check your email to confirm the new address." | ||
end | ||
else | ||
"Profile updated successfully." | ||
end | ||
|
||
case Accounts.update_user( | ||
user, | ||
Map.put(user_params, "email", user.email), | ||
&consume_image_data(socket, &1) | ||
) do | ||
{:ok, _user} -> | ||
{:noreply, | ||
socket | ||
|> put_flash(:success, flash_text) | ||
|> push_navigate(to: ~p"/profile/#{user_params["slug"] || user.slug}")} | ||
|
||
{:error, %Ecto.Changeset{} = changeset} -> | ||
{:noreply, assign(socket, :changeset, changeset)} | ||
end | ||
end | ||
|
||
defp consume_image_data(socket, user) do | ||
consume_uploaded_entries(socket, :image, fn %{path: path}, entry -> | ||
Accounts.update_user_picture(user, %{ | ||
"profile_picture" => %Plug.Upload{ | ||
content_type: entry.client_type, | ||
filename: entry.client_name, | ||
path: path | ||
} | ||
}) | ||
end) | ||
|> case do | ||
[{:ok, user}] -> | ||
{:ok, user} | ||
|
||
_errors -> | ||
{:ok, user} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is being used in multiple places please create a component