-
-
Notifications
You must be signed in to change notification settings - Fork 617
feat: Implement settings page functionality(#566) #606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rohan-pandeyy
merged 6 commits into
AOSSIE-Org:main
from
ShivaGupta-14:feat/settings-page
May 13, 2026
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
917ed09
This commit introduces the initial implementation of the user setting…
ShivaGupta-14 1621717
This commit introduces the initial implementation of the user setting…
ShivaGupta-14 e2c3e04
Updating some important changes and improving user experience
ShivaGupta-14 4a393a2
adding try and catch block
ShivaGupta-14 cfe0699
Update Settings.tsx
ShivaGupta-14 96bb9a4
Connect Navbar Avatar with Setting#account + Nitpicks
rohan-pandeyy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
122 changes: 122 additions & 0 deletions
122
frontend/src/pages/SettingsPage/components/AccountSettingsCard.tsx
This file contains hidden or 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,122 @@ | ||
| import React, { useState } from 'react'; // No need for useEffect | ||
| import { useDispatch } from 'react-redux'; | ||
| import { Label } from '@/components/ui/label'; | ||
| import { Input } from '@/components/ui/input'; | ||
| import { setAvatar, setName } from '@/features/onboardingSlice'; | ||
| import { User } from 'lucide-react'; | ||
| import SettingsCard from './SettingsCard'; | ||
| import { avatars } from '@/constants/avatars'; | ||
| import { CardContent } from '@/components/ui/card'; | ||
| import { Button } from '@/components/ui/button'; | ||
|
|
||
| const AccountSettingsCard: React.FC = () => { | ||
| const dispatch = useDispatch(); | ||
| const [name, setLocalName] = useState( | ||
| () => localStorage.getItem('name') || '', | ||
| ); | ||
| const [selectedAvatar, setLocalAvatar] = useState( | ||
| () => localStorage.getItem('avatar') || '', | ||
| ); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| const [nameError, setNameError] = useState(false); | ||
|
|
||
| // The redundant useEffect has been removed. | ||
|
|
||
| const handleAvatarSelect = (avatar: string) => { | ||
| setLocalAvatar(avatar); | ||
| }; | ||
|
|
||
| const handleNameChange = (value: string) => { | ||
| setLocalName(value); | ||
| if (nameError) { | ||
| setNameError(false); | ||
| } | ||
| }; | ||
|
|
||
| const handleSave = () => { | ||
| if (!name.trim()) { | ||
| setNameError(true); | ||
| return; | ||
| } | ||
|
|
||
| setNameError(false); | ||
| if (!selectedAvatar) return; | ||
|
|
||
| dispatch(setName(name)); | ||
| dispatch(setAvatar(selectedAvatar)); | ||
| localStorage.setItem('name', name); | ||
| localStorage.setItem('avatar', selectedAvatar); | ||
| }; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| return ( | ||
| <SettingsCard | ||
| icon={User} | ||
| title="Account Information" | ||
| description="Manage your account details and profile information." | ||
| > | ||
| <CardContent className="flex-1 space-y-6 overflow-y-hidden p-1 px-2"> | ||
| <div className="w-fit space-y-6"> | ||
| {/* Name Change */} | ||
| <div className="w-full"> | ||
| <Label htmlFor="name" className="mb-2 block text-base font-medium"> | ||
| Name | ||
| </Label> | ||
| <Input | ||
| id="name" | ||
| placeholder={ | ||
| nameError ? "Name can't be empty" : 'Enter your name' | ||
| } | ||
| value={name} | ||
| onChange={(e) => handleNameChange(e.target.value)} | ||
| className={`h-10 w-full text-sm placeholder:text-sm ${ | ||
| nameError | ||
| ? 'border-red-500 placeholder:text-red-500/80 focus-visible:ring-red-500' | ||
| : '' | ||
| }`} | ||
| /> | ||
| </div> | ||
|
|
||
| {/* Avatar Section */} | ||
| <div className="w-full"> | ||
| <Label className="mb-3 block text-base font-medium">Avatar</Label> | ||
| <div className="grid grid-cols-4 gap-8"> | ||
| {avatars.map((avatar) => { | ||
| const isSelected = selectedAvatar === avatar; | ||
| return ( | ||
| <button | ||
| type="button" | ||
| key={avatar} | ||
| onClick={() => handleAvatarSelect(avatar)} | ||
| className={`bg-background relative inline-flex h-24 w-24 items-center justify-center rounded-full transition-all duration-300 ${ | ||
| isSelected | ||
| ? 'ring-offset-background scale-90 ring-2 ring-blue-500 ring-offset-4' | ||
| : 'hover:ring-4 hover:ring-blue-500 hover:ring-offset-4' | ||
| }`} | ||
| > | ||
| <img | ||
| src={avatar} | ||
| alt="Avatar" | ||
| className={`h-24 w-24 rounded-full object-cover transition-all duration-300 ${ | ||
| isSelected ? 'brightness-110' : '' | ||
| }`} | ||
| /> | ||
| </button> | ||
| ); | ||
| })} | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* Save Changes Button */} | ||
| <Button | ||
| className="mt-4 w-auto bg-blue-500 px-6 py-2 text-sm font-medium text-white hover:bg-blue-600" | ||
| onClick={handleSave} | ||
| disabled={!selectedAvatar} | ||
| > | ||
| Save Changes | ||
| </Button> | ||
| </CardContent> | ||
| </SettingsCard> | ||
| ); | ||
| }; | ||
|
|
||
| export default AccountSettingsCard; | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.