Skip to content

Commit

Permalink
Merge branch 'release/2024.02'
Browse files Browse the repository at this point in the history
  • Loading branch information
lurnid committed Dec 10, 2024
2 parents d9cdd31 + 6f71982 commit 1d22789
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 25 deletions.
16 changes: 8 additions & 8 deletions lib/maker_passport/maker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ defmodule MakerPassport.Maker do
"""
def list_profiles(skills \\ []) do
Repo.all(Profile) |> Repo.preload([:skills, :user])

query =
Profile
|> join(:left, [p], s in assoc(p, :skills))
|> maybe_filter_by_skills(skills)
|> preload([:skills, :user])
|> distinct([p], p.id)
Profile
|> join(:left, [p], s in assoc(p, :skills))
|> maybe_filter_by_skills(skills)
|> preload([:skills, :user])
|> distinct([p], p.id)

Repo.all(query)
end
end

defp maybe_filter_by_skills(query, []), do: query

defp maybe_filter_by_skills(query, skills) do
query
|> where([p, s], s.name in ^skills)
Expand Down Expand Up @@ -482,8 +484,6 @@ end
"""
def create_certification(attrs \\ %{}) do
IO.inspect(attrs)

%Certification{}
|> Certification.changeset(attrs)
|> Repo.insert()
Expand Down
16 changes: 13 additions & 3 deletions lib/maker_passport_web/live/home_live/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,19 @@
</div>
</div>
</div>
<h2 class="text-[#1C1D22] text-[22px] font-bold leading-tight tracking-[-0.015em] px-4 pb-3 pt-5">
Recently Active Makers
</h2>
<div class="flex w-full items-center">
<h2 class="grow text-[#1C1D22] text-[22px] font-bold leading-tight tracking-[-0.015em] px-4 pb-3 pt-5">
Recently Active Makers
</h2>
<div class="justify-self-end">
<.link
href={~p"/profiles"}
class="text-[#1C1D22] underline font-bold leading-normal hover:text-blue-700"
>
See all
</.link>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<%= for profile <- @latest_profiles do %>
<.link
Expand Down
2 changes: 0 additions & 2 deletions lib/maker_passport_web/live/profile_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ defmodule MakerPassportWeb.ProfileLive.Index do
|> Enum.reject(fn profile -> profile.user && profile.user.id == user.id end)
end

IO.inspect(profiles)

socket =
socket
|> assign(:no_skills_results, profiles == [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ defmodule MakerPassportWeb.ProfileLive.ProfileFormComponent do
|> assign(assigns)
|> assign_new(:form, fn ->
to_form(Maker.change_profile(profile))
end)
}
end)}
end

@impl true
Expand Down Expand Up @@ -70,9 +69,9 @@ defmodule MakerPassportWeb.ProfileLive.ProfileFormComponent do
{:noreply, socket}
end


defp save_profile(socket, profile_params) do
profile_params = check_or_create_location(profile_params)

case Maker.update_profile(socket.assigns.profile, profile_params) do
{:ok, _profile} ->
{:noreply,
Expand Down
25 changes: 16 additions & 9 deletions lib/maker_passport_web/live/profile_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@
<% end %>
</div>

<div :if={@live_action != :edit_profile} class="py-8 @container max-w-5xl mx-auto" id="profile-details">
<div
:if={@live_action != :edit_profile}
class="py-8 @container max-w-5xl mx-auto"
id="profile-details"
>
<div class="space-y-12">
<div class="grid grid-cols-4 gap-8">
<div class="justify-self-end">
<.avatar profile={@profile} size={36} />
</div>
<div class="col-span-3 mt-5 border border-gray-300 rounded-lg p-4">
<div class="col-span-3 mt-5 border border-gray-300 rounded-lg p-4">
<h1 class="text-4xl font-bold text-gray-900 tracking-tight">
<%= @profile.name %>
</h1>
<div class="mt-4 space-y-2 text-gray-600">
<div :if={@profile.location} class="mt-4 space-y-2 text-gray-600">
<p class="flex items-center gap-2">
<.icon name="hero-map-pin" class="w-5 h-5" :if={@profile.location} />
<%= @profile.location && get_country_name(@profile.location.country) <> " . " <> @profile.location.city %>
<.icon :if={@profile.location} name="hero-map-pin" class="w-5 h-5" />
<%= @profile.location &&
get_country_name(@profile.location.country) <> " . " <> @profile.location.city %>
</p>
<p class="leading-relaxed"><%= @profile.bio %></p>
</div>
Expand All @@ -49,7 +54,7 @@
</div>
<% end %>

<%= if @profile.certifications != [] do %>
<%= if @profile.certifications != [] do %>
<div class="grid grid-cols-4 gap-8">
<div class="justify-self-end">
<h3 class="text-lg font-semibold text-gray-800">Certifications</h3>
Expand Down Expand Up @@ -80,9 +85,11 @@
<%= if certificate.url do %>
<div class="text-sm font-medium text-gray-500">URL</div>
<div class="col-span-2 text-sm text-gray-900">
<a href={certificate.url}
target="_blank"
class="text-blue-600 hover:text-blue-800 hover:underline break-all">
<a
href={certificate.url}
target="_blank"
class="text-blue-600 hover:text-blue-800 hover:underline break-all"
>
<%= certificate.url %>
</a>
</div>
Expand Down

0 comments on commit 1d22789

Please sign in to comment.