Signed-off-by: mbrucedogs <mbrucedogs@gmail.com>
This commit is contained in:
parent
0a8d9ee4e8
commit
6b93061e87
@ -6,6 +6,7 @@ import { debugLog } from '../../utils/logger';
|
|||||||
import { setAuth } from '../../redux/authSlice';
|
import { setAuth } from '../../redux/authSlice';
|
||||||
import { database } from '../../firebase/config';
|
import { database } from '../../firebase/config';
|
||||||
import { ref, get } from 'firebase/database';
|
import { ref, get } from 'firebase/database';
|
||||||
|
import { singerService } from '../../firebase/services';
|
||||||
import type { Authentication } from '../../types';
|
import type { Authentication } from '../../types';
|
||||||
|
|
||||||
interface LoginPromptProps {
|
interface LoginPromptProps {
|
||||||
@ -46,6 +47,21 @@ const LoginPrompt: React.FC<LoginPromptProps> = ({ isAdmin, onComplete }) => {
|
|||||||
};
|
};
|
||||||
debugLog('Dispatching auth:', auth);
|
debugLog('Dispatching auth:', auth);
|
||||||
dispatch(setAuth(auth));
|
dispatch(setAuth(auth));
|
||||||
|
|
||||||
|
// Automatically add singer to the singers list if they don't exist
|
||||||
|
try {
|
||||||
|
await singerService.addSinger(partyId.trim(), singerName.trim());
|
||||||
|
debugLog('Singer automatically added to singers list');
|
||||||
|
} catch (error) {
|
||||||
|
// If singer already exists, that's fine - just log it
|
||||||
|
if (error instanceof Error && error.message === 'Singer already exists') {
|
||||||
|
debugLog('Singer already exists in singers list');
|
||||||
|
} else {
|
||||||
|
console.error('Error adding singer automatically:', error);
|
||||||
|
// Don't block login if singer addition fails
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
debugLog('Calling onComplete');
|
debugLog('Calling onComplete');
|
||||||
onComplete();
|
onComplete();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user