-
Notifications
You must be signed in to change notification settings - Fork 2
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 #2404 from prefeiturasp/feature/33155-parametrizac…
…oes-repasses Feature/33155 parametrizacoes repasses
- Loading branch information
Showing
20 changed files
with
1,276 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
5 changes: 5 additions & 0 deletions
5
src/componentes/sme/Parametrizacoes/Receitas/ParametrizacoesRepasses/UrlsMenuInterno.js
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,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 | ||
]; |
100 changes: 100 additions & 0 deletions
100
...me/Parametrizacoes/Receitas/ParametrizacoesRepasses/components/AutoCompleteAssociacoes.js
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,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) |
138 changes: 138 additions & 0 deletions
138
src/componentes/sme/Parametrizacoes/Receitas/ParametrizacoesRepasses/components/Filtros.js
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,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> | ||
</> | ||
) | ||
} |
Oops, something went wrong.