diff --git a/lib/parzival_web/live/app/profile_live/form_component.ex b/lib/parzival_web/live/app/profile_live/form_component.ex index 1bc8d756..22ea193f 100644 --- a/lib/parzival_web/live/app/profile_live/form_component.ex +++ b/lib/parzival_web/live/app/profile_live/form_component.ex @@ -4,6 +4,7 @@ defmodule ParzivalWeb.App.ProfileLive.FormComponent do alias Parzival.Accounts alias Parzival.Accounts.User + alias Parzival.Companies @extensions_whitelist ~w(.jpg .jpeg .gif .png) @cycles [:Bachelors, :Masters, :Phd] @@ -27,7 +28,8 @@ defmodule ParzivalWeb.App.ProfileLive.FormComponent do |> assign(assigns) |> assign(:user, user) |> assign(:cycles, @cycles) - |> assign(:changeset, changeset)} + |> assign(:changeset, changeset) + |> assign(list_companies(assigns))} end @impl true @@ -98,4 +100,14 @@ defmodule ParzivalWeb.App.ProfileLive.FormComponent do {:ok, user} end end + + defp list_companies(params) do + case Companies.list_companies(params) do + {:ok, {companies, _meta}} -> + %{companies: companies} + + {:error, _flop} -> + %{companies: []} + end + end end diff --git a/lib/parzival_web/live/app/profile_live/form_component.html.heex b/lib/parzival_web/live/app/profile_live/form_component.html.heex index c50b54f3..6816b822 100644 --- a/lib/parzival_web/live/app/profile_live/form_component.html.heex +++ b/lib/parzival_web/live/app/profile_live/form_component.html.heex @@ -118,6 +118,14 @@ <%= text_input(f, :website, class: "mt-1 focus:ring-red-500 focus:border-red-500 block w-full shadow-sm text-sm border-gray-300 rounded-md") %> + <%= if @role in [:recruiter] && @current_user.role in [:admin] do %> +
+
Company
+
+ <%= select(f, :company_id, Enum.map(@companies, &{&1.name, &1.id}), prompt: "Choose a Sponsorship Level", selected: f.data.company_id, class: "mt-1 focus:ring-red-500 focus:border-red-500 block w-full shadow-sm text-sm border-gray-300 rounded-md") %> +
+
+ <% end %>
diff --git a/lib/parzival_web/live/backoffice/accounts/user_live/new.ex b/lib/parzival_web/live/backoffice/accounts/user_live/new.ex index 7f70f0f2..f1d7bf63 100644 --- a/lib/parzival_web/live/backoffice/accounts/user_live/new.ex +++ b/lib/parzival_web/live/backoffice/accounts/user_live/new.ex @@ -16,7 +16,7 @@ defmodule ParzivalWeb.Backoffice.UserLive.New do "admin" -> :admin "staff" -> :staff "attendee" -> :attendee - "company" -> :company + "recruiter" -> :recruiter end {:noreply,