Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion frontend/src/components/Navigation/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ export function Navbar() {
<ThemeSelector />
<div className="flex items-center space-x-2">
<span className="hidden text-sm sm:inline-block">
Welcome <span className="text-muted-foreground">{userName}</span>
Welcome{' '}
<span
className="text-muted-foreground inline-block max-w-[150px] truncate align-bottom"
title={userName}
>
{userName?.split(' ')[0] ?? ''}
</span>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
</span>
<Link to="/settings#account" className="p-2">
<img
Expand Down
15 changes: 14 additions & 1 deletion frontend/src/components/OnboardingSteps/AvatarSelectionStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const AvatarSelectionStep: React.FC<AvatarNameSelectionStepProps> = ({
const isEditing = useSelector(
(state: RootState) => state.onboarding.isEditing,
);
const [longWordError, setLongWordError] = useState(false);

useEffect(() => {
if (
Expand All @@ -56,6 +57,13 @@ export const AvatarSelectionStep: React.FC<AvatarNameSelectionStepProps> = ({
};

const handleNameChange = (value: string) => {
const words = value.split(' ');
const hasLongWord = words.some((word) => word.length > 30);
if (hasLongWord) {
setLongWordError(true);
return;
}
setLongWordError(false);
setLocalName(value);
Comment thread
rohan-pandeyy marked this conversation as resolved.
};

Expand Down Expand Up @@ -115,6 +123,11 @@ export const AvatarSelectionStep: React.FC<AvatarNameSelectionStepProps> = ({
onChange={(e) => handleNameChange(e.target.value)}
className="h-8 text-sm placeholder:text-sm"
/>
{longWordError && (
<p className="mt-2 text-xs text-red-500">
A single word in your name cannot exceed 30 characters.
</p>
)}
</div>

{/* Avatar Grid */}
Expand Down Expand Up @@ -152,7 +165,7 @@ export const AvatarSelectionStep: React.FC<AvatarNameSelectionStepProps> = ({
<Button
className="cursor-pointer px-4 py-1 text-sm"
onClick={handleNextClick}
disabled={!name || !selectedAvatar}
disabled={!name || !selectedAvatar || longWordError}
>
Next
</Button>
Expand Down
19 changes: 15 additions & 4 deletions frontend/src/pages/SettingsPage/components/AccountSettingsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const AccountSettingsCard: React.FC = () => {
return avatars.includes(stored) ? stored : '';
});
const [nameError, setNameError] = useState(false);
const [longWordError, setLongWordError] = useState(false);

// The redundant useEffect has been removed.

Expand All @@ -27,10 +28,15 @@ const AccountSettingsCard: React.FC = () => {
};

const handleNameChange = (value: string) => {
setLocalName(value);
if (nameError) {
setNameError(false);
const words = value.split(' ');
const hasLongWord = words.some((word) => word.length > 30);
if (hasLongWord) {
setLongWordError(true);
return;
}
setLongWordError(false);
setLocalName(value);
if (nameError) setNameError(false);
};

const handleSave = () => {
Expand Down Expand Up @@ -78,6 +84,11 @@ const AccountSettingsCard: React.FC = () => {
: ''
}`}
/>
{longWordError && (
<p className="mt-2 text-xs text-red-500">
A single word in your name cannot exceed 30 characters.
</p>
)}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
</div>

{/* Avatar Section */}
Expand Down Expand Up @@ -115,7 +126,7 @@ const AccountSettingsCard: React.FC = () => {
<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}
disabled={!selectedAvatar || longWordError}
>
Save Changes
</Button>
Expand Down
Loading