goldenChat base source add

This commit is contained in:
aidev
2026-05-23 15:11:48 +09:00
commit a4ea7762b5
2081 changed files with 1155760 additions and 0 deletions
@@ -0,0 +1,240 @@
import React, { useState } from 'react';
import {
Dialog,
DialogTitle,
DialogContent,
DialogActions,
TextField,
Button,
Box,
Typography,
Alert,
Link,
IconButton,
InputAdornment,
Divider,
} from '@mui/material';
import { Visibility, VisibilityOff, Close, AccountCircle } from '@mui/icons-material';
import { useAuth } from '../contexts/AuthContext';
import DraggablePaper from './DraggablePaper';
interface LoginDialogProps {
open: boolean;
onClose: () => void;
onSwitchToSignUp: () => void;
}
const LoginDialog: React.FC<LoginDialogProps> = ({ open, onClose, onSwitchToSignUp }) => {
const { login } = useAuth();
const [usernameOrEmail, setUsernameOrEmail] = useState('');
const [password, setPassword] = useState('');
const [showPassword, setShowPassword] = useState(false);
const [error, setError] = useState('');
const [isLoading, setIsLoading] = useState(false);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setError('');
if (!usernameOrEmail || !password) {
setError('모든 필드를 입력해주세요.');
return;
}
setIsLoading(true);
try {
await login(usernameOrEmail, password);
handleClose();
} catch (err: any) {
setError(err.response?.data?.error || '로그인에 실패했습니다. 아이디와 비밀번호를 확인해주세요.');
} finally {
setIsLoading(false);
}
};
const handleClose = () => {
setUsernameOrEmail('');
setPassword('');
setError('');
setShowPassword(false);
onClose();
};
// 테스트 계정으로 자동 로그인
const handleTestLogin = async (username: string, password: string) => {
setError('');
setIsLoading(true);
try {
await login(username, password);
handleClose();
} catch (err: any) {
setError(err.response?.data?.error || '로그인에 실패했습니다.');
} finally {
setIsLoading(false);
}
};
return (
<Dialog
open={open}
onClose={handleClose}
maxWidth="xs"
fullWidth
hideBackdrop={true}
disableScrollLock={true}
PaperComponent={DraggablePaper}
sx={{
pointerEvents: 'none',
'& .MuiDialog-container': {
pointerEvents: 'none',
alignItems: 'flex-start',
},
}}
PaperProps={{
sx: {
pointerEvents: 'auto',
boxShadow: '0 8px 32px rgba(0, 0, 0, 0.3)',
border: '2px solid rgba(80, 100, 160, 0.5)',
}
}}
>
<DialogTitle sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
bgcolor: '#1976d2',
color: '#fff',
py: 1.2,
}}>
<Typography variant="h6" sx={{ fontWeight: 600, fontSize: '16px', color: '#fff' }}>
🔐
</Typography>
<IconButton size="small" onClick={handleClose} sx={{ color: '#fff' }}>
<Close />
</IconButton>
</DialogTitle>
<form onSubmit={handleSubmit}>
<DialogContent>
{error && (
<Alert severity="error" sx={{ mb: 2 }}>
{error}
</Alert>
)}
<TextField
fullWidth
label="사용자명 또는 이메일"
value={usernameOrEmail}
onChange={(e) => setUsernameOrEmail(e.target.value)}
margin="normal"
autoFocus
disabled={isLoading}
/>
<TextField
fullWidth
label="비밀번호"
type={showPassword ? 'text' : 'password'}
value={password}
onChange={(e) => setPassword(e.target.value)}
margin="normal"
disabled={isLoading}
InputProps={{
endAdornment: (
<InputAdornment position="end">
<IconButton
onClick={() => setShowPassword(!showPassword)}
edge="end"
>
{showPassword ? <VisibilityOff /> : <Visibility />}
</IconButton>
</InputAdornment>
),
}}
/>
<Box sx={{ mt: 2, textAlign: 'center' }}>
<Typography variant="body2" color="text.secondary">
?{' '}
<Link
component="button"
type="button"
onClick={() => {
handleClose();
onSwitchToSignUp();
}}
sx={{ cursor: 'pointer' }}
>
</Link>
</Typography>
</Box>
</DialogContent>
<DialogActions sx={{ px: 3, pb: 2, flexDirection: 'column', gap: 2 }}>
<Box sx={{ display: 'flex', gap: 1, width: '100%' }}>
<Button
onClick={handleClose}
disabled={isLoading}
variant="outlined"
fullWidth
>
</Button>
<Button
type="submit"
variant="contained"
disabled={isLoading}
fullWidth
>
{isLoading ? '로그인 중...' : '로그인'}
</Button>
</Box>
<Divider sx={{ width: '100%' }}>
<Typography variant="caption" color="text.secondary">
</Typography>
</Divider>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1, width: '100%' }}>
<Button
variant="outlined"
color="secondary"
startIcon={<AccountCircle />}
onClick={() => handleTestLogin('test1', 'test1')}
disabled={isLoading}
fullWidth
>
Test 1
</Button>
<Button
variant="outlined"
color="secondary"
startIcon={<AccountCircle />}
onClick={() => handleTestLogin('test2', 'test2')}
disabled={isLoading}
fullWidth
>
Test 2
</Button>
<Button
variant="outlined"
color="secondary"
startIcon={<AccountCircle />}
onClick={() => handleTestLogin('test3', 'test3')}
disabled={isLoading}
fullWidth
>
Test 3
</Button>
</Box>
</DialogActions>
</form>
</Dialog>
);
};
export default LoginDialog;