feat: Implement Share Modal for document sharing functionality

- Added ShareModal component to manage user and link sharing for documents.
- Created AuthContext to handle user authentication state and token management.
- Updated useYjsDocument hook to support sharing via tokens.
- Enhanced Yjs document creation to include user information and authentication tokens.
- Introduced AuthCallback page to handle authentication redirects and token processing.
- Modified EditorPage and KanbanPage to include share functionality.
- Created LoginPage with Google and GitHub authentication options.
- Added styles for LoginPage.
- Defined types for authentication and sharing in respective TypeScript files.
This commit is contained in:
M1ngdaXie
2026-01-06 22:03:07 -08:00
parent 8ae7fd96e8
commit 0a5e6661f1
30 changed files with 1923 additions and 118 deletions

View File

@@ -0,0 +1,68 @@
import { useEffect, useState } from 'react';
import { useNavigate, useSearchParams } from 'react-router-dom';
import { useAuth } from '../contexts/AuthContext';
function AuthCallback() {
const [searchParams] = useSearchParams();
const navigate = useNavigate();
const { login } = useAuth();
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const handleCallback = async () => {
const token = searchParams.get('token');
const redirect = searchParams.get('redirect') || '/';
if (!token) {
setError('No authentication token received');
setTimeout(() => navigate('/login'), 2000);
return;
}
try {
await login(token);
navigate(redirect);
} catch (err) {
console.error('Login error:', err);
setError('Authentication failed. Please try again.');
setTimeout(() => navigate('/login'), 2000);
}
};
handleCallback();
}, [searchParams, login, navigate]);
return (
<div style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
minHeight: '100vh',
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
}}>
<div style={{
background: 'white',
borderRadius: '16px',
padding: '48px',
textAlign: 'center',
}}>
{error ? (
<>
<h2 style={{ color: '#e53e3e', marginBottom: '8px' }}>Error</h2>
<p style={{ color: '#718096' }}>{error}</p>
<p style={{ color: '#718096', fontSize: '14px', marginTop: '16px' }}>
Redirecting to login...
</p>
</>
) : (
<>
<h2 style={{ color: '#1a202c', marginBottom: '8px' }}>Logging you in...</h2>
<p style={{ color: '#718096' }}>Please wait while we complete the authentication.</p>
</>
)}
</div>
</div>
);
}
export default AuthCallback;