monthly budget analysis page
This commit is contained in:
parent
3338586605
commit
ce2c163abe
2 changed files with 72 additions and 0 deletions
32
app/static/budget_monthly_analysis.js
Normal file
32
app/static/budget_monthly_analysis.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
const monthSelector = document.getElementById('month-selector');
|
||||
const tableBody = document.getElementById('table-body');
|
||||
|
||||
|
||||
|
||||
async function displayMonthLineItems(dateString){
|
||||
const [month, year] = dateString.split(' ');
|
||||
var result = await fetch(`/get_budget_details_for_month/${month}/${year}`, {method:'POST'});
|
||||
var data = await result.json();
|
||||
tableBody.innerHTML = ''
|
||||
data.forEach(budget_category => {
|
||||
const row = `
|
||||
<tr id="${budget_category.id}-row">
|
||||
<th scope="row">${budget_category.id}</th>
|
||||
<th scope="row">${budget_category.name}</th>
|
||||
<th scope="row">${budget_category.month_cost}</th>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
// Insert the row into the table body
|
||||
tableBody.insertAdjacentHTML('beforeend', row);
|
||||
|
||||
});
|
||||
addListenersToReassignButtons();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", (event) => {
|
||||
displayMonthLineItems(monthSelector.value);
|
||||
monthSelector.addEventListener('change', (e) => {
|
||||
displayMonthLineItems(e.target.value);
|
||||
})
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue