@@ -7,6 +7,8 @@ import About from "./About";
77import { getDoc , collection , setDoc , doc } from "firebase/firestore" ;
88import { firestore } from "../firebase" ;
99import Skeleton from "./Skeleton" ;
10+ import { ToastContainer , toast } from 'react-toastify' ;
11+ import 'react-toastify/dist/ReactToastify.css' ;
1012
1113export 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