-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from deepraj21/main
fixed profile section
- Loading branch information
Showing
14 changed files
with
562 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
|
||
const BannerUpdate = () => { | ||
return ( | ||
<div>BannerUpdate</div> | ||
) | ||
} | ||
|
||
export default BannerUpdate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className='sm:w-80 grid gap-6'> | ||
<p className='text-sm'>Once you delete an account, there is no going back. Please be certain.</p> | ||
<Button | ||
variant="destructive" | ||
className='w-full mt-2' | ||
onClick={handleDelete} | ||
disabled={isLoading} | ||
> | ||
{isLoading ? ( | ||
<> | ||
<Icons.spinner className="mr-2 h-4 w-4 animate-spin" /> 'Deleting...' | ||
</> | ||
) : 'Delete Account'} | ||
</Button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DeleteAccount; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.