Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad-masud committed Dec 8, 2024
1 parent 0ce4769 commit 51b06e6
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 30 deletions.
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@szhsin/react-menu": "^4.2.2",
"@xyflow/react": "^12.3.5",
"axios": "^1.7.7",
"crypto-js": "^4.2.0",
"eslint-config-react-app": "^7.0.1",
"firebase": "^10.12.3",
"katex": "^0.16.11",
Expand Down
58 changes: 43 additions & 15 deletions src/content/release.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,86 @@
[
{
"date": "2024-12-05",
"comment": "Added a hierarchical view of the roadmap for easier navigation through topics."
},
{
"date": "2024-12-04",
"comment": "Improved user experience by securely saving preferences and progress for faster loading."
},
{
"date": "2024-12-03",
"comment": "Introduced a personalized dashboard to track completed lessons and quizzes."
},
{
"date": "2024-11-20",
"comment": "Enhanced quiz feedback with explanations for correct and incorrect answers."
},
{
"date": "2024-11-13",
"comment": "Added quizzes for each lesson topic in the lessons page"
"comment": "Added quizzes for each lesson topic to make learning more interactive and engaging."
},
{
"date": "2024-11-05",
"comment": "Launched progress streaks to encourage consistent learning."
},
{
"date": "2024-10-19",
"comment": "Merged algorithms and data structures into a roadmap along with lessons for each topic"
"comment": "Combined data structures and algorithms into a single roadmap for a seamless learning journey."
},
{
"date": "2024-10-17",
"comment": "Added Lessons for data structures and algorithms"
"comment": "Launched guided lessons for key programming topics to help users learn effectively."
},
{
"date": "2024-10-10",
"comment": "Added premium subcriptions"
"comment": "Introduced premium subscriptions with exclusive features and priority support."
},
{
"date": "2024-09-30",
"comment": "Added weekly challenges to help users stay motivated and track their progress."
},
{
"date": "2024-09-26",
"comment": "Added code solutions"
"comment": "Provided detailed code solutions to popular coding problems for better understanding."
},
{
"date": "2024-09-24",
"comment": "Updated entire webpage ui"
"comment": "Redesigned the website for a cleaner look and easier navigation."
},
{
"date": "2024-08-24",
"comment": "Modified concepts page to seperate ds and algos pages and misc concepts"
"comment": "Separated data structures, algorithms, and other concepts for a more focused learning experience."
},
{
"date": "2024-08-22",
"comment": "Added concepts page, to practice important dsa concepts"
"comment": "Introduced a concepts page to practice essential programming techniques."
},
{
"date": "2024-07-25",
"comment": "Added progress tracking to help users monitor their learning journey."
},
{
"date": "2024-07-11",
"comment": "Added home page, that includes release notes"
"comment": "Launched a home page with release notes to keep users updated on new features."
},
{
"date": "2024-07-11",
"comment": "Implemented google authentication to save completed user problems in the cloud"
"comment": "Enabled account synchronization using Google authentication."
},
{
"date": "2024-07-10",
"comment": "Implemented local storage to handle dark mode, light mode and auto color mode"
"comment": "Introduced customizable themes, including dark mode, light mode, and system default."
},
{
"date": "2024-07-10",
"comment": "Added problems page for tracking all problems found for each corresponding company"
"comment": "Added a problems page to explore questions by companies and topics."
},
{
"date": "2024-07-09",
"comment": "Added most popular companies's LeetCode questions including their difficulties, frequencies, and acceptance rate"
"comment": "Curated popular coding problems from top tech companies."
},
{
"date": "2024-07-09",
"comment": "Initial release"
"comment": "Initial release of the platform."
}
]
]
13 changes: 10 additions & 3 deletions src/context/themecontext.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { useUser } from "../context/usercontext";
const ThemeContext = createContext();

