Skip to content

Commit

Permalink
Connect recruiter to companies
Browse files Browse the repository at this point in the history
  • Loading branch information
laraujo7 committed Jun 28, 2022
1 parent a3c7571 commit e440603
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 27 deletions.
14 changes: 13 additions & 1 deletion lib/parzival_web/live/app/profile_live/form_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down Expand Up @@ -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
58 changes: 33 additions & 25 deletions lib/parzival_web/live/app/profile_live/form_component.html.heex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<main x-data="{option: 'profile'}" class="overflow-y-auto relative z-0 flex-1 mb-4 min-h-screen border-r border-gray-200 xl:order-last focus:outline-none">
<main x-data="{option: 'profile'}" class="relative z-0 flex-1 min-h-screen mb-4 overflow-y-auto border-r border-gray-200 xl:order-last focus:outline-none">
<.form let={f} for={@changeset} id="user-form" phx-change="validate" phx-target={@myself} phx-submit="save">
<article>
<!-- Profile header -->
Expand All @@ -14,20 +14,20 @@
<div class={"#{if length(@uploads.picture.entries) != 0 do
"hidden"
end} relative w-24 h-24 ring-4 ring-white rounded-full cursor-pointer bg-secondary sm:w-32 group sm:h-32 hover:bg-tertiary"}>
<div class="flex absolute justify-center items-center w-full h-full">
<Heroicons.Outline.camera class="mx-auto w-12 h-12 text-white group-hover:text-opacity-70" />
<div class="absolute flex items-center justify-center w-full h-full">
<Heroicons.Outline.camera class="w-12 h-12 mx-auto text-white group-hover:text-opacity-70" />
</div>
</div>
<section>
<%= for entry <- @uploads.picture.entries do %>
<%= for err <- upload_errors(@uploads.picture, entry) do %>
<p class="alert alert-danger"><%= Phoenix.Naming.humanize(err) %></p>
<% end %>
<article class="flex relative items-center w-24 h-24 bg-white rounded-full cursor-pointer sm:w-32 sm:h-32 upload-entry group">
<div class="flex absolute z-10 justify-center items-center w-full h-full rounded-full">
<Heroicons.Outline.camera class="mx-auto w-12 h-12 text-white text-opacity-0 rounded-full group-hover:text-opacity-100" />
<article class="relative flex items-center w-24 h-24 bg-white rounded-full cursor-pointer sm:w-32 sm:h-32 upload-entry group">
<div class="absolute z-10 flex items-center justify-center w-full h-full rounded-full">
<Heroicons.Outline.camera class="w-12 h-12 mx-auto text-white text-opacity-0 rounded-full group-hover:text-opacity-100" />
</div>
<figure class="flex justify-center items-center w-full h-full rounded-full group-hover:opacity-80">
<figure class="flex items-center justify-center w-full h-full rounded-full group-hover:opacity-80">
<%= live_img_preview(entry, class: "object-cover object-center rounded-full w-24 h-24 sm:w-32 sm:h-32 border-4 border-white") %>
</figure>
</article>
Expand All @@ -48,14 +48,14 @@

