Skip to content

Commit f917de9

Browse files
committed
fix: handle potential undefined userName and improve className formatting in Navbar and AccountSettingsCard
1 parent 11210c0 commit f917de9

3 files changed

Lines changed: 21 additions & 16 deletions

File tree

frontend/src/components/Navigation/Navbar/Navbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function Navbar() {
8686
className="text-muted-foreground inline-block max-w-[150px] truncate align-bottom"
8787
title={userName}
8888
>
89-
{userName.split(' ')[0]}
89+
{userName?.split(' ')[0] ?? ''}
9090
</span>
9191
</span>
9292
<Link to="/settings#account" className="p-2">

frontend/src/components/OnboardingSteps/AvatarSelectionStep.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,18 @@ export const AvatarSelectionStep: React.FC<AvatarNameSelectionStepProps> = ({
141141
type="button"
142142
key={avatar}
143143
onClick={() => handleAvatarSelect(avatar)}
144-
className={`bg-background relative inline-flex h-20 w-20 items-center justify-center rounded-full transition-all duration-300 ${isSelected
144+
className={`bg-background relative inline-flex h-20 w-20 items-center justify-center rounded-full transition-all duration-300 ${
145+
isSelected
145146
? 'border-primary ring-primary ring-offset-background ring-2 ring-offset-2'
146147
: 'border-muted'
147-
}`}
148+
}`}
148149
>
149150
<img
150151
src={avatar}
151152
alt="Avatar"
152-
className={`h-20 w-20 rounded-full object-cover transition-all duration-300 ${isSelected ? 'scale-105' : ''
153-
}`}
153+
className={`h-20 w-20 rounded-full object-cover transition-all duration-300 ${
154+
isSelected ? 'scale-105' : ''
155+
}`}
154156
/>
155157
</button>
156158
);

frontend/src/pages/SettingsPage/components/AccountSettingsCard.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ const AccountSettingsCard: React.FC = () => {
7878
}
7979
value={name}
8080
onChange={(e) => handleNameChange(e.target.value)}
81-
className={`h-10 w-full text-sm placeholder:text-sm ${nameError
82-
? 'border-red-500 placeholder:text-red-500/80 focus-visible:ring-red-500'
83-
: ''
84-
}`}
81+
className={`h-10 w-full text-sm placeholder:text-sm ${
82+
nameError
83+
? 'border-red-500 placeholder:text-red-500/80 focus-visible:ring-red-500'
84+
: ''
85+
}`}
8586
/>
8687
{longWordError && (
8788
<p className="mt-2 text-xs text-red-500">
@@ -101,16 +102,18 @@ const AccountSettingsCard: React.FC = () => {
101102
type="button"
102103
key={avatar}
103104
onClick={() => handleAvatarSelect(avatar)}
104-
className={`bg-background relative inline-flex h-24 w-24 items-center justify-center rounded-full transition-all duration-300 ${isSelected
105-
? 'ring-offset-background scale-90 ring-2 ring-blue-500 ring-offset-4'
106-
: 'hover:ring-4 hover:ring-blue-500 hover:ring-offset-4'
107-
}`}
105+
className={`bg-background relative inline-flex h-24 w-24 items-center justify-center rounded-full transition-all duration-300 ${
106+
isSelected
107+
? 'ring-offset-background scale-90 ring-2 ring-blue-500 ring-offset-4'
108+
: 'hover:ring-4 hover:ring-blue-500 hover:ring-offset-4'
109+
}`}
108110
>
109111
<img
110112
src={avatar}
111113
alt="Avatar"
112-
className={`h-24 w-24 rounded-full object-cover transition-all duration-300 ${isSelected ? 'brightness-110' : ''
113-
}`}
114+
className={`h-24 w-24 rounded-full object-cover transition-all duration-300 ${
115+
isSelected ? 'brightness-110' : ''
116+
}`}
114117
/>
115118
</button>
116119
);
@@ -123,7 +126,7 @@ const AccountSettingsCard: React.FC = () => {
123126
<Button
124127
className="mt-4 w-auto bg-blue-500 px-6 py-2 text-sm font-medium text-white hover:bg-blue-600"
125128
onClick={handleSave}
126-
disabled={!selectedAvatar}
129+
disabled={!selectedAvatar || longWordError}
127130
>
128131
Save Changes
129132
</Button>

0 commit comments

Comments
 (0)