From ffff7efaccd9efe885ac8e3e9516fd429e4559ec Mon Sep 17 00:00:00 2001 From: emmamelkumian <147114444+emmamelkumian@users.noreply.github.com> Date: Fri, 13 Jun 2025 21:46:17 -0700 Subject: [PATCH 01/16] settings JSDOC comments --- .../components/client/settings/settings.jsx | 99 +++++++++++++++---- 1 file changed, 78 insertions(+), 21 deletions(-) diff --git a/frontend/src/components/client/settings/settings.jsx b/frontend/src/components/client/settings/settings.jsx index fd09261..0e9898c 100644 --- a/frontend/src/components/client/settings/settings.jsx +++ b/frontend/src/components/client/settings/settings.jsx @@ -2,6 +2,17 @@ import { useEffect, useState } from "react"; import { baseUrl } from "../../../emails/emailHandler"; import "./settings.css"; +/** + * Settings component for managing user preferences + * @param {Object} param0 - Component props + * @param {boolean} param0.isChecked - Indicates whether summaries are enabled + * @param {function} param0.handleToggleSummariesInInbox - Callback to toggle summaries + * @param {number} param0.emailFetchInterval - Current email fetch interval + * @param {function} param0.handleSetEmailFetchInterval - Callback to set email fetch interval + * @param {string} param0.theme - Current theme + * @param {function} param0.handleSetTheme - Callback to set theme + * @returns {JSX.Element} + */ export function Settings({ isChecked, handleToggleSummariesInInbox, @@ -15,10 +26,15 @@ export function Settings({ window.location.href = "/login"; }; - const handleDeleteAccount = async() => { - //confirm if the user wants to delete their account + /** + * Deletes the user account after confirmation, removes all user info from the database, + * and redirects to the login page. + * @async + * @returns {Promise} + */ + const handleDeleteAccount = async () => { if (!window.confirm("Are you sure you want to delete your EmailEssence Account? \nThis will remove all information associated with your gmail account from our server and lead to longer loading times when you log back in next time.")) return; - try{ + try { const profile = await fetchUserProfile(); const userId = profile.google_id await deleteUserById(userId); @@ -31,8 +47,14 @@ export function Settings({ }; } + + /** + * Custom hook to detect system theme preference + * This hook listens for changes in the user's system theme preference + * and updates the state accordingly. + * @returns {boolean} isDarkTheme - true if the system theme is dark, false otherwise + */ const isDarkTheme = useSystemTheme(); - // useEffect that sets the dark mode class when the theme is set to system useEffect(() => { if (theme === "system") { if (isDarkTheme) { @@ -63,7 +85,7 @@ export function Settings({ ); } -// component that renders the summary toggle switch for enabling/disabling summaries in the inbox +/* Component that renders the summary toggle switch for enabling/disabling summaries in the inbox */ export function SummariesInInbox({ isChecked, onToggle }) { return (
@@ -76,7 +98,7 @@ export function SummariesInInbox({ isChecked, onToggle }) { ); } -// component that renders the email fetch interval slider +/* Component that renders the email fetch interval slider */ export function EmailFetchInterval({ emailFetchInterval, onSetEmailFetchInterval, @@ -101,11 +123,14 @@ export function EmailFetchInterval({ ); } -// component that renders the buttons to switch between different themes +/** + * Component that renders the theme switcher buttons + * @param {string} theme - The current theme + * @param {function} onSetTheme - Callback function to handle theme changes + * @returns {JSX.Element} + */ export function Theme({ theme, onSetTheme }) { - const themes = ["light", "system", "dark"]; //array of themes - - //function to handle theme change between light and dark through the buttons + const themes = ["light", "system", "dark"]; const handleThemeChange = (setTheme) => { onSetTheme(setTheme); if (setTheme === "dark") { @@ -123,14 +148,13 @@ export function Theme({ theme, onSetTheme }) { } } }; - return (

Theme

- {themes.map( + {themes.map( //renders the theme buttons ( - t //renders the theme buttons + t ) => (