Skip to content

Commit

Permalink
update columns tableLoan
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarrill0 committed Jul 24, 2021
1 parent 1159a4a commit 29e654d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 26 deletions.
5 changes: 3 additions & 2 deletions src/components/Footer/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ function Footer(props) {
</nav>
<div className="credits ml-auto">
<div className="copyright">
&copy; {new Date().getFullYear()}, made with
<i className="fa fa-heart heart ml-1" /> by Creative Tim
&copy; {new Date().getFullYear()}, Derechos reservados
{/* , made with
<i className="fa fa-heart heart ml-1" /> by Creative Tim */}
</div>
</div>
</Row>
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const getDateOfPayments = (date, days) => {
// montoTotal: 21626.88,
// montoCuota: 5406.72

export const loanCalculate = (montoCredito, interes, numCuotas) => ({
export const loanCalculate = (montoCredito, interes, numCuotas = 0) => ({
getAmountInteres: function() {
return (montoCredito * interes) / 100
},
Expand Down
61 changes: 38 additions & 23 deletions src/views/LoansTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ModalLoan } from 'components/Modal/ModalLoan';
import { useModal } from 'hooks/useModal'
import CalcForm from 'components/Forms/CalcForm';
import { styles } from './styles/styles'
import { loanCalculate } from '../helpers/helpers'


const LoansTable = () => {
Expand All @@ -19,7 +20,7 @@ const LoansTable = () => {
const loadLoans = useLoanStore(state => state.getAllLoans)
const loanList = useLoanStore(state => state.loanList)

const [listLoan] = useState(loans)
// const [listLoan] = useState(loans)

const { modal, toggle } = useModal()

Expand All @@ -28,12 +29,9 @@ const LoansTable = () => {
loadLoans()
}, [loadLoans, loadCustomers])

if(loanList.length === 0) { console.log("Lista de prestamos vacía") }
if(customerList.length > 0) { console.log(customerList) }

const columns = [
{
dataField: "codigo",
dataField: "id",
text: "N° Prestamo",
sort: true,
// headerStyle: styles.headerStyle,
Expand All @@ -45,49 +43,66 @@ const LoansTable = () => {
sort: true,
style: styles.columnStyle,
formatter: cell => {
const customer = customers.find(item => item.id === cell)

let customer = customers.find(item => item.id === cell)
return (
<span>{`${customer.firstName} ${customer.lastName}`}</span>
);
}
},
{
dataField: "fechaPrestamo",
text: "Fecha Préstamo",
dataField: "montoCredito",
text: "M. crédito",
headerAlign: 'center',
headerStyle: styles.headerStyle,
style: styles.columnStyle
},
{
dataField: "montoCredito",
text: "Monto Crédito",
dataField: "interes",
isDummyField: true,
text: "M. interés",
headerAlign: 'center',
headerStyle: styles.headerStyle,
style: styles.columnStyle
style: styles.columnStyle,
formatter: (cell, {montoCredito, interes}) => {
const { getAmountInteres } = loanCalculate(montoCredito, interes)
return (
<span>{getAmountInteres()}</span>
);
}
},
// {
// dataField: "montoTotal",
// text: "Monto Total",
// style: styles.columnStyle
// },
{
dataField: "interes",
text: "Interés",
dataField: "montoTotal",
isDummyField: true,
text: "M. total",
headerAlign: 'center',
headerStyle: styles.headerStyle,
style: styles.columnStyle,
formatter: (cell, row) => {
formatter: (cell, {montoCredito, interes}) => {
const { getAmountTotal } = loanCalculate(montoCredito, interes)
return (
<span>{cell}%</span>
<span>{getAmountTotal()}</span>
);
}
},
{
dataField: "cuotas",
text: "Cuotas",
dataField: "fechaPrestamo",
text: "F. Préstamo",
headerAlign: 'center',
headerStyle: styles.headerStyle,
style: styles.columnStyle
},
{
dataField: "estado",
text: "Estado",
headerStyle: styles.headerStyle,
style: styles.columnStyle
},
// {
// dataField: "cuotas",
// text: "Cuotas",
// headerStyle: styles.headerStyle,
// style: styles.columnStyle
// },
{
dataField: "action",
isDummyField: true,
Expand Down

0 comments on commit 29e654d

Please sign in to comment.