mirror of
https://github.com/gabehf/BudgetBuddy.git
synced 2026-03-07 21:48:14 -08:00
Fixed income not in budget remaining bug hopefully
This commit is contained in:
parent
f6cb130db8
commit
59309524ee
4 changed files with 25 additions and 9 deletions
|
|
@ -102,7 +102,6 @@ const ExpenseList = () => {
|
|||
var row = `<tr>
|
||||
<td>${data1[i]}</td>
|
||||
<td>$${data2[i]}</td>
|
||||
|
||||
</tr>`
|
||||
table.innerHTML += row
|
||||
|
||||
|
|
@ -110,14 +109,12 @@ const ExpenseList = () => {
|
|||
}
|
||||
}
|
||||
|
||||
buildTable(category, transaction, time);
|
||||
buildTable(category, transaction, time);
|
||||
|
||||
async function fetchTransactions() {
|
||||
const categories = await getTransactionsCategory();
|
||||
const transaction_balance = await getTransactionsBalance();
|
||||
const date = await getDate();
|
||||
|
||||
|
||||
|
||||
setCategories(categories);
|
||||
setTransactions(transaction_balance);
|
||||
|
|
@ -141,7 +138,7 @@ const ExpenseList = () => {
|
|||
<h4>Recent Transactions</h4>
|
||||
{/* <h4>{category}</h4>
|
||||
<h4>{transaction}</h4> */}
|
||||
<table><tbody id="myTable">
|
||||
<table class="table table-striped"><tbody id="myTable">
|
||||
|
||||
</tbody></table>
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ const ExpenseTotal = () => {
|
|||
}, [])
|
||||
|
||||
return (
|
||||
<div className='widget'>
|
||||
<div className="widget">
|
||||
<h5 class="textttt">This Month's Expenses:</h5>
|
||||
<img src={logo} class="imageee"></img>
|
||||
<h1 class="displayyyy">${expense}</h1>
|
||||
|
|
|
|||
|
|
@ -55,14 +55,33 @@ export default function Remaining() {
|
|||
console.error(error);
|
||||
}
|
||||
}
|
||||
async function getIncome() {
|
||||
try {
|
||||
const response = await fetch('https://api.bb.gabefarrell.com/w/income/month', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'x-session-key': getSessionKey(),
|
||||
},
|
||||
});
|
||||
const data = await response.json();
|
||||
const whole = data.whole;
|
||||
const decimal = data.decimal;
|
||||
const total_expenses = whole + '.' + decimal;
|
||||
console.log(total_expenses + "<- Income By Month");
|
||||
return Number(total_expenses);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
async function fetchBudget() {
|
||||
const name = await getBudget();
|
||||
const expenses = await getMonthlyExpenses();
|
||||
const budget_remaining = (name - expenses).toFixed(2);
|
||||
|
||||
const income = await getIncome();
|
||||
const budget_remaining = (name - expenses + income).toFixed(2);
|
||||
setBudget(budget_remaining);
|
||||
}
|
||||
useEffect(() => {
|
||||
|
||||
fetchBudget();
|
||||
}, [])
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
td {
|
||||
padding-top: 8px;
|
||||
padding-bottom: 8px;
|
||||
padding-left: 50px;
|
||||
padding-left: 20px;
|
||||
border: 1px solid;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue