-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from TreinaDev/feat/manager-dashboard
Dashboard de Organizador de Evento
- Loading branch information
Showing
3 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,5 +1,69 @@ | ||
<% if current_user.event_manager? %> | ||
<p>Dashboard Manager</p> | ||
<div class="flex flex-col gap-4"> | ||
<div class="border-l-4 pl-4 py-2 flex flex-col border-blue-800"> | ||
<h2>Seu lucro total na plataforma: <%= number_to_currency 20_000 %></h2> | ||
<p>No último mês: R$2.000,00</p> | ||
</div> | ||
|
||
<div class="grid grid-cols-2 w-full mt-6 gap-10"> | ||
<div class="flex flex-col gap-8"> | ||
<h2>Seus Eventos</h2> | ||
|
||
<div class="ml-6 flex gap-16 text-center items-center"> | ||
<div id="created-events"> | ||
<strong class="text-3xl underline underline-offset-8 decoration-primary"><%= @events_count %></strong> | ||
|
||
<p class="mt-4"><%= @events_count == 1 ? 'Evento Criado' : 'Eventos Criados' %></p> | ||
</div> | ||
|
||
<div class="h-full w-px bg-gray-300"></div> | ||
|
||
<div id="published-events"> | ||
<strong class="text-3xl underline underline-offset-8 decoration-primary"><%= @published_events_count %></strong> | ||
|
||
<p class="mt-4"><%= @published_events_count == 1 ? 'Evento publicado' : 'Eventos Publicados' %></p> | ||
</div> | ||
</div> | ||
|
||
<div class="mt-6"> | ||
<h3 class="mb-3 text-primary font-bold">Últimos Eventos Publicados</h3> | ||
|
||
<% @last_published_events.each do |event| %> | ||
<%= link_to event_path(event) do %> | ||
<div class="mb-3 rounded w-full h-24 bg-slate-500 bg-opacity-5 shadow flex gap-4 pr-4 cursor-pointer hover:shadow-md duration-150"> | ||
<%= image_tag url_for(event.logo), class: "h-full w-[100px]" %> | ||
|
||
<div class="w-full flex justify-between"> | ||
<div class="flex flex-col h-full justify-center gap-1"> | ||
<strong><%= event.name %></strong> | ||
<p class="text-sm"><span class="font-bold">Quando?</span> | ||
<% if event.start_date > Time.current %> | ||
Começa em <%= distance_of_time_in_words event.start_date, Time.now %> | ||
<% elsif event.end_date.present? && event.end_date < Time.current %> | ||
O evento terminou há <%= distance_of_time_in_words event.start_date, Time.now %> | ||
<% else %> | ||
O evento já começou! Iniciado <%= distance_of_time_in_words event.start_date, Time.now %> atrás | ||
<% end %> | ||
</p> | ||
</div> | ||
|
||
<div class="flex gap-4"> | ||
<div class="h-full w-px bg-gray-300 "></div> | ||
|
||
<div class="h-full w-full flex flex-col items-center justify-center text-center"> | ||
<strong class="text-lg"><%= event.participants_count %> / <%= event.participants_limit %></strong> | ||
<p class="text-sm text-wrap">ingressos<br /> | ||
vendidos</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% elsif current_user.admin? %> | ||
<p>Dashboard Admin</p> | ||
<% end %> |
54 changes: 54 additions & 0 deletions
54
spec/system/dashboard/event_manager_views_dashboard_spec.rb
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,54 @@ | ||
require 'rails_helper' | ||
|
||
describe 'Usuário visualiza a dashboard de gerenciador de evento' do | ||
it 'e nao esta autenticado' do | ||
event_manager = create(:user) | ||
event = create(:event, status: "published", user: event_manager) | ||
create(:ticket_batch, event: event) | ||
|
||
visit dashboard_path | ||
expect(page).not_to have_content "#{event.name}" | ||
expect(current_path).to eq new_user_session_path | ||
end | ||
|
||
it 'com sucesso' do | ||
event_manager = create(:user) | ||
first_event = create(:event, status: "published", user: event_manager) | ||
create(:ticket_batch, event: first_event) | ||
|
||
second_event = create(:event, name: "Segundo Evento", status: "published", user: event_manager, categories: [ Category.first ]) | ||
create(:ticket_batch, event: second_event) | ||
create(:ticket_batch, event: second_event) | ||
|
||
third_event = create(:event, user: event_manager, categories: [ Category.first ]) | ||
create(:ticket_batch, event: third_event) | ||
|
||
event_participants_count_response = { id: 1, participants: [], sold_tickets: 2 } | ||
second_event_participants_count_response = { id: 1, participants: [], sold_tickets: 4 } | ||
allow(ParticipantsApiService).to receive(:get_participants_and_tickets_by_event_code).and_return( | ||
event_participants_count_response, | ||
second_event_participants_count_response | ||
) | ||
|
||
|
||
login_as event_manager | ||
|
||
visit root_path | ||
|
||
expect(current_path).to eq dashboard_path | ||
first_event.reload | ||
second_event.reload | ||
expect(page).to have_content "Seu lucro total na plataforma: R$ 20.000,00" | ||
within "#created-events" do | ||
expect(page).to have_content "3" | ||
expect(page).to have_content "Eventos Criados" | ||
end | ||
within "#published-events" do | ||
expect(page).to have_content "2" | ||
expect(page).to have_content "Eventos Publicados" | ||
end | ||
expect(page).to have_content "Últimos Eventos Publicados" | ||
expect(page).to have_content "#{first_event.name}" | ||
expect(page).to have_content "#{second_event.name}" | ||
end | ||
end |