<div class="flex flex-col space-y-3 sm:flex-row sm:space-y-0 sm:space-x-4 md:mt-6 justify-stretch">
<%= submit do %>
<div type="button" class="py-2 px-4 mt-6 text-sm font-medium text-white rounded-md border border-transparent shadow-sm xl:w-full bg-secondary hover:bg-primary">
<div type="button" class="px-4 py-2 mt-6 text-sm font-medium text-white border border-transparent rounded-md shadow-sm xl:w-full bg-secondary hover:bg-primary">
Save
</div>
<% end %>
</div>
</div>
</div>
<div class="hidden flex-1 mt-6 min-w-0 sm:block 2xl:hidden">
<div class="flex-1 hidden min-w-0 mt-6 sm:block 2xl:hidden">
<h1 class="text-2xl font-bold text-gray-900 truncate">
<%= input_value(f, :name) %>
</h1>
Expand All @@ -65,12 +65,12 @@
<!-- Tabs -->
<div class="mt-6 sm:mt-2 2xl:mt-5">
<div class="border-b border-gray-200">
<div class="px-4 mx-auto max-w-5xl sm:px-6 lg:px-8">
<div class="max-w-5xl px-4 mx-auto sm:px-6 lg:px-8">
<nav class="flex -mb-px space-x-8" aria-label="Tabs">
<button
x-on:click="option = 'profile'"
x-bind:class="option =='profile' ? 'border-b-2 border-red-500 text-gray-900' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'"
class="py-4 px-1 text-sm font-medium text-gray-500 whitespace-nowrap border-b-2 border-transparent hover:text-gray-700 hover:border-gray-300"
class="px-1 py-4 text-sm font-medium text-gray-500 border-b-2 border-transparent whitespace-nowrap hover:text-gray-700 hover:border-gray-300"
>
Profile
</button>
Expand All @@ -79,8 +79,8 @@
</div>
</div>
<!-- Profile -->
<div x-bind:class="option =='profile' ? 'block' : 'hidden'" class="mx-auto max-w-5xl">
<dl class="grid grid-cols-1 gap-4 py-6 px-4 border-b border-gray-200 sm:grid-cols-2 sm:px-6 lg:px-8">
<div x-bind:class="option =='profile' ? 'block' : 'hidden'" class="max-w-5xl mx-auto">
<dl class="grid grid-cols-1 gap-4 px-4 py-6 border-b border-gray-200 sm:grid-cols-2 sm:px-6 lg:px-8">
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Name</dt>
<dd class="mt-1 text-sm text-gray-900">
Expand All @@ -92,7 +92,7 @@
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Course</dt>
<dd class="flex flex-row gap-x-4 mt-1 text-sm text-gray-900">
<dd class="flex flex-row mt-1 text-sm text-gray-900 gap-x-4">
<%= select(f, :cycle, @cycles, prompt: "Choose a Cycle", selected: f.data.cycle, class: "mt-1 block border-gray-300 rounded-md shadow-sm focus:ring-red-800 focus:border-red-800 text-sm") %>
<%= text_input(f, :course, class: "mt-1 focus:ring-red-500 focus:border-red-500 block w-full shadow-sm text-sm border-gray-300 rounded-md") %>
</dd>
Expand All @@ -108,52 +108,60 @@
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Cellphone</dt>
<dd class="flex flex-row gap-x-4 mt-1 text-sm text-gray-900">
<dd class="flex flex-row mt-1 text-sm text-gray-900 gap-x-4">
<%= text_input(f, :cellphone, class: "mt-1 focus:ring-red-500 focus:border-red-500 block w-full shadow-sm text-sm border-gray-300 rounded-md") %>
</dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Website</dt>
<dd class="flex flex-row gap-x-4 mt-1 text-sm text-gray-900">
<dd class="flex flex-row mt-1 text-sm text-gray-900 gap-x-4">
<%= 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") %>
</dd>
</div>
<%= if @role in [:recruiter] && @current_user.role in [:admin] do %>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Company</dt>
<dd class="flex flex-row mt-1 text-sm text-gray-900 gap-x-4">
<%= 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") %>
</dd>
</div>
<% end %>
</dl>
<dl class="grid grid-cols-1 gap-4 py-6 px-4 border-b border-gray-200 sm:grid-cols-2 sm:px-6 lg:px-8">
<dl class="grid grid-cols-1 gap-4 px-4 py-6 border-b border-gray-200 sm:grid-cols-2 sm:px-6 lg:px-8">
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Linkedin</dt>
<dd class="flex flex-row gap-x-4 mt-1 text-sm text-gray-900">
<dd class="flex flex-row mt-1 text-sm text-gray-900 gap-x-4">
<%= text_input(f, :linkedin, class: "mt-1 focus:ring-red-500 focus:border-red-500 block w-full shadow-sm text-sm border-gray-300 rounded-md") %>
</dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Github</dt>
<dd class="flex flex-row gap-x-4 mt-1 text-sm text-gray-900">
<dd class="flex flex-row mt-1 text-sm text-gray-900 gap-x-4">
<%= text_input(f, :github, class: "mt-1 focus:ring-red-500 focus:border-red-500 block w-full shadow-sm text-sm border-gray-300 rounded-md") %>
</dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Twitter</dt>
<dd class="flex flex-row gap-x-4 mt-1 text-sm text-gray-900">
<dd class="flex flex-row mt-1 text-sm text-gray-900 gap-x-4">
<%= text_input(f, :twitter, class: "mt-1 focus:ring-red-500 focus:border-red-500 block w-full shadow-sm text-sm border-gray-300 rounded-md") %>
</dd>
</div>
</dl>

<%= if @current_user.role == :admin and @user.role == :attendee do %>
<div class="py-6 px-4 border-b border-gray-200 sm:grid-cols-2 sm:px-6 lg:px-8">
<div class="px-4 py-6 border-b border-gray-200 sm:grid-cols-2 sm:px-6 lg:px-8">
<h2 class="text-base font-medium text-gray-900">Scan credential to link to user</h2>
<%= text_input(f, :qr, id: "qr_input", class: "hidden mt-1 focus:ring-red-500 focus:border-red-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md") %>
<div id="loadingMessageWrapper" class="pt-5 pr-6 pb-5 pl-4 mt-16 sm:pl-6 lg:pl-8 xl:pt-6 xl:pl-6">
<div class="flex justify-between items-center h-10">
<div id="loadingMessageWrapper" class="pt-5 pb-5 pl-4 pr-6 mt-16 sm:pl-6 lg:pl-8 xl:pt-6 xl:pl-6">
<div class="flex items-center justify-between h-10">
<div id="loadingMessage" class="inline-flex justify-center py-2 text-base font-medium text-gray-900">
Unable to access camera. Make sure you allow the use of the camera
</div>
<button onclick="requestMedia()" class="inline-flex justify-center items-center py-2 px-4 text-sm font-medium text-white rounded-md border border-transparent shadow-sm bg-secondary hover:bg-primary">Request Permission</button>
<button onclick="requestMedia()" class="inline-flex items-center justify-center px-4 py-2 text-sm font-medium text-white border border-transparent rounded-md shadow-sm bg-secondary hover:bg-primary">Request Permission</button>
</div>
</div>

<canvas id="canvas" class="mt-16 w-full"></canvas>
<canvas id="canvas" class="w-full mt-16"></canvas>
</div>
<script src="/js/qrjs.js">
</script>
Expand Down
2 changes: 1 addition & 1 deletion lib/parzival_web/live/backoffice/accounts/user_live/new.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule ParzivalWeb.Backoffice.UserLive.New do
"admin" -> :admin
"staff" -> :staff
"attendee" -> :attendee
"company" -> :company
"recruiter" -> :recruiter
end

{:noreply,
Expand Down

0 comments on commit e440603

Please sign in to comment.