Skip to content

Commit f07599b

Browse files
committed
Toast notification added when clicked on bttons
1 parent 863be22 commit f07599b

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed

client/package-lock.json

Lines changed: 22 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"axios": "^1.6.2",
1414
"firebase": "^10.6.0",
1515
"react": "^18.2.0",
16-
"react-dom": "^18.2.0"
16+
"react-dom": "^18.2.0",
17+
"react-toastify": "^9.1.3"
1718
},
1819
"devDependencies": {
1920
"@types/react": "^18.2.37",

client/src/components/StatsGenerator.jsx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import About from "./About";
77
import { getDoc, collection, setDoc, doc } from "firebase/firestore";
88
import { firestore } from "../firebase";
99
import Skeleton from "./Skeleton";
10+
import { ToastContainer, toast } from 'react-toastify';
11+
import 'react-toastify/dist/ReactToastify.css';
1012

1113
export default function StatsGenerator({ setShowStats }) {
1214

@@ -74,6 +76,32 @@ export default function StatsGenerator({ setShowStats }) {
7476
return transformedData;
7577
};
7678

79+
function dataThere() {
80+
toast.error('Oyee! Your profile is already there', {
81+
position: "top-center",
82+
autoClose: 2000,
83+
hideProgressBar: false,
84+
closeOnClick: true,
85+
pauseOnHover: true,
86+
draggable: true,
87+
progress: undefined,
88+
theme: "dark",
89+
});
90+
}
91+
function dataAdded() {
92+
toast.success('Bhadhai ho! Profile added successfully', {
93+
position: "top-center",
94+
autoClose: 2000,
95+
hideProgressBar: false,
96+
closeOnClick: true,
97+
pauseOnHover: true,
98+
draggable: true,
99+
progress: undefined,
100+
theme: "dark",
101+
});
102+
}
103+
104+
77105
const addData = async () => {
78106
try {
79107
const transformedUserData = transformUserData(userData);
@@ -88,15 +116,16 @@ export default function StatsGenerator({ setShowStats }) {
88116
// Add the data only if it doesn't exist
89117
await setDoc(docRef, transformedUserData);
90118
console.log("User data added to Firestore successfully!");
119+
dataAdded()
91120
} else {
92121
console.log("User data already exists in Firestore.");
122+
dataThere()
123+
93124
}
94125
}
95126
catch (err) {
96127
console.log(err);
97128
}
98-
setShowStats(false)
99-
100129
}
101130

102131
function handleInputChange(e) {
@@ -190,6 +219,18 @@ export default function StatsGenerator({ setShowStats }) {
190219
<button onClick={() => setShowStats(false)} className="mt-2">
191220
<iconify-icon icon="line-md:close-small" width="60" height="60"></iconify-icon>
192221
</button>
222+
<ToastContainer
223+
position="top-center"
224+
autoClose={2000}
225+
hideProgressBar={false}
226+
newestOnTop={false}
227+
closeOnClick
228+
rtl={false}
229+
pauseOnFocusLoss
230+
draggable
231+
pauseOnHover
232+
theme="dark"
233+
/>
193234
</div >
194235

195236
)

0 commit comments

Comments
 (0)