import React, { useState } from 'react';
import { useMsal } from '@azure/msal-react';
import { BarclaysLogo } from './icons/BarclaysLogo';
import { XIcon } from './icons/XIcon';
import { MicrosoftLogo } from './icons/MicrosoftLogo';
import { loginRequest } from '../services/authConfig';
const SupportModal: React.FC<{
isOpen: boolean;
onClose: () => void;
onSubmit: (query: string) => void;
}> = ({ isOpen, onClose, onSubmit }) => {
if (!isOpen) return null;
const [query, setQuery] = useState('');
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
if (query.trim()) {
onSubmit(query);
}
};
return (
e.stopPropagation()}
>
Contact Support
);
};
export const Login: React.FC = () => {
const { instance } = useMsal();
const [isSupportModalOpen, setIsSupportModalOpen] = useState(false);
const [isLoggingIn, setIsLoggingIn] = useState(false);
const [loginError, setLoginError] = useState(null);
const handleSupportSubmit = (query: string) => {
console.log("Support query submitted:", query);
alert("Thank you for your query. A member of the support team will be in touch with you shortly.");
setIsSupportModalOpen(false);
};
const handleMicrosoftLogin = async () => {
setIsLoggingIn(true);
setLoginError(null);
try {
await instance.loginPopup(loginRequest);
// Success - MSAL Provider will detect the login and re-render App
} catch (error: unknown) {
console.error('Login failed:', error);
if (error instanceof Error) {
// Handle user cancellation differently from errors
if (error.message.includes('user_cancelled')) {
setLoginError(null); // Don't show error for cancellation
} else {
setLoginError('Login failed. Please try again or contact support.');
}
}
} finally {
setIsLoggingIn(false);
}
};
return (
<>
setIsSupportModalOpen(false)}
onSubmit={handleSupportSubmit}
/>
{/* Modern Glassy Background */}
{/* Top Left Blob */}
{/* Bottom Right Blob */}
{/* Noise Texture */}
{/* Login Card */}
Mod Comms
Proof Review & Compliance Platform
Enterprise Sign-In
This application is connected to Azure Active Directory. Please sign in using your corporate Microsoft account.
{loginError && (
{loginError}
)}
>
);
};