' amount functionlity and ui '

new_001
sonali 2024-10-08 14:22:30 +05:30
parent e50026b7a2
commit b7be589ee7
8 changed files with 36 additions and 37 deletions

View File

@ -62,7 +62,6 @@
} }
.Rupeesicon { .Rupeesicon {
width: 30px; width: 30px;
height: 30px; height: 30px;
@ -123,7 +122,9 @@
inset 2px 2px 2px #181618; inset 2px 2px 2px #181618;
} }
.coin.selected {
background: #4caf50; /* Green color for the selected coin */
}
@media (max-width: 600px) { @media (max-width: 600px) {
.amount-container { .amount-container {
padding: 10px; padding: 10px;
@ -185,9 +186,8 @@
} }
.coin:hover {
background-color: #4caf50;
}
.btn-group{ .btn-group{
justify-content: space-between; justify-content: space-between;
@ -219,6 +219,7 @@
font-size: 20px; font-size: 20px;
} }
.Rupeesicon { .Rupeesicon {
width: 30px; width: 30px;
height: 30px; height: 30px;
@ -238,6 +239,7 @@
direction: row; direction: row;
gap: 25px; gap: 25px;
} }
} }
@media (max-width: 375px) { @media (max-width: 375px) {

View File

@ -16,19 +16,23 @@ function ExpenseAmount() {
const handleCoinClick = (coinAmount) => { const handleCoinClick = (coinAmount) => {
if (isClickable) { if (isClickable) {
// Update totalAmount based on coin click
const newAmount = parseFloat(totalAmount) + coinAmount; const currentAmount = totalAmount ? parseFloat(totalAmount) : 0;
setTotalAmount(newAmount); // Update the total amount const newAmount = currentAmount + coinAmount;
setLastAddedAmount(coinAmount); // Update the last added amount
setTotalAmount(newAmount);
setLastAddedAmount(coinAmount);
setIsClickable(false); setIsClickable(false);
setTimeout(() => { setTimeout(() => {
setIsClickable(true); setIsClickable(true);
}, 500); }, 300);
} }
}; };
const handleSubtractClick = (amount) => { const handleSubtractClick = (amount) => {
if (totalAmount >= amount) { // Ensure you do not go negative if (totalAmount >= amount) {
setTotalAmount((prevAmount) => prevAmount - amount); setTotalAmount((prevAmount) => prevAmount - amount);
} }
}; };

View File

@ -26,7 +26,7 @@ function TotalExpenseAmount({ totalAmount, category, setCategory, handleManualAm
const handleAddEntry = () => { const handleAddEntry = () => {
setCategoryError(''); setCategoryError('');
// Ensure amount is a number and greater than zero
if (amount <= 0) { if (amount <= 0) {
alert('Amount is required and must be greater than zero'); alert('Amount is required and must be greater than zero');
return null; return null;

View File

@ -44,7 +44,7 @@ function ExpenseCategory() {
setCustomCategoryCount(customCategoryCount + 1); setCustomCategoryCount(customCategoryCount + 1);
localStorage.setItem('categories', JSON.stringify(updatedCategories)); localStorage.setItem('categories', JSON.stringify(updatedCategories));
alert(`Category "${newCategory}" added!`); alert(`Category "${newCategory}" added!`);
setNewCategory(''); // Clear input field after adding setNewCategory('');
} else { } else {
alert('You can only add up to three custom categories!'); alert('You can only add up to three custom categories!');
} }

View File

@ -64,12 +64,14 @@
} }
.categories ul { .categories p {
list-style-type: none; list-style-type: none;
padding: 5px; padding: 5px;
font-size: 12px;
border-bottom: 1px solid white;
} }
.categories li { .categories li {
font-size: 16px; font-size: 16px;
color: #deb1b1; color: #deb1b1;

View File

@ -87,11 +87,7 @@ function ExpenseRecords() {
<div className="categories"> <div className="categories">
<h3>Selected Categories:</h3> <h3>Selected Categories:</h3>
<ul> <p>{categories.join(', ')}</p>
{categories.map((category, index) => (
<li key={index}>{category}</li>
))}
</ul>
</div> </div>
</div> </div>

View File

@ -16,19 +16,22 @@ function AmountPage() {
const handleCoinClick = (coinAmount) => { const handleCoinClick = (coinAmount) => {
if (isClickable) { if (isClickable) {
// Update totalAmount based on coin click
const newAmount = parseFloat(totalAmount) + coinAmount; const currentAmount = totalAmount ? parseFloat(totalAmount) : 0;
setTotalAmount(newAmount); // Update the total amount const newAmount = currentAmount + coinAmount;
setLastAddedAmount(coinAmount); // Update the last added amount
setTotalAmount(newAmount);
setLastAddedAmount(coinAmount);
setIsClickable(false); setIsClickable(false);
setTimeout(() => { setTimeout(() => {
setIsClickable(true); setIsClickable(true);
}, 500); }, 300);
} }
}; };
const handleSubtractClick = (amount) => { const handleSubtractClick = (amount) => {
if (totalAmount >= amount) { // Ensure you do not go negative if (totalAmount >= amount) {
setTotalAmount((prevAmount) => prevAmount - amount); setTotalAmount((prevAmount) => prevAmount - amount);
} }
}; };

View File

@ -47,16 +47,14 @@ function Records() {
const handleBackClick = () => { const handleBackClick = () => {
navigate("/totalsuccessfully"); navigate("/totalsuccessfully");
}; };
const handleBackHomeClick = () => { const handleBackHomeClick = () => {
navigate("/") navigate("/")
} }
const handleEditClick = () => { const handleEditClick = () => {
const idToEdit = entryId || (lastEntry ? lastEntry.id : null); const idToEdit = entryId || (lastEntry ? lastEntry.id : null);
if (idToEdit) { if (idToEdit) {
navigate("/editpage", { navigate("/editPage", {
state: { state: {
id: idToEdit, id: idToEdit,
amount: entry ? entry.amount : lastEntry.amount, amount: entry ? entry.amount : lastEntry.amount,
@ -69,7 +67,6 @@ function Records() {
}; };
return ( return (
<div className="container"> <div className="container">
<div className="back_arrows"> <div className="back_arrows">
<FontAwesomeIcon <FontAwesomeIcon
@ -80,9 +77,8 @@ function Records() {
/> />
</div> </div>
<h1>Expense</h1>
<div className="success-datetime"> <div className="success-datetime">
<h1>Income</h1>
<p>{currentDateTime}</p> <p>{currentDateTime}</p>
</div> </div>
@ -91,11 +87,7 @@ function Records() {
<div className="categories"> <div className="categories">
<h3>Selected Categories:</h3> <h3>Selected Categories:</h3>
<ul> <p>{categories.join(', ')}</p>
{categories.map((category, index) => (
<li key={index}>{category}</li>
))}
</ul>
</div> </div>
</div> </div>