Skip to content

Commit

Permalink
set initial streak value to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
NancyAanchal committed Jul 23, 2024
1 parent 5d67233 commit 9d96d4a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion nepalingo-web/src/components/header/StreakPhrase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface StreakPhrase {
}

const phrases = [
{ min: 1, max: 5, text: "Starting strong! Keep going!" },
{ min: 0, max: 5, text: "Starting strong! Keep going!" },
{ min: 6, max: 10, text: "On a roll! Nice job!" },
{ min: 11, max: 20, text: "Heating up! As hot as a chilly!" },
{ min: 21, max: 30, text: "Crushing it! Unstoppable!" },
Expand Down
9 changes: 4 additions & 5 deletions nepalingo-web/src/hooks/StreakContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {
import {
createContext,
useContext,
useState,
Expand Down Expand Up @@ -60,8 +60,8 @@ export const StreakProvider = ({ children }: { children: ReactNode }) => {
const currentDate = new Date().toISOString().split("T")[0]; // Get current date

if (user) {
let newStreak = 1;
let newLongestStreak = 1;
let newStreak = 0;
let newLongestStreak = 0;

if (data?.streak_end_date) {
const lastDate = new Date(data.streak_end_date)
Expand All @@ -81,7 +81,6 @@ export const StreakProvider = ({ children }: { children: ReactNode }) => {
}

// Update state

// Upsert database
const { error } = await supabaseClient
.from("user_daily_streaks")
Expand All @@ -95,7 +94,7 @@ export const StreakProvider = ({ children }: { children: ReactNode }) => {
longest_streak: newLongestStreak,
created_at: new Date().toISOString(),
},
{ onConflict: "user_id" },
{ onConflict: "user_id" }
)
.select();

Expand Down
1 change: 0 additions & 1 deletion nepalingo-web/src/pages/FlashcardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const FlashcardPage: React.FC = () => {

useEffect(() => {
updateStreak(); // Trigger streak update on flashcard page load
console.log("Updated Streak");
}, []);

return (
Expand Down

0 comments on commit 9d96d4a

Please sign in to comment.