- ProjectHeader component replaces the headerButtons JSX in context; it owns the export menu and share panel state. - useShareLink (share status/enable/revoke/copy) and useSharedView (?share= read-only view, now used directly by the router). - utils/projectExport: HTML/Markdown/DOCX download and print-to-PDF. - AuthStatus component replaces the authStatus JSX in context. - Pages import wordStudy helpers directly instead of via context. - Remove dead copyPronunciationGuide (PronunciationPage has its own). - Tests: Markdown export, enabling a share link, the ?share= view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
735 B
JavaScript
21 lines
735 B
JavaScript
// A ?share=TOKEN URL shows a read-only view of someone else's project. No
|
|
// login is needed, so this runs independently of auth.
|
|
import { useEffect, useState } from 'react';
|
|
import { getSharedProject } from '../syncService.js';
|
|
|
|
export function useSharedView() {
|
|
const [token] = useState(() => new URLSearchParams(window.location.search).get('share'));
|
|
const [project, setProject] = useState(null);
|
|
const [error, setError] = useState('');
|
|
|
|
useEffect(() => {
|
|
if (!token) return;
|
|
getSharedProject(token).then((result) => {
|
|
if (result.ok) setProject(result.data);
|
|
else setError(result.error ?? 'This share link is invalid or has been revoked.');
|
|
});
|
|
}, [token]);
|
|
|
|
return { token, project, error };
|
|
}
|