Skip to content

Commit

Permalink
Merge branch 'main' into feat/download-relatorio-pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedsoupe authored Feb 6, 2024
2 parents fa973d3 + 823fe3c commit b8bebfe
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 101 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ erl_crash.dump
/.direnv/
/.nix-*/
/.postgres/
/.elixir-tools/
.elixir-tools/
.lexical/
result

# Temporary images
Expand Down
4 changes: 2 additions & 2 deletions lib/pescarte/modulo_pesquisa/models/relatorio_pesquisa.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ defmodule Pescarte.ModuloPesquisa.Models.RelatorioPesquisa do
limit_date =
case report_type do
nil -> changeset
:mensal -> Date.from_iso8601!("#{today.year}-#{today.month}-15")
_ -> Date.from_iso8601!("#{today.year}-#{today.month}-10")
:mensal -> Date.new!(today.year, today.month, 15)
_ -> Date.new!(today.year, today.month, 10)
end

put_change(changeset, :data_limite, limit_date)
Expand Down
13 changes: 10 additions & 3 deletions lib/pescarte_web/design_system.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ defmodule PescarteWeb.DesignSystem do

import Phoenix.HTML.Tag, only: [content_tag: 3]

alias PescarteWeb.DesignSystem
alias PescarteWeb.DesignSystem.SearchInput

@text_sizes ~w(h1 h2 h3 h4 h5 base lg md sm giant)
Expand Down Expand Up @@ -423,15 +424,21 @@ defmodule PescarteWeb.DesignSystem do
<!-- TODO: Use named slots to render links -->
<ul class="nav-menu">
<li class="nav-item">
<.text size="h4" color="text-blue-100">Cooperativas</.text>
<DesignSystem.link href={~p"/xx"} class="text-sm font-semibold">
<.text size="h4" color="text-blue-100">Cooperativas</.text>
</DesignSystem.link>
<Lucideicons.chevron_down class="text-blue-100" />
</li>
<li class="nav-item">
<.text size="h4" color="text-blue-100">Equipes</.text>
<DesignSystem.link href={~p"/xx"} class="text-sm font-semibold">
<.text size="h4" color="text-blue-100">Equipes</.text>
</DesignSystem.link>
<Lucideicons.chevron_down class="text-blue-100" />
</li>
<li class="nav-item">
<.text size="h4" color="text-blue-100">Quem Somos</.text>
<DesignSystem.link href={~p"/xx"} class="text-sm font-semibold">
<.text size="h4" color="text-blue-100">Quem Somos</.text>
</DesignSystem.link>
<Lucideicons.chevron_down class="text-blue-100" />
</li>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions lib/pescarte_web/design_system/authenticated_navbar.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ defmodule PescarteWeb.DesignSystem.AuthenticatedNavbar do
</DesignSystem.link>
</li>
<li class="nav-item">
<DesignSystem.link navigate={~p"/"}>
<DesignSystem.link navigate={~p"/xxxx"}>
<Lucideicons.calendar_days />
<.text :if={@open} size="base" color="text-black-60">Agenda</.text>
</DesignSystem.link>
</li>
<li class="nav-item">
<DesignSystem.link navigate={~p"/"}>
<DesignSystem.link navigate={~p"/xxx"}>
<Lucideicons.mail />
<.text :if={@open} size="base" color="text-black-60">Mensagens</.text>
</DesignSystem.link>
Expand Down
32 changes: 17 additions & 15 deletions lib/pescarte_web/live/pesquisa/relatorio_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ defmodule PescarteWeb.Pesquisa.RelatorioLive.Index do

alias Pescarte.ModuloPesquisa.Models.RelatorioPesquisa
alias Pescarte.ModuloPesquisa.Repository
alias PescarteWeb.Pesquisa.RelatorioLive.FormComponent

@impl true
def mount(_params, _session, socket) do
Expand All @@ -18,33 +19,34 @@ defmodule PescarteWeb.Pesquisa.RelatorioLive.Index do
end

@impl true
def handle_event("report-type", %{"type" => type}, socket) do
def handle_event("mensal_report", _, socket) do
pesquisador_id = socket.assigns.current_researcher.id_publico

{:noreply,
socket
|> assign(:type, type)
|> assign(:type, "mensal")
|> assign(:pesquisador_id, pesquisador_id)
|> push_patch(to: ~p"/app/pesquisa/relatorios/new")}
end

