feat: added privacy policy page
This commit is contained in:
26
App.tsx
26
App.tsx
@@ -10,18 +10,40 @@ import PrivacyPolicy from './components/PrivacyPolicy';
|
||||
const App: React.FC = () => {
|
||||
const [currentPage, setCurrentPage] = useState<'home' | 'privacy'>('home');
|
||||
|
||||
useEffect(() => {
|
||||
const handleHashChange = () => {
|
||||
const hash = window.location.hash;
|
||||
if (hash === '#privacy') {
|
||||
setCurrentPage('privacy');
|
||||
} else {
|
||||
setCurrentPage('home');
|
||||
}
|
||||
};
|
||||
|
||||
// Initial check
|
||||
handleHashChange();
|
||||
|
||||
// Listen for hash changes
|
||||
window.addEventListener('hashchange', handleHashChange);
|
||||
return () => window.removeEventListener('hashchange', handleHashChange);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
window.scrollTo(0, 0);
|
||||
}, [currentPage]);
|
||||
|
||||
const navigateToPrivacy = (e?: React.MouseEvent) => {
|
||||
e?.preventDefault();
|
||||
setCurrentPage('privacy');
|
||||
window.location.hash = 'privacy';
|
||||
};
|
||||
|
||||
const navigateToHome = (e?: React.MouseEvent) => {
|
||||
e?.preventDefault();
|
||||
setCurrentPage('home');
|
||||
window.location.hash = '';
|
||||
// If hash is empty, it might not trigger hashchange if it was already empty?
|
||||
// Actually assigning '' to hash usually removes the hash or makes it '#'.
|
||||
// Better to explicitly set history or just ensure state updates if the listener fires.
|
||||
// If we rely on the listener, updating hash is enough.
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user