diff --git a/client/src/components/HamburgerMenu.jsx b/client/src/components/HamburgerMenu.jsx index 7149d33..2c9591c 100644 --- a/client/src/components/HamburgerMenu.jsx +++ b/client/src/components/HamburgerMenu.jsx @@ -1,4 +1,5 @@ -import React, {useContext, useEffect} from 'react'; +import React, { useContext, useEffect } from 'react'; +import User from '../models/User.js'; import { Drawer, DrawerBody, @@ -15,6 +16,7 @@ import { import {HamburgerIcon} from "@chakra-ui/icons"; import {AppContext} from '../context/AppContext.jsx'; import SignOut from "./SignOut.jsx"; +import { set } from 'react-hook-form'; // const HamburgerMenu = ({setRunTour}) => { const HamburgerMenu = () => { @@ -24,9 +26,8 @@ const HamburgerMenu = () => { renderNewScreen, showCategories, toggleCategoriesList, - user, - setRunTour, - setRunChartTour + user, setRunTour, setRunChartTour, setIsUpdating, + setServerResponse, setScreen, resetAppState } = useContext(AppContext); const {isOpen, onOpen, onClose} = useDisclosure(); @@ -43,6 +44,19 @@ const HamburgerMenu = () => { setRunTour(true); }; + const handleDeleteAccount = async () => { + if (window.confirm("Are you sure you want to delete your account?")) { + setIsUpdating(true) + console.log(user.user_id) + const userToDelete = new User(user) + localStorage.removeItem('user') + // const result = await userToDelete.deleteUser(user.user_id) + userToDelete.deleteUser(user.user_id) + // setServerResponse(result) + resetAppState() + } + } + return ( <> { onClick={toggleCategoriesList}> {showCategories ? "Hide Categories" : "Show Categories"} +