refactor: temporarily remove withI18n from GoogleLoginButton for debugging and enhance error handling in LoginComponent

This commit is contained in:
sebseb7
2025-07-30 15:34:23 +02:00
parent 4584da1199
commit afcdbb29c9
2 changed files with 36 additions and 23 deletions

View File

@@ -2,7 +2,7 @@ import React, { Component } from 'react';
import Button from '@mui/material/Button'; import Button from '@mui/material/Button';
import GoogleIcon from '@mui/icons-material/Google'; import GoogleIcon from '@mui/icons-material/Google';
import GoogleAuthContext from '../contexts/GoogleAuthContext.js'; import GoogleAuthContext from '../contexts/GoogleAuthContext.js';
import { withI18n } from '../i18n/index.js'; // import { withI18n } from '../i18n/withTranslation.js'; // Temporarily commented out for debugging
class GoogleLoginButton extends Component { class GoogleLoginButton extends Component {
static contextType = GoogleAuthContext; static contextType = GoogleAuthContext;
@@ -191,13 +191,16 @@ class GoogleLoginButton extends Component {
const { isInitializing, isPrompting } = this.state; const { isInitializing, isPrompting } = this.state;
const isLoading = isInitializing || isPrompting || (this.context && !this.context.isLoaded); const isLoading = isInitializing || isPrompting || (this.context && !this.context.isLoaded);
return ( return (
<Button <Button
variant="contained" variant="contained"
startIcon={<GoogleIcon />} startIcon={<GoogleIcon />}
onClick={this.handleClick} onClick={this.handleClick}
disabled={disabled || isLoading} disabled={disabled || isLoading}
style={{ backgroundColor: '#4285F4', color: 'white', ...style }} fullWidth
style={{backgroundColor: '#4285F4', color: 'white', ...style }}
className={className} className={className}
> >
{isLoading ? 'Loading...' : text} {isLoading ? 'Loading...' : text}
@@ -206,4 +209,4 @@ class GoogleLoginButton extends Component {
} }
} }
export default withI18n(GoogleLoginButton); export default GoogleLoginButton; // Temporarily removed withI18n for debugging

View File

@@ -277,9 +277,17 @@ export class LoginComponent extends Component {
tabValue: 0 // Switch to login tab tabValue: 0 // Switch to login tab
}); });
} else { } else {
let errorMessage = 'Registrierung fehlgeschlagen';
if (response.cause === 'emailExists') {
errorMessage = 'Ein Benutzer mit dieser E-Mail-Adresse existiert bereits. Bitte verwenden Sie eine andere E-Mail-Adresse oder melden Sie sich an.';
} else if (response.message) {
errorMessage = response.message;
}
this.setState({ this.setState({
loading: false, loading: false,
error: response.message || 'Registrierung fehlgeschlagen' error: errorMessage
}); });
} }
}); });
@@ -606,25 +614,27 @@ export class LoginComponent extends Component {
)} )}
{showGoogleAuth && ( {showGoogleAuth && (
<Suspense fallback={ <div>
<Button <Suspense fallback={
variant="contained" <Button
startIcon={<PersonIcon />} variant="contained"
sx={{ width: '100%', backgroundColor: '#4285F4', color: 'white' }} startIcon={<PersonIcon />}
> sx={{ width: '100%', backgroundColor: '#4285F4', color: 'white' }}
Mit Google anmelden >
</Button> Mit Google anmelden
}> </Button>
<GoogleAuthProvider clientId={config.googleClientId}> }>
<GoogleLoginButton <GoogleAuthProvider clientId={config.googleClientId}>
onSuccess={this.handleGoogleLoginSuccess} <GoogleLoginButton
onError={this.handleGoogleLoginError} onSuccess={this.handleGoogleLoginSuccess}
text="Mit Google anmelden" onError={this.handleGoogleLoginError}
style={{ width: '100%', backgroundColor: '#4285F4' }} text="Mit Google anmelden"
autoInitiate={true} style={{ width: '100%', backgroundColor: '#4285F4' }}
/> autoInitiate={true}
</GoogleAuthProvider> />
</Suspense> </GoogleAuthProvider>
</Suspense>
</div>
)} )}
</Box> </Box>