diff --git a/frontend/src/components/Transaction.jsx b/frontend/src/components/Transaction.jsx index 7ca7f85..12cdc24 100644 --- a/frontend/src/components/Transaction.jsx +++ b/frontend/src/components/Transaction.jsx @@ -1,11 +1,13 @@ import React, { useEffect, useState, useContext } from "react"; import TransactionContext from "../context/TransactionContext"; +import TransactionDetailsPopup from "../components/TransactionDetailPopup"; const Transaction = ({ transaction }) => { const [isAmountNegative, setIsAmountNegative] = useState(false); const [convertedAmount, setConvertedAmount] = useState(transaction.amount); + const [showDetails, setShowDetails] = useState(false); const { currency, convertCurrency, handleSelect } = - useContext(TransactionContext); + useContext(TransactionContext); // useEffect to check if each transaction is negative and then convert the currency useEffect(() => { @@ -25,22 +27,40 @@ const Transaction = ({ transaction }) => { handleSelect(transaction.id, e.target.checked); console.log("clicked: ", transaction.id); }; + return ( -
- -
-

- {isAmountNegative ? convertedAmount : `+${convertedAmount}`}:{" "} - {transaction.description} -

-

{transaction.created_at.substring(0, 10)}

+ <> +
+ + +
setShowDetails(true)}> + +

+ {isAmountNegative ? convertedAmount : `+${convertedAmount}`}:{" "} + {transaction.title} +

+ +

{transaction.created_at.substring(0, 10)}

+ +
-
- ); + + {/*displays the currently hovered transaction in a popup*/ + + showDetails && ( +
+ +
+ ) + } + + ) }; export default Transaction; diff --git a/frontend/src/components/TransactionDetailPopup.jsx b/frontend/src/components/TransactionDetailPopup.jsx new file mode 100644 index 0000000..1724e2f --- /dev/null +++ b/frontend/src/components/TransactionDetailPopup.jsx @@ -0,0 +1,46 @@ +import { useState, useEffect } from "react"; + +export default function TransactionDetailPopup({transaction, setShowDetails}){ + + //exits out of the current popup by setting the popup boolean to false in transaction.jsx + const handleExit =() => { + setShowDetails(false); + } + + return( + <> +
+
+ +

Transaction Details

+ +
+

Title:

+

{transaction.title}

+
+ +
+

Amount:

+

${transaction.amount}

+
+ +

Description

+ + +