# ================= Vamos trabalhar o dropdown do "Preencher Relatório" 09-14/10/2023
@impl true
def handle_event("mensal_report", _, socket) do
{:noreply, redirect(socket, to: ~p"/app/pesquisa/pesquisadores")}
# ~p"/app/pesquisa/relatorios"
end

def handle_event("trimestral_report", _, socket) do
{:noreply, redirect(socket, to: ~p"/app/pesquisa/pesquisadores")}
end
pesquisador_id = socket.assigns.current_researcher.id_publico

def handle_event("bienal_report", _, socket) do
{:noreply, redirect(socket, to: ~p"/app/pesquisa/pesquisadores")}
{:noreply,
socket
|> assign(:type, "trimestral")
|> assign(:pesquisador_id, pesquisador_id)
|> push_patch(to: ~p"/app/pesquisa/relatorios/new")}
end

def handle_event("anual_report", _, socket) do
{:noreply, redirect(socket, to: ~p"/app/pesquisa/pesquisadores")}
pesquisador_id = socket.assigns.current_researcher.id_publico

{:noreply,
socket
|> assign(:type, "anual")
|> assign(:pesquisador_id, pesquisador_id)
|> push_patch(to: ~p"/app/pesquisa/relatorios/new")}
end

defp apply_action(socket, :edit, %{"id" => id}) do
Expand All @@ -66,7 +68,7 @@ defmodule PescarteWeb.Pesquisa.RelatorioLive.Index do
end

@impl true
def handle_info({PescarteWeb.Pesquisa.RelatorioLive.FormComponent, {:saved, relatorio}}, socket) do
def handle_info({FormComponent, {:saved, relatorio}}, socket) do
{:noreply, stream_insert(socket, :relatorios, relatorio)}
end
end
30 changes: 12 additions & 18 deletions lib/pescarte_web/live/pesquisa/relatorio_live/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,23 @@
</div>

<.table rows={@streams.relatorios} text-color="text-blue-100">
<:column :let={relatorio} label=" ">
<div class="flex-center"><.checkbox name={elem(relatorio, 0)} id="usuario" /></div>
<:column :let={_} label=" ">
<div class="flex-center"><.checkbox name="check" id="usuario" /></div>
</:column>
<:column :let={relatorio} label="Data"><%= elem(relatorio, 1).data_entrega %></:column>
<:column :let={relatorio} label="Tipo" class="linhas">
<%= elem(relatorio, 1).tipo %>
<:column :let={{_, relatorio}} label="Data">
<%= "#{relatorio.data_inicio} - #{relatorio.data_fim}" %>
</:column>
<:column :let={relatorio} label="Mês/Ano">
<%= to_string(elem(relatorio, 1).data_entrega.month) <>
" / " <> to_string(elem(relatorio, 1).data_entrega.year) %>
<:column :let={{_, relatorio}} label="Tipo" class="linhas"><%= relatorio.tipo %></:column>
<:column :let={{_, relatorio}} label="Mês/Ano">
<%= "#{relatorio.data_fim.month}/#{relatorio.data_fim.year}" %>
</:column>
<:column :let={relatorio} label="Nome">
<%= elem(relatorio, 1).pesquisador.usuario.primeiro_nome %>
</:column>
<:column :let={relatorio} label="Status"><%= elem(relatorio, 1).status %></:column>
<:column :let={relatorio} label="Baixar">
<:column :let={{_, relatorio}} label="Nome"><%= relatorio.pesquisador_id %></:column>
<:column :let={{_, relatorio}} label="Status"><%= relatorio.status %></:column>
<:column :let={{id, _}} label="Baixar">
<div class="flex-center">
<Phoenix.Component.link
href={"/app/pesquisa/relatorios/#{elem(relatorio, 0)}/download-pdf"}
target="_blank"
>
<DesignSystem.link href={~p"/app/pesquisa/relatorios/${id}/download-pdf"}>
<Lucideicons.download />
</Phoenix.Component.link>
</DesignSystem.link>
</div>
</:column>
</.table>
Expand Down
2 changes: 1 addition & 1 deletion lib/pescarte_web/templates/error_html/404.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<main class="error-grid">
<span class="error-message">
<.text size="giant" color="text-blue-100" class="uppercase">oops!</.text>
<.text size="h2" color="text-blue-100">Página não<br />encontrada</.text>
<.text size="h2" color="text-blue-100">Página em<br />construção</.text>
</span>
<img src={~p"/images/404.svg"} alt="erro404" class="error-banner" />
</main>
Expand Down
Loading

0 comments on commit b8bebfe

Please sign in to comment.