File tree Expand file tree Collapse file tree
pages/SettingsPage/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,7 +81,13 @@ export function Navbar() {
8181 < ThemeSelector />
8282 < div className = "flex items-center space-x-2" >
8383 < span className = "hidden text-sm sm:inline-block" >
84- Welcome < span className = "text-muted-foreground" > { userName } </ span >
84+ Welcome{ ' ' }
85+ < span
86+ className = "text-muted-foreground inline-block max-w-[150px] truncate align-bottom"
87+ title = { userName }
88+ >
89+ { userName ?. split ( ' ' ) [ 0 ] ?? '' }
90+ </ span >
8591 </ span >
8692 < Link to = "/settings#account" className = "p-2" >
8793 < img
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ export const AvatarSelectionStep: React.FC<AvatarNameSelectionStepProps> = ({
4040 const isEditing = useSelector (
4141 ( state : RootState ) => state . onboarding . isEditing ,
4242 ) ;
43+ const [ longWordError , setLongWordError ] = useState ( false ) ;
4344
4445 useEffect ( ( ) => {
4546 if (
@@ -56,6 +57,13 @@ export const AvatarSelectionStep: React.FC<AvatarNameSelectionStepProps> = ({
5657 } ;
5758
5859 const handleNameChange = ( value : string ) => {
60+ const words = value . split ( ' ' ) ;
61+ const hasLongWord = words . some ( ( word ) => word . length > 30 ) ;
62+ if ( hasLongWord ) {
63+ setLongWordError ( true ) ;
64+ return ;
65+ }
66+ setLongWordError ( false ) ;
5967 setLocalName ( value ) ;
6068 } ;
6169
@@ -115,6 +123,11 @@ export const AvatarSelectionStep: React.FC<AvatarNameSelectionStepProps> = ({
115123 onChange = { ( e ) => handleNameChange ( e . target . value ) }
116124 className = "h-8 text-sm placeholder:text-sm"
117125 />
126+ { longWordError && (
127+ < p className = "mt-2 text-xs text-red-500" >
128+ A single word in your name cannot exceed 30 characters.
129+ </ p >
130+ ) }
118131 </ div >
119132
120133 { /* Avatar Grid */ }
@@ -152,7 +165,7 @@ export const AvatarSelectionStep: React.FC<AvatarNameSelectionStepProps> = ({
152165 < Button
153166 className = "cursor-pointer px-4 py-1 text-sm"
154167 onClick = { handleNextClick }
155- disabled = { ! name || ! selectedAvatar }
168+ disabled = { ! name || ! selectedAvatar || longWordError }
156169 >
157170 Next
158171 </ Button >
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ const AccountSettingsCard: React.FC = () => {
1919 return avatars . includes ( stored ) ? stored : '' ;
2020 } ) ;
2121 const [ nameError , setNameError ] = useState ( false ) ;
22+ const [ longWordError , setLongWordError ] = useState ( false ) ;
2223
2324 // The redundant useEffect has been removed.
2425
@@ -27,10 +28,15 @@ const AccountSettingsCard: React.FC = () => {
2728 } ;
2829
2930 const handleNameChange = ( value : string ) => {
30- setLocalName ( value ) ;
31- if ( nameError ) {
32- setNameError ( false ) ;
31+ const words = value . split ( ' ' ) ;
32+ const hasLongWord = words . some ( ( word ) => word . length > 30 ) ;
33+ if ( hasLongWord ) {
34+ setLongWordError ( true ) ;
35+ return ;
3336 }
37+ setLongWordError ( false ) ;
38+ setLocalName ( value ) ;
39+ if ( nameError ) setNameError ( false ) ;
3440 } ;
3541
3642 const handleSave = ( ) => {
@@ -78,6 +84,11 @@ const AccountSettingsCard: React.FC = () => {
7884 : ''
7985 } `}
8086 />
87+ { longWordError && (
88+ < p className = "mt-2 text-xs text-red-500" >
89+ A single word in your name cannot exceed 30 characters.
90+ </ p >
91+ ) }
8192 </ div >
8293
8394 { /* Avatar Section */ }
@@ -115,7 +126,7 @@ const AccountSettingsCard: React.FC = () => {
115126 < Button
116127 className = "mt-4 w-auto bg-blue-500 px-6 py-2 text-sm font-medium text-white hover:bg-blue-600"
117128 onClick = { handleSave }
118- disabled = { ! selectedAvatar }
129+ disabled = { ! selectedAvatar || longWordError }
119130 >
120131 Save Changes
121132 </ Button >
You can’t perform that action at this time.
0 commit comments