Skip to content

Commit

Permalink
Merge pull request #4 from adnanbwp/add-item-count-to-toast
Browse files Browse the repository at this point in the history
show item count in toast
  • Loading branch information
adnanbwp authored Jun 27, 2024
2 parents 555ac7d + 198025b commit c464c5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function App() {
setItems(newItems);
saveItems(newItems);
setSelectedItem(null);
showToast('Items loaded successfully');
showToast('Items loaded successfully', 'success', newItems.length);
};

const handleSpinComplete = (item) => {
Expand Down
12 changes: 8 additions & 4 deletions src/components/Toast.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// src/components/Toast.jsx
import React, { useEffect } from 'react';

const Toast = ({ message, type, onClose }) => {
const Toast = ({ message, type, onClose, itemCount }) => {
useEffect(() => {
const timer = setTimeout(() => {
onClose();
Expand All @@ -14,9 +13,14 @@ const Toast = ({ message, type, onClose }) => {

return (
<div className={`fixed bottom-4 right-4 ${bgColor} text-white px-4 py-2 rounded shadow-lg`}>
{message}
<div>{message}</div>
{itemCount !== undefined && (
<div className="text-sm mt-1">
{itemCount} item{itemCount !== 1 ? 's' : ''} loaded
</div>
)}
</div>
);
};

export default Toast;
export default Toast;

0 comments on commit c464c5b

Please sign in to comment.