From db3ac7c678c8bda66c67de37a69c0fb58887ba93 Mon Sep 17 00:00:00 2001 From: Gabe Farrell Date: Fri, 28 Apr 2023 19:49:25 +0000 Subject: [PATCH] Revert "Update ExpenseList.js" again This reverts commit 621495342df49fb517dfcb05756904d5cd128965. --- src/components/ExpenseList.js | 115 ++-------------------------------- 1 file changed, 4 insertions(+), 111 deletions(-) diff --git a/src/components/ExpenseList.js b/src/components/ExpenseList.js index 8d24154..c0ef267 100644 --- a/src/components/ExpenseList.js +++ b/src/components/ExpenseList.js @@ -9,8 +9,6 @@ const ExpenseList = () => { const [transaction, setTransactions] = useState(''); const [category, setCategories] = useState(''); const [time, setTime] = useState(''); - const [data, setData] = useState([]); - const [type, setType] = useState(''); function getSessionKey() { var cookies = document.cookie.split(';'); @@ -23,74 +21,7 @@ const ExpenseList = () => { return null; } - async function fetchData() { - - fetch('https://api.bb.gabefarrell.com/w/transactions/recent', { - method: 'GET', - headers: { - 'x-session-key': getSessionKey(), - }, - }) - .then((response) => response.json()) - .then((actualData) => { - console.log(actualData); - setData(actualData); - console.log(data); - }) - .catch((err) => { - console.log(err.message); - }); - } - - - async function getTransactionsBalance() { - try { - const response = await fetch('https://api.bb.gabefarrell.com/w/transactions/recent', { - method: 'GET', - headers: { - 'x-session-key': getSessionKey(), - }, - }); - const data = await response.json(); - let whole = data.transactions.map((item)=>item.amount.whole); - let decimal = data.transactions.map((item)=>item.amount.decimal); - let balance = []; - for (let i = 0; i < whole.length; i++) { - let expense_balance = whole[i] + '.' + decimal[i]; - balance.push(expense_balance); - } - - //console.log(whole + decimal + "<- total recent transacations"); - //console.log(whole, decimal, balance); - //const transactions_balance = whole + '.' + decimal; - //console.log(whole, decimal, category); - return balance; - } catch (error) { - console.error(error); - } - } - - async function getType() { - try { - const response = await fetch('https://api.bb.gabefarrell.com/w/transactions/recent', { - method: 'GET', - headers: { - 'x-session-key': getSessionKey(), - }, - }); - const data = await response.json(); - const type = data.transactions.map((item)=>item.type); - - - //console.log(whole + decimal + "<- total recent transacations"); - //console.log(whole, decimal, balance); - //const transactions_balance = whole + '.' + decimal; - //console.log(whole, decimal, category); - return type; - } catch (error) { - console.error(error); - } - } + async function getTransactionsBalance() { try { @@ -153,7 +84,7 @@ const ExpenseList = () => { date = new Date(timestamp[i]); month = date.getMonth(); day = date.getDay(); - //console.log(month, day); + console.log(month, day); dateFormat.push(month + '/' + day); } //let dateFormat = new Date(timestamp[0]); @@ -184,18 +115,14 @@ const ExpenseList = () => { const categories = await getTransactionsCategory(); const transaction_balance = await getTransactionsBalance(); const date = await getDate(); - const type = await getType(); setCategories(categories); - //console.log(category + "CATEGORIES"); setTransactions(transaction_balance); setTime(date); - setType(type); } useEffect(() => { fetchTransactions(); //b36efa01-7824-4f61-a274-63131b58d8fe - //fetchData(); }, []) @@ -211,42 +138,8 @@ const ExpenseList = () => {

Recent Transactions

{/*

{category}

{transaction}

*/} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
{category[0]}{transaction[0]}{type[0]}
{category[1]}{transaction[1]}{type[1]}
{category[2]}{transaction[2]}{type[2]}
{category[3]}{transaction[3]}{type[3]}
{category[4]}{transaction[4]}{type[4]}
{category[5]}{transaction[5]}{type[5]}
{category[6]}{transaction[6]}{type[6]}
+