Fixed income not in budget remaining bug hopefully

main
Chris 3 years ago
parent f6cb130db8
commit 59309524ee

@ -102,7 +102,6 @@ const ExpenseList = () => {
var row = `<tr> var row = `<tr>
<td>${data1[i]}</td> <td>${data1[i]}</td>
<td>$${data2[i]}</td> <td>$${data2[i]}</td>
</tr>` </tr>`
table.innerHTML += row table.innerHTML += row
@ -110,15 +109,13 @@ const ExpenseList = () => {
} }
} }
buildTable(category, transaction, time); buildTable(category, transaction, time);
async function fetchTransactions() { async function fetchTransactions() {
const categories = await getTransactionsCategory(); const categories = await getTransactionsCategory();
const transaction_balance = await getTransactionsBalance(); const transaction_balance = await getTransactionsBalance();
const date = await getDate(); const date = await getDate();
setCategories(categories); setCategories(categories);
setTransactions(transaction_balance); setTransactions(transaction_balance);
setTime(date); setTime(date);
@ -141,7 +138,7 @@ const ExpenseList = () => {
<h4>Recent Transactions</h4> <h4>Recent Transactions</h4>
{/* <h4>{category}</h4> {/* <h4>{category}</h4>
<h4>{transaction}</h4> */} <h4>{transaction}</h4> */}
<table><tbody id="myTable"> <table class="table table-striped"><tbody id="myTable">
</tbody></table> </tbody></table>

@ -23,7 +23,7 @@ const ExpenseTotal = () => {
}, []) }, [])
return ( return (
<div className='widget'> <div className="widget">
<h5 class="textttt">This Month's Expenses:</h5> <h5 class="textttt">This Month's Expenses:</h5>
<img src={logo} class="imageee"></img> <img src={logo} class="imageee"></img>
<h1 class="displayyyy">${expense}</h1> <h1 class="displayyyy">${expense}</h1>

@ -55,14 +55,33 @@ export default function Remaining() {
console.error(error); 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() { async function fetchBudget() {
const name = await getBudget(); const name = await getBudget();
const expenses = await getMonthlyExpenses(); 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); setBudget(budget_remaining);
} }
useEffect(() => { useEffect(() => {
fetchBudget(); fetchBudget();
}, []) }, [])

@ -1,6 +1,6 @@
td { td {
padding-top: 8px; padding-top: 8px;
padding-bottom: 8px; padding-bottom: 8px;
padding-left: 50px; padding-left: 20px;
border: 1px solid; border: 1px solid;
} }
Loading…
Cancel
Save