Skip to content

Commit

Permalink
Merge pull request #2404 from prefeiturasp/feature/33155-parametrizac…
Browse files Browse the repository at this point in the history
…oes-repasses

Feature/33155 parametrizacoes repasses
  • Loading branch information
Lucas-Santos-Rocha-dev authored May 13, 2024
2 parents e2e7cb7 + 5d584af commit e46857a
Show file tree
Hide file tree
Showing 20 changed files with 1,276 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/assets/img/icone-parametro-repasses.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/componentes/sme/PainelParametrizacoes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import IconeUsuarios from "../../../assets/img/icone-parametro-usuarios.svg"
import IconeTextosFiqueDeOlho from "../../../assets/img/icone-parametro-textos-fique-de-olho.svg"
import IconeFornecedores from "../../../assets/img/icone-parametro-fornecedores.svg"
import IconeMandato from "../../../assets/img/icone-parametro-periodos-de-mandato.svg"
import IconeRepasses from "../../../assets/img/icone-parametro-repasses.svg"

export const PainelParametrizacoes = () => {

Expand Down Expand Up @@ -123,6 +124,12 @@ export const PainelParametrizacoes = () => {
url: 'parametro-motivos-estorno',
icone: IconeTiposConta,
permissoes: ['access_painel_parametrizacoes', 'change_painel_parametrizacoes'],
},
{
parametro: 'Repasses',
url: 'parametro-repasse',
icone: IconeRepasses,
permissoes: ['access_painel_parametrizacoes', 'change_painel_parametrizacoes'],
}
];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const UrlsMenuInterno = [
{label: "Repasses", url: "parametro-repasse"},
{label: "Carga de repasses previstos", url: 'parametro-arquivos-de-carga', origem:'REPASSE_PREVISTO'}, // Alterar url e origem
{label: "Carga de repasses realizados", url: 'parametro-arquivos-de-carga', origem:'REPASSE_REALIZADO'}, // Alterar url e origem
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import React, {useState, memo} from 'react';
import {AutoComplete} from 'primereact/autocomplete';
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import {faSearch} from "@fortawesome/free-solid-svg-icons";
import { Tag } from '../../../../../Globais/Tag';
import { useContext } from "react";
import { RepassesContext } from "../context/Repasse";


const AutoCompleteAssociacoes = ({todasAsAssociacoesAutoComplete, setFieldValue, disabled = false, loadingAssociacoes = false}) => {
const [selectedAssociacao, setSelectedAssociacao] = useState(null);
const [filteredAssociacoes, setFilteredAssociacoes] = useState(null);
const {stateFormModal, setStateFormModal} = useContext(RepassesContext)


const searchAssociacao = (event) => {
setTimeout(() => {
let filteredAssociacoes;
if (!event.query.trim().length) {
filteredAssociacoes = [...todasAsAssociacoesAutoComplete];
} else {
filteredAssociacoes = todasAsAssociacoesAutoComplete.filter((associacao) => {
return associacao.unidade.nome_com_tipo.toLowerCase().includes(event.query.toLowerCase())
})
}
setFilteredAssociacoes(filteredAssociacoes);
}, 250);
}

const itemTemplate = (item) => {
if(item.encerrada) {
return (
<div className='d-flex' style={{opacity: 0.6}}>
<span className='mr-3'>{item.unidade.nome_com_tipo}</span>
<Tag label='Associação encerrada'/>
</div>
)
} else {
return item.unidade.nome_com_tipo;
}
};

const handleChange = (e) => {
if(e.value.encerrada){
setSelectedAssociacao(null)
} else {
setSelectedAssociacao(e.value)
}
};

const handleSelect = (e) => {
if(e.value.encerrada){
setFieldValue("associacao", "")

setStateFormModal({
...stateFormModal,
associacao: ""
})
} else {
setFieldValue("associacao", e.value.uuid)

setStateFormModal({
...stateFormModal,
associacao: e.value.uuid
})
}
};

return (
<div className="d-flex bd-highlight">
<div className="flex-grow-1 bd-highlight">
<AutoComplete
value={selectedAssociacao}
name='associacao'
inputId='associacao'
suggestions={filteredAssociacoes}
completeMethod={searchAssociacao}
field="unidade.nome_com_tipo"
onChange={handleChange}
inputClassName="form-control"
onSelect={handleSelect}
style={{width: "100%", borderLeft:'none'}}
itemTemplate={itemTemplate}
disabled={disabled || loadingAssociacoes}
placeholder={`${loadingAssociacoes ? "Carregando unidades" : ""}`}
/>
</div>
<div className="bd-highlight ml-0 py-1 px-3 ml-n3 border-top border-right border-bottom">

<FontAwesomeIcon
style={{fontSize: '18px', marginRight: "0", color: "#42474A"}}
icon={faSearch}
/>

</div>
</div>
)
};

export default memo(AutoCompleteAssociacoes)
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import React, {useContext, useState} from "react";
import { RepassesContext } from "../context/Repasse";
import { useGetTabelasRepasse } from "../hooks/useGetTabelasRepasse";

export const Filtros = () => {
const {setFilter, initialFilter, setCurrentPage, setFirstPage} = useContext(RepassesContext);
const [formFilter, setFormFilter] = useState(initialFilter);

const { data: tabelas } = useGetTabelasRepasse();

const handleChangeFormFilter = (name, value) => {
setFormFilter({
...formFilter,
[name]: value
});
};

const handleSubmitFormFilter = () => {
setCurrentPage(1)
setFirstPage(0)
setFilter(formFilter);
};

const clearFilter = () => {
setCurrentPage(1)
setFirstPage(0)
setFormFilter(initialFilter);
setFilter(initialFilter);
};

return (
<>
<form>
<div className="form-row">
<div className="form-group col-md-8">
<label htmlFor="search">Filtrar por associação / Unidade educacional</label>
<input
value={formFilter.search}
onChange={(e) => handleChangeFormFilter(e.target.name, e.target.value)}
name='search'
id="search"
type="text"
className="form-control"
placeholder='Escreva o nome da associação'
/>
</div>

<div className="form-group col-md-4">
<label htmlFor="periodo">Filtrar por período</label>
<select
value={formFilter.periodo}
onChange={(e) => handleChangeFormFilter(e.target.name, e.target.value)}
name="periodo"
id="periodo"
className="form-control"
>
<option value="">Selecione o período</option>
{tabelas && tabelas.periodos && tabelas.periodos.map((periodo)=>
<option key={periodo.uuid} value={periodo.uuid}>{periodo.referencia}</option>
)}
</select>
</div>
</div>

<div className="form-row">
<div className="form-group col-md-3">
<label htmlFor="conta">Filtrar por conta</label>
<select
value={formFilter.conta}
onChange={(e) => handleChangeFormFilter(e.target.name, e.target.value)}
name="conta"
id="conta"
className="form-control"
>
<option value="">Selecione a conta</option>
{tabelas && tabelas.tipos_contas && tabelas.tipos_contas.map((tipo_conta)=>
<option key={tipo_conta.uuid} value={tipo_conta.uuid}>{tipo_conta.nome}</option>
)}
</select>
</div>

<div className="form-group col-md-3">
<label htmlFor="acao">Filtrar por ação</label>
<select
value={formFilter.acao}
onChange={(e) => handleChangeFormFilter(e.target.name, e.target.value)}
name="acao"
id="acao"
className="form-control"
>
<option value="">Selecione a ação</option>
{tabelas && tabelas.acoes && tabelas.acoes.map((acao)=>
<option key={acao.uuid} value={acao.uuid}>{acao.nome}</option>
)}
</select>
</div>

<div className="form-group col-md-3">
<label htmlFor="status">Filtrar por status</label>
<select
value={formFilter.status}
onChange={(e) => handleChangeFormFilter(e.target.name, e.target.value)}
name="status"
id="status"
className="form-control"
>
<option value="">Selecione o status</option>
{tabelas && tabelas.status && tabelas.status.map((status)=>
<option key={status.id} value={status.id}>{status.nome}</option>
)}
</select>
</div>

<div className="from-group col-md-3">
<div className="d-flex bd-highlight justify-content-end mt-4">
<button
onClick={clearFilter}
type="button"
className="btn btn-outline-success mt-2 mr-2"
>
Limpar
</button>

<button
onClick={handleSubmitFormFilter}
type="button"
className="btn btn-success mt-2"
>
Filtrar
</button>
</div>

</div>
</div>
</form>
</>
)
}
Loading

0 comments on commit e46857a

Please sign in to comment.