Refactor ProfileSettings and SecuritySettings components to improve code clarity and add input types

This commit is contained in:
2025-06-05 21:01:06 +02:00
parent 3276fd98c2
commit 734b98d286
3 changed files with 9 additions and 18 deletions

View File

@@ -1,16 +0,0 @@
import { describe, it, expect } from 'vitest';
import { render } from '@/test/utils';
describe('Testing Setup Sanity Check', () => {
it('should render a basic component', () => {
const TestComponent = () => <div>Hello, World!</div>;
const { getByText } = render(<TestComponent />);
expect(getByText('Hello, World!')).toBeInTheDocument();
});
it('should have access to global API_BASE_URL', () => {
expect(window.API_BASE_URL).toBe('http://localhost:8080/api/v1');
});
});

View File

@@ -7,7 +7,7 @@ interface ProfileSettingsProps {
onInputChange: (key: keyof UserProfileSettings, value: string) => void; onInputChange: (key: keyof UserProfileSettings, value: string) => void;
} }
const ProfileSettingsComponent: React.FC<ProfileSettingsProps> = ({ const ProfileSettings: React.FC<ProfileSettingsProps> = ({
settings, settings,
onInputChange, onInputChange,
}) => ( }) => (
@@ -15,18 +15,22 @@ const ProfileSettingsComponent: React.FC<ProfileSettingsProps> = ({
<Stack gap="md"> <Stack gap="md">
<TextInput <TextInput
label="Display Name" label="Display Name"
type="text"
value={settings.displayName || ''} value={settings.displayName || ''}
onChange={(e) => onInputChange('displayName', e.currentTarget.value)} onChange={(e) => onInputChange('displayName', e.currentTarget.value)}
placeholder="Enter display name" placeholder="Enter display name"
data-testid="display-name-input"
/> />
<TextInput <TextInput
label="Email" label="Email"
type="email"
value={settings.email || ''} value={settings.email || ''}
onChange={(e) => onInputChange('email', e.currentTarget.value)} onChange={(e) => onInputChange('email', e.currentTarget.value)}
placeholder="Enter email" placeholder="Enter email"
data-testid="email-input"
/> />
</Stack> </Stack>
</Box> </Box>
); );
export default ProfileSettingsComponent; export default ProfileSettings;

View File

@@ -41,6 +41,7 @@ const SecuritySettings: React.FC<SecuritySettingsProps> = ({
<Stack gap="md"> <Stack gap="md">
<PasswordInput <PasswordInput
label="Current Password" label="Current Password"
type="password"
value={settings.currentPassword || ''} value={settings.currentPassword || ''}
onChange={(e) => onChange={(e) =>
handlePasswordChange('currentPassword', e.currentTarget.value) handlePasswordChange('currentPassword', e.currentTarget.value)
@@ -49,6 +50,7 @@ const SecuritySettings: React.FC<SecuritySettingsProps> = ({
/> />
<PasswordInput <PasswordInput
label="New Password" label="New Password"
type="password"
value={settings.newPassword || ''} value={settings.newPassword || ''}
onChange={(e) => onChange={(e) =>
handlePasswordChange('newPassword', e.currentTarget.value) handlePasswordChange('newPassword', e.currentTarget.value)
@@ -57,6 +59,7 @@ const SecuritySettings: React.FC<SecuritySettingsProps> = ({
/> />
<PasswordInput <PasswordInput
label="Confirm New Password" label="Confirm New Password"
type="password"
value={confirmPassword} value={confirmPassword}
onChange={(e) => onChange={(e) =>
handlePasswordChange('confirmNewPassword', e.currentTarget.value) handlePasswordChange('confirmNewPassword', e.currentTarget.value)