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,31 @@
const API_BASE_URL = import.meta.env.VITE_API_URL || "http://localhost:8080/api";
export async function authFetch(url: string, options?: RequestInit): Promise<Response> {
const token = localStorage.getItem('auth_token');
const headers: HeadersInit = {
'Content-Type': 'application/json',
...options?.headers,
};
// Add Authorization header if token exists
if (token) {
headers['Authorization'] = `Bearer ${token}`;
}
const response = await fetch(url, {
...options,
headers,
});
// Handle 401: Token expired or invalid
if (response.status === 401) {
localStorage.removeItem('auth_token');
window.location.href = '/login';
throw new Error('Unauthorized');
}
return response;
}
export { API_BASE_URL };