<%- include('../../partials/header.ejs') %>
<body>
    <%- include('../../partials/navbar.ejs') %>
    <div class="container">


<form class="row g-3 mt-3" >
    <div class="col-md-12">
        <h1><span class="badge bg-secondary d-grid">Plano de Empréstimo: Cartão de Crédito</span></h1>
      </div>
      <div class="col-4">
        <label for="labelNomeCompleto" class="form-label">Nome Completo</label>
        <h4><span class="badge  bg-secondary col-md-12 text-start">Relton Lima</span></h4>
    </div>
    <div class="col-md-2">
      <label for="labelCPF" class="form-label">CPF</label>
      <h4><span class="badge  bg-secondary col-md-12 text-start">074.878.844.14</span></h4>
    </div>
    <div class="col-md-2">
      <label for="labelRG" class="form-label">RG</label>
      <h4><span class="badge  bg-secondary col-md-12 text-start">53.921.490-5</span></h4>
    </div>
    <!-- Endereço -->
    <div class="col-md-2">
      <label for="inputListaEstados" class="form-label">Estado</label>
      <h4><span class="badge  bg-secondary col-md-12 text-start">Pernambuco</span></h4>
  </div>
  <div class="col-md-2">
    <label for="inputCidade" class="form-label">Cidade</label>
    <h4><span class="badge  bg-secondary col-md-12 text-start">Recife - PE</span></h4>
</div>
<!--Fim Endereço  -->
    <!-- Dados Bancarios -->
    <div class="col-md-2">
      <label for="inputCidade" class="form-label">Agência e dígito</label>
      <h4><span class="badge  bg-secondary col-md-12 text-start">12545-0</span></h4>
  </div>
  
  <div class="col-md-2">
    <label for="inputcelularPrincipalConta" class="form-label">Conta</label>
    <h4><span class="badge  bg-secondary col-md-12 text-start">0001234-9</span></h4>
</div>
        <div class="col-md-2">
        <label for="inputListaBanco" class="form-label">Banco</label>
        <h4><span class="badge  bg-secondary col-md-12 text-start">Inter</span></h4>
    </div>
    <div class="col-md-2">
      <label for="inputTipoConta" class="form-label">Tipo de Conta</label>
      <h4><span class="badge  bg-secondary col-md-12 text-start">Corrente</span></h4>
  </div>
  <!-- FIm Dados Bancarios -->
  <!-- Parcelamento -->
  <!-- valorDoEmprestimo: number, limiteNecessario: number, status: string, parcelaMensal: number, tabelaDeCalculo: number, quantidadeDeParcelas : number  -->
    <div class="col-md-2">
        <label for="inputValorCredito" class="form-label">Valor Solicitado</label>
        <h4><span class="badge  bg-secondary col-md-12 text-start">R$ 12000,00</span></h4>
    </div>
    <div class="col-md-2">
        <label for="inputTabelaDeCalculo" class="form-label">Tabela de Cálculo</label>
        <h4><span class="badge  bg-secondary col-md-12 text-start">Tabela 1</span></h4>
    </div>
    <div class="col-md-2">
        <label for="labelParcelaMensal" class="form-label">Parcela (12x)</label>
    <h3><span id="campoValorParcelaMensal" class="badge bg-secondary col-md-12 text-start">R$ 1.134,0</span></h3>
    </div>
    <div class="col-md-2">
        <label for="labelLimiteNecessario" class="form-label">Limite Necessário</label>
        <h3><span id="limiteN" class="badge bg-secondary col-md-12 text-start">R$ 1591.52</span></h3>
    </div>
    <div class="col-md-3">
        <label for="labelValorDoEmprestimo" class="form-label">Valor a liberar</label>
        <h3><span class="badge  bg-secondary col-md-12 text-start">R$ 12.000,00</span></h3>
    </div>
    <div class="col-md-5">
      <label for="labelTaxaDeJuros" class="form-label">Calcular e Salvar Proposta</label>
      <div class="d-grid gap-2">
        <button class="btn btn-success" type="button" (click)="createProposta()">Salvar Proposta</button>
      </div></div>
    <div class="col-md-12">
    </div>

    <div class="col-md-12 padding-footer">
      <button type="button" class="btn btn-warning float-start">Recalcular</button>
      <button type="button" class="btn btn-success float-end" [routerLink]="['/enviar-proposta-para-digitar']">Enviar para Digitação</button>
    </div>
  </form>

  <script>
    
 function calculaValor(){
  const listaTabelas = [
        {label: "Tabela 1", percent: 1.99, }, {label: "Tabela 2", percent: 2.65, },
        {label: "Tabela 3", percent: 2.89, }, {label: "Tabela 4", percent: 3.19, },
        {label: "Tabela 5", percent: 3.50, }, {label: "Tabela 6", percent: 4.05, },
        {label: "Tabela 7", percent: 4.75, }, {label: "Tabela 8", percent: 5.25, },
        {label: "Tabela 9", percent: 6.25, }, {label: "Tabela 10", percent: 7.99, }
       ];

var valorDoEmprestimo = 15000.55
console.log(valorDoEmprestimo)
const tabelaDeCalculo = listaTabelas[0];

let valorSolicitado = parseFloat(valorDoEmprestimo);
let taxaDeCalculo = tabelaDeCalculo / 100;
let baseDivisor = Number;
let baseDivisorUm = (Math.pow((1 + taxaDeCalculo), 12) -1);
let baseDivisorDois = Math.pow((1 + taxaDeCalculo), 12) * taxaDeCalculo;

baseDivisor = baseDivisorUm / baseDivisorDois;
let vlrParcelaMensal = (valorSolicitado / baseDivisor)*1000;
valorParcelaMensal = parseFloat(vlrParcelaMensal.toFixed(2))
let lmtNecessario = (vlrParcelaMensal * 12);
limiteNecessario = parseFloat(lmtNecessario.toFixed(2));
valorLiberado = valorDoEmprestimo;

}
</script>
</div>
</body>
<%- include('../../partials/footer.ejs') %>