From be84b4eb45dfb0199e57cc0a084c4daa95047c49 Mon Sep 17 00:00:00 2001 From: Deepraj Date: Tue, 19 Nov 2024 12:38:06 +0530 Subject: [PATCH 1/3] feat: add Delete Account functionality and update UI components --- README.md | 3 - client/src/App.tsx | 1 - client/src/components/Navbar/Navbar.tsx | 8 +- .../src/components/Settings/DeleteAccount.tsx | 53 +++++++ .../src/components/Settings/UpdateProfile.tsx | 131 +++++++++--------- .../components/Settings/WebappSettings.tsx | 17 ++- client/src/components/Sidebar/Sidebar.tsx | 8 +- 7 files changed, 138 insertions(+), 83 deletions(-) create mode 100644 client/src/components/Settings/DeleteAccount.tsx diff --git a/README.md b/README.md index 718c305..9bfbe3e 100644 --- a/README.md +++ b/README.md @@ -110,9 +110,6 @@ Our API is designed to give you access to all core functionalities of DevHub pro -For the full API documentation, visit the following link: -[Postman API Documentation](https://documenter.getpostman.com/view/37803453/2sAXxP9Cxo) - ## Conclusion 🎉 By integrating LLMs for natural language understanding, LangChain for workflow enhancement, and Neo4j for advanced data storage and querying, DevHub offers a comprehensive solution for devs seeking meaningful collaborations. This combination not only enhances user experience but also ensures that connections are based on relevant skills and interests, leading to more effective teamwork. diff --git a/client/src/App.tsx b/client/src/App.tsx index c0197fd..b64a2e9 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -17,7 +17,6 @@ import UserPosts from './pages/UserPosts'; import ShowPostByID from './components/Posts/ShowPostByID'; const App = () => { - return ( diff --git a/client/src/components/Navbar/Navbar.tsx b/client/src/components/Navbar/Navbar.tsx index 6ac5391..bdd7813 100644 --- a/client/src/components/Navbar/Navbar.tsx +++ b/client/src/components/Navbar/Navbar.tsx @@ -6,13 +6,13 @@ export type IconProps = React.HTMLAttributes & React.ImgHTMLAttribut export function Navbar() { const gotoGithub = () => { - window.location.href = "https://github.com" + window.location.href = "https://github.com/devhub-ai/devhub" } const gotoDiscord = () => { window.location.href = "https://discord.gg/u86Gy2qFHm" } const gotoFeed = () => { - window.location.href = "https://devhub.page/feed" + window.location.href = "https://devhub.page/feed" } return (
@@ -52,9 +52,7 @@ const Icons = { /> ), Feed: (props: IconProps) => ( - - - + ), Discord:(props: IconProps) => ( diff --git a/client/src/components/Settings/DeleteAccount.tsx b/client/src/components/Settings/DeleteAccount.tsx new file mode 100644 index 0000000..c175b06 --- /dev/null +++ b/client/src/components/Settings/DeleteAccount.tsx @@ -0,0 +1,53 @@ +import axios from 'axios'; +import { useNavigate } from 'react-router-dom'; +import { Button } from "@/components/ui/button"; +import { useState } from 'react'; +import { toast } from 'sonner'; +import { Icons } from "@/components/ui/icons"; + +const username = localStorage.getItem('devhub_username'); +const backendUrl = import.meta.env.VITE_BACKEND_URL || 'http://localhost:5000'; + +const DeleteAccount = () => { + const navigate = useNavigate(); + const [isLoading, setIsLoading] = useState(false); + + const handleDelete = async () => { + setIsLoading(true); + try { + const response = await axios.delete(`${backendUrl}/profile/delete/${username}`); + if (response.status === 200) { + toast.success('Account deleted successfully.'); + localStorage.removeItem('devhub_username'); + navigate('/'); + } else { + toast.error('Failed to delete account.'); + } + } catch (error) { + console.error('Error:', error); + toast.error('An error occurred while deleting the account.'); + } finally { + setIsLoading(false); + } + }; + + return ( +
+

Once you delete an account, there is no going back. Please be certain.

+ +
+ ); +}; + +export default DeleteAccount; diff --git a/client/src/components/Settings/UpdateProfile.tsx b/client/src/components/Settings/UpdateProfile.tsx index 4c0ad6b..2a3d729 100644 --- a/client/src/components/Settings/UpdateProfile.tsx +++ b/client/src/components/Settings/UpdateProfile.tsx @@ -7,6 +7,7 @@ import { toast } from 'sonner'; import { Textarea } from '../ui/textarea'; import { Icons } from "@/components/ui/icons"; import UploadComponent from '@/components/UploadComponent/UploadComponent'; +import { ScrollArea } from "@/components/ui/scroll-area" const backendUrl = import.meta.env.VITE_BACKEND_URL || 'http://localhost:5000'; @@ -100,89 +101,91 @@ const UpdateProfile = () => { }; return ( -
-

+
+

Update Profile

-
- - -
-
- - -
-
- -