export const ThemeProvider = ({ children }) => {
const [theme, setTheme] = useState("system");
const [theme, setTheme] = useState(() => {
return localStorage.getItem("theme") || "system";
});
const { user } = useUser();

useEffect(() => {
Expand All @@ -16,7 +18,9 @@ export const ThemeProvider = ({ children }) => {
.then((docSnap) => {
if (docSnap.exists()) {
const userData = docSnap.data();
setTheme(userData.theme || "system");
const userTheme = userData.theme || "system";
setTheme(userTheme);
localStorage.setItem("theme", userTheme);
}
})
.catch((error) => {
Expand All @@ -34,6 +38,8 @@ export const ThemeProvider = ({ children }) => {
} else {
document.querySelector(":root").className = theme;
}

localStorage.setItem("theme", theme);
}, [theme]);

const changeTheme = (newTheme) => {
Expand All @@ -44,6 +50,7 @@ export const ThemeProvider = ({ children }) => {
console.error("Error updating theme:", error);
});
}
localStorage.setItem("theme", newTheme);
};

return (
Expand All @@ -53,4 +60,4 @@ export const ThemeProvider = ({ children }) => {
);
};

export const useTheme = () => useContext(ThemeContext);
export const useTheme = () => useContext(ThemeContext);
62 changes: 50 additions & 12 deletions src/context/usercontext.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,43 @@
import React, { createContext, useState, useContext, useEffect } from "react";
import { doc, getDoc } from "firebase/firestore";
import { firestore } from "../config/firebase-config";
import CryptoJS from "crypto-js";

const UserContext = createContext();

const ENCRYPTION_KEY = process.env.REACT_APP_USER_ENCRYPTION_KEY || "default_key";

const encryptData = (data) => {
return CryptoJS.AES.encrypt(JSON.stringify(data), ENCRYPTION_KEY).toString();
};

const decryptData = (encryptedData) => {
try {
const bytes = CryptoJS.AES.decrypt(encryptedData, ENCRYPTION_KEY);
return JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
} catch (error) {
console.error("Error decrypting data:", error);
return null;
}
};

export const UserProvider = ({ children }) => {
const [user, setUser] = useState(null);
const [premiumInfo, setPremiumInfo] = useState({
premium: false,
subscriptionId: "",
canceled: false,
customerId: "",
subscriptionEnd: null,
const [user, setUser] = useState(() => {
const cachedUser = localStorage.getItem("user");
return cachedUser ? decryptData(cachedUser) : null;
});

const [premiumInfo, setPremiumInfo] = useState(() => {
const cachedPremiumInfo = localStorage.getItem("premiumInfo");
return cachedPremiumInfo
? decryptData(cachedPremiumInfo)
: {
premium: false,
subscriptionId: "",
canceled: false,
customerId: "",
subscriptionEnd: null,
};
});

useEffect(() => {
Expand All @@ -22,27 +48,39 @@ export const UserProvider = ({ children }) => {
if (docSnap.exists()) {
const userData = docSnap.data();
if (userData.premiumInfo) {
setPremiumInfo({
const updatedPremiumInfo = {
premium: userData.premiumInfo.premium || false,
subscriptionId: userData.premiumInfo.subscriptionId || "",
canceled: userData.premiumInfo.canceled || false,
customerId: userData.premiumInfo.stripeCustomerId || "",
subscriptionEnd: userData.premiumInfo.subscriptionEnd || null,
});
};
setPremiumInfo(updatedPremiumInfo);
localStorage.setItem("premiumInfo", encryptData(updatedPremiumInfo));
}
}
})
.catch((error) => {
console.error("Error fetching user data: ", error);
});
} else {
setPremiumInfo({
const defaultPremiumInfo = {
premium: false,
subscriptionId: "",
canceled: false,
customerId: "",
subscriptionEnd: null,
});
};
setPremiumInfo(defaultPremiumInfo);
localStorage.removeItem("premiumInfo");
}
}, [user]);

useEffect(() => {
if (user) {
localStorage.setItem("user", encryptData(user));
} else {
localStorage.removeItem("user");
}
}, [user]);

Expand All @@ -53,4 +91,4 @@ export const UserProvider = ({ children }) => {
);
};

export const useUser = () => useContext(UserContext);
export const useUser = () => useContext(UserContext);

0 comments on commit 51b06e6

Please # to comment.