Uncaught TypeError: DateHelper.dataParaTexto is not a function
at NegociacoesView.js:25
at Array.map (<anonymous>)
at NegociacoesView._template (NegociacoesView.js:23)
at NegociacoesView.update (NegociacoesView.js:41)
at NegociacaoControler.adiciona (NegociacaoControler.js:20)
at HTMLFormElement.onsubmit (index.html:14)
estou tendo esse erro no console, não consigo achar o problema, seguem os codigos
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Negociações</title>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/bootstrap-theme.css">
</head>
<body class="container">
<h1 class="text-center">Negociações</h1>
<form class="form" onsubmit="negociacaoControler.adiciona(event)">
<div class="form-group">
<label for="data">Data</label>
<input type="date" id="data" class="form-control" required autofocus/>
</div>
<div class="form-group">
<label for="quantidade">Quantidade</label>
<input type="number" min="1" step="1" id="quantidade" class="form-control" value="1" required/>
</div>
<div class="form-group">
<label for="valor">Valor</label>
<input id="valor" type="number" class="form-control" min="0.01" step="0.01" value="0.0" required />
</div>
<button class="btn btn-primary" type="submit">Incluir</button>
</form>
<div class="text-center">
<button class="btn btn-primary text-center" type="button">
Importar Negociações
</button>
<button class="btn btn-primary text-center" type="button">
Apagar
</button>
</div>
<br>
<br>
<div id="negociacoesView"></div>
<script src="js/app/models/Negociacao.js"></script>
<script src="js/app/controlers/NegociacaoControler.js"></script>
<!-- codigo emet script[src="js/app/models/Negociacao.js"] e tab ao final -->
<script src="js/app/helpers/DateHelper.js"></script>
<script src="js/app/models/ListaNegociacoes.js"></script>
<script src="js/app/Views/NegociacoesView.js"></script>
<script>
let negociacaoControler = new NegociacaoControler();
</script>
</body>
</html>
class NegociacaoControler {
constructor() {
/* as tre linhas abaixo capturam o valor do input no HTML */
let $ = document.querySelector.bind(document); /* bind mantem a associacao queryselector com o document */
this._inputData = $('#data');
this._inputQuantidade = $('#quantidade');
this._inputValor = $('#valor');
this._listaNegociacoes = new ListaNegociacoes();
this._negociacoesView = new NegociacoesView($('#negociacoesView'));
this._negociacoesView.update(this._listaNegociacoes);
}
adiciona(event) {
event.preventDefault();
this._listaNegociacoes.adiciona(this._criaNegociacao());
this._negociacoesView.update(this._listaNegociacoes);
this._limpaFormulario();
}
_criaNegociacao() {
return new Negociacao(
DateHelper.textoParaData(this._inputData.value),
this._inputQuantidade.value,
this._inputValor.value);
}
_limpaFormulario() {
this._inputData.value = '';
this._inputQuantidade.value = 1;
this._inputValor.value = 0.0;
this._inputData.focus();
}
}
class NegociacoesView {
constructor(elemento) {
this._elemento = elemento;
}
_template(model) {
return `
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>DATA</th>
<th>QUANTIDADE</th>
<th>VALOR</th>
<th>VOLUME</th>
</tr>
</thead>
<tbody>
${model.negociacoes.map(n => `
<tr>
<td>${DateHelper.dataParaTexto(n.data)}</td>
<td>${n.quantidade}</td>
<td>${n.valor}</td>
<td>${n.volume}</td>
</tr>
`).join('')}
</tbody>
<tfoot>
</tfoot>
</table>
`;
}
update(model) {
this._elemento.innerHTML = this._template(model); /* innerhtml converte a string de template, se ela estiver correta, em elementos do DOM */
}
}