File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,33 @@ const Dashboard: React.FC = () => {
109109 }
110110 } ;
111111
112+ const handleStreakSet = async ( startDate : Date ) => {
113+ if ( ! currentUser ) return ;
114+
115+ try {
116+ const result = await updateStreakStart ( currentUser . uid , startDate ) ;
117+
118+ if ( result . success ) {
119+ // Refresh user data
120+ const updatedProfile = await getUserProfile ( currentUser . uid ) ;
121+
122+ if ( updatedProfile ) {
123+ setStreak ( updatedProfile . streakDays || 0 ) ;
124+ }
125+
126+ if ( result . message === 'Streak start updated successfully' ) {
127+ toast . success ( "Streak start updated!" , {
128+ description : `Your streak has been reset to start from ${ formatDate ( startDate ) } .` ,
129+ } ) ;
130+ }
131+ }
132+ } catch ( error ) {
133+ console . error ( 'Error updating streak:' , error ) ;
134+ toast . error ( "Failed to set streak start date" , {
135+ description : "Please try again later." ,
136+ } ) ;
137+ }
138+ } ;
112139
113140
114141 return (
You can’t perform that action at this time.
0 commit comments