Skip to content

Commit

Permalink
Revert "Feature/transaction pop up (#160)" (#161)
Browse files Browse the repository at this point in the history
This reverts commit b2ab5e5.
  • Loading branch information
LX6T authored Sep 24, 2024
1 parent afc696a commit a798556
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 81 deletions.
50 changes: 15 additions & 35 deletions frontend/src/components/Transaction.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
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(() => {
Expand All @@ -27,40 +25,22 @@ const Transaction = ({ transaction }) => {
handleSelect(transaction.id, e.target.checked);
console.log("clicked: ", transaction.id);
};

return (
<>
<div className="flex flex-row justify-start text-body pl-[8x] ">
<input className="cursor-pointer" type="checkbox" onChange={handleCheckboxChange} />

<div
className={` w-full flex flex-row justify-between text-body ml-[8px] pl-2 pr-2 rounded-2xl ${
isAmountNegative ? "text-red-500" : "text-green-500"} hover:bg-gray-300 cursor-pointer`}
onClick={() => setShowDetails(true)}>

<p>
{isAmountNegative ? convertedAmount : `+${convertedAmount}`}:{" "}
{transaction.title}
</p>

<p className="self-end">{transaction.created_at.substring(0, 10)}</p>

</div>
<div className="flex flex-row justify-start text-body pl-[8x]">
<input type="checkbox" onChange={handleCheckboxChange} />
<div
className={` w-full flex flex-row justify-between text-body pl-[8px] ${
isAmountNegative ? "text-red-500" : "text-green-500"
}`}
>
<p>
{isAmountNegative ? convertedAmount : `+${convertedAmount}`}:{" "}
{transaction.description}
</p>
<p className="self-end">{transaction.created_at.substring(0, 10)}</p>
</div>

{/*displays the currently hovered transaction in a popup*/

showDetails && (
<div className="absolute">
<TransactionDetailsPopup
transaction={transaction}
setShowDetails={setShowDetails}
/>
</div>
)
}
</>
)
</div>
);
};

export default Transaction;
46 changes: 0 additions & 46 deletions frontend/src/components/TransactionDetailPopup.jsx

This file was deleted.

0 comments on commit a798556

Please sign in to comment.