Skip to content

Commit

Permalink
Merge pull request #121 from TreinaDev/layout/pagina-busca-de-usuarios
Browse files Browse the repository at this point in the history
Redesign da página de busca de usuários
  • Loading branch information
oLucasAguilar authored Feb 15, 2024
2 parents e7feda4 + e3cd0c0 commit 82fabaa
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 65 deletions.
8 changes: 7 additions & 1 deletion app/assets/stylesheets/application.bootstrap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
@import 'bootstrap-icons/font/bootstrap-icons';
@import 'style.scss';
@import 'bootstrap_overwrite';
@import 'simple_calendar';
@import 'simple_calendar';
@import 'app_theme';

.form-control:focus {
border-color: $colaBoraGreen;
box-shadow: 0 0 0 0.2rem rgba(19, 121, 91, 0.075);
}
99 changes: 55 additions & 44 deletions app/views/portfoliorrr_profiles/search.html.erb
Original file line number Diff line number Diff line change
@@ -1,51 +1,62 @@
<%= render 'shared/project_header', project: @project %>

<%= link_to t('back'), project_path(@project), class: 'btn btn-secondary' %>

<h1><%= t('profile_search_title', project_title: @project.title) %></h1>
<h2><%= t('available_users') %></h2>

<% if @query.present? %>
<h3><%= t('results_to') %>: <%= @query %></h3>
<% end %>
<main>
<div class="mt-3 mb-3">
<%= form_with url: search_project_portfoliorrr_profiles_path(@project), method: :get do |f| %>
<div class="input-group">
<%= f.label :q, t('search'),
class: 'd-none' %>
<%= f.text_field :q,
class: 'form-control rounded',
placeholder: t('search_profiles'),
autofocus: true %>
<%= f.submit t('to_search'),
class: 'btn btn-primary' %>
</div>
<% end %>
</div>

<h2 class="display-6 fs-2">
<%= t('available_users') %>
<%= @portfoliorrr_profiles.any? ? "(#{@portfoliorrr_profiles.count})" : '(0)' %>
</h2>

<%= form_with url: search_project_portfoliorrr_profiles_path(@project), method: :get do |f| %>
<div class="input-group">
<%= f.label :q, t('search'), class: 'd-none' %>
<%= f.text_field :q, class: 'form-control rounded', placeholder: t('search') %>
<%= f.submit t('to_search'), class: 'btn btn-outline-primary' %>
<div class="mt-3 text-muted">
<% if @query.present? %>
<p><%= t('results_to') %>: <%= @query %></p>
<% end %>
</div>
<% end %>

<% if @portfoliorrr_profiles.any? %>
<table class="table table-hover align-middle mb-0 bg-white">
<thead class="bg-light">
<tr>
<th><%= t('portfoliorrr_profile.attributes.name') %></th>
<th><%= t('portfoliorrr_profile.attributes.job_category') %></th>
</tr>
</thead>
<tbody>
<% @portfoliorrr_profiles.each do |profile| %>
<% if @portfoliorrr_profiles.any? %>
<table class="table table-hover align-middle mb-0 bg-white">
<thead class="bg-light">
<tr>
<td>
<div class="d-flex align-items-center">
<div class="ms-3">
<p class="fw-bold mb-1">
<%= link_to profile.name, project_portfoliorrr_profile_path(@project, profile.id) %>
</p>
</div>
</div>
</td>
<td>
<p class="fw-normal mb-1">
<%= profile.job_categories.map(&:name).to_sentence %>
</p>
</td>
<th><%= t('portfoliorrr_profile.attributes.name') %></th>
<th><%= t('portfoliorrr_profile.attributes.job_category') %></th>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<h3><%= t('no_users_to_display') %>.</h3>
<% end %>
</thead>
<tbody>
<% @portfoliorrr_profiles.each do |profile| %>
<tr>
<td>
<div class="d-flex align-items-center">
<div class="ms-3">
<p class="fw-bold mb-1">
<%= link_to profile.name, project_portfoliorrr_profile_path(@project, profile.id) %>
</p>
</div>
</div>
</td>
<td>
<p class="fw-normal mb-1">
<%= profile.job_categories.map(&:name).to_sentence %>
</p>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<%# <h3><%= t('no_users_to_display') .</h3> %>
<% end %>
</main>
3 changes: 2 additions & 1 deletion config/locales/general.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ pt-BR:
unauthorized: Você não tem acesso a esse recurso
results_to: Resultados para
search: Busca
search_profiles: Digite o tipo de serviço desejado
to_search: Buscar
available_users: Usuários disponíveis
available_users: Usuários encontrados
no_users_to_display: Não há usuários a serem exibidos
try_again_later: Tente novamente mais tarde
profile: Perfil de %{name}
Expand Down
6 changes: 4 additions & 2 deletions spec/helpers/invitation_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
end

it 'retorna tempo em dias para expiração do convite' do
invitation = create :invitation, expiration_days: 5
travel_to Time.zone.now.beginning_of_day do
invitation = create :invitation, expiration_days: 5

expect(invitation_expiration_date(invitation)).to eq 'Expira em 4 dias'
expect(invitation_expiration_date(invitation)).to eq 'Expira em 5 dias'
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@
end

expect(page).not_to have_content 'Não há usuários a serem exibidos.'
expect(page).to have_content 'Projeto Top - Recrutamento de colaboradores'
expect(page).to have_content 'Usuários disponíveis'
expect(page).to have_content 'Usuários encontrados (3)'
expect(page).to have_content 'Lucas'
expect(page).to have_content 'Desenvolvedor'
expect(page).to have_content 'Mateus'
Expand All @@ -115,7 +114,7 @@
login_as user
visit search_project_portfoliorrr_profiles_path project

expect(page).to have_content 'Não há usuários a serem exibidos.'
expect(page).to have_content 'Usuários encontrados (0)'
end

context 'buscando por termo' do
Expand Down Expand Up @@ -157,22 +156,9 @@
click_on 'Buscar'

expect(current_path).to eq search_project_portfoliorrr_profiles_path project
expect(page).to have_content 'Usuários encontrados (0)'
expect(page).to have_content 'Resultados para: termo maluco'
expect(page).to have_content 'Não há usuários a serem exibidos.'
end
end

it 'e volta para a página de projetos' do
user = create :user, cpf: '149.759.780-32'
project = create(:project, user:)
project.user_roles.find_by(user:).update(role: :leader)
allow(PortfoliorrrProfile).to receive(:all).and_return([])

login_as user
visit search_project_portfoliorrr_profiles_path project
click_on 'Voltar'

expect(page).to have_current_path project_path(project)
end
end
end

0 comments on commit 82fabaa

Please sign in to comment.