-
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.
- Loading branch information
Showing
54 changed files
with
3,092 additions
and
974 deletions.
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
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
132 changes: 132 additions & 0 deletions
132
src/componentes/Associacao/DadosDasContas/FormDadosDasContas/index.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,132 @@ | ||
import React from "react"; | ||
import {Formik, FieldArray} from "formik"; | ||
|
||
export const FormDadosDasContas = ({intialValues, setaCampoReadonly, validateFormDadosDasContas, onSubmit}) => { | ||
const valores_inciais = { | ||
contas: intialValues | ||
}; | ||
return ( | ||
<> | ||
<Formik | ||
initialValues={valores_inciais} | ||
validate={validateFormDadosDasContas} | ||
enableReinitialize={true} | ||
validateOnBlur={true} | ||
onSubmit={onSubmit} | ||
> | ||
{props => { | ||
const { | ||
values, | ||
} = props; | ||
|
||
return ( | ||
<form onSubmit={props.handleSubmit}> | ||
<FieldArray | ||
name="contas" | ||
render={() => ( | ||
<> | ||
{values.contas && values.contas.length > 0 && values.contas.map((conta, index) => { | ||
return ( | ||
<div className="row" key={index}> | ||
<div className={`col-12 mt-${index === 0 ? "2" : 4} mb-4 ml-0`}> | ||
<p className="mb-0"> | ||
<strong>Conta {index + 1}</strong> | ||
</p> | ||
<hr className="mt-0 mb-1"/> | ||
</div> | ||
<div className='col-12 col-md-3'> | ||
<div className="form-group"> | ||
<label htmlFor="banco_nome">Banco</label> | ||
<input | ||
readOnly={setaCampoReadonly(conta.tipo_conta.nome)} | ||
name={`contas[${index}].banco_nome`} | ||
value={conta.banco_nome} | ||
onChange={(e) => { | ||
props.handleChange(e); | ||
} | ||
} | ||
type="text" | ||
className="form-control" | ||
/> | ||
{props.errors.banco_nome && <span className="text-danger mt-1">{props.errors.banco_nome}</span>} | ||
</div> | ||
</div> | ||
|
||
<div className='col-12 col-md-3'> | ||
<div className="form-group"> | ||
<label htmlFor="tipo_conta">Tipo de Conta</label> | ||
<input | ||
readOnly={true} | ||
name={`contas[${index}].tipo_conta`} | ||
value={conta.tipo_conta && conta.tipo_conta.nome ? conta.tipo_conta.nome : ""} | ||
onChange={(e) => { | ||
props.handleChange(e); | ||
} | ||
} | ||
type="text" | ||
className="form-control" | ||
/> | ||
{props.errors.tipo_conta && <span className="text-danger mt-1">{props.errors.tipo_conta}</span>} | ||
</div> | ||
</div> | ||
|
||
<div className='col-12 col-md-3'> | ||
<div className="form-group"> | ||
<label htmlFor="agencia">Agência {setaCampoReadonly(conta.tipo_conta.nome) ? 'do programa' : ""}</label> | ||
<input | ||
readOnly={setaCampoReadonly(conta.tipo_conta.nome)} | ||
name={`contas[${index}].agencia`} | ||
value={conta.agencia} | ||
onChange={(e) => { | ||
props.handleChange(e); | ||
} | ||
} | ||
type="text" | ||
className="form-control" | ||
/> | ||
{props.errors.agencia && <span className="text-danger mt-1">{props.errors.agencia}</span>} | ||
</div> | ||
</div> | ||
|
||
<div className='col-12 col-md-3'> | ||
<div className="form-group"> | ||
<label htmlFor="numero_conta">Nº da conta com o dígito {setaCampoReadonly(conta.tipo_conta.nome) ? 'do programa' : ""}</label> | ||
<input | ||
readOnly={setaCampoReadonly(conta.tipo_conta.nome)} | ||
name={`contas[${index}].numero_conta`} | ||
value={conta.numero_conta} | ||
onChange={(e) => { | ||
props.handleChange(e); | ||
} | ||
} | ||
type="text" | ||
className="form-control" | ||
/> | ||
{props.errors.numero_conta && <span className="text-danger mt-1">{props.errors.numero_conta}</span>} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
})} | ||
{props.errors.campos_obrigatorios && | ||
<div className="col-12 mt-2"> | ||
<span className="text-danger"> {props.errors.campos_obrigatorios}</span> | ||
</div> | ||
} | ||
</> | ||
)} | ||
> | ||
</FieldArray> | ||
|
||
<div className="d-flex justify-content-end pb-3 mt-3"> | ||
<button onClick={props.handleReset} type="button" className="btn btn btn-outline-success mt-2 mr-2">Cancelar</button> | ||
<button type="submit" className="btn btn-success mt-2">Salvar</button> | ||
</div> | ||
|
||
</form> | ||
) | ||
}} | ||
</Formik> | ||
</> | ||
) | ||
}; |
Oops, something went wrong.