Compare commits

..

No commits in common. "80232b80992906fd82c0e186a17890c208bf1586" and "a19c082d9a347a8121a0158c0c1465597a21c859" have entirely different histories.

View File

@ -6,11 +6,7 @@ import './HomePage.css';
const HomePage: React.FC = () => { const HomePage: React.FC = () => {
const [productsData, setProductsData] = useState<ProductsData>({ food: [], drinks: [] }); const [productsData, setProductsData] = useState<ProductsData>({ food: [], drinks: [] });
const [activeTab, setActiveTab] = useState<'food' | 'drinks'>(() => { const [activeTab, setActiveTab] = useState<'food' | 'drinks'>('drinks');
// Initialize from session storage, default to 'drinks' if not available
const savedTab = sessionStorage.getItem('kelnerRechnerActiveTab');
return (savedTab === 'food' || savedTab === 'drinks') ? savedTab as 'food' | 'drinks' : 'drinks';
});
useEffect(() => { useEffect(() => {
import('../data/products.json') import('../data/products.json')
@ -20,12 +16,6 @@ const HomePage: React.FC = () => {
.catch(error => console.error('Failed to load products:', error)); .catch(error => console.error('Failed to load products:', error));
}, []); }, []);
// Handler for tab changes that also updates session storage
const handleTabChange = (tab: 'food' | 'drinks') => {
setActiveTab(tab);
sessionStorage.setItem('kelnerRechnerActiveTab', tab);
};
return ( return (
<div className="home-page"> <div className="home-page">
<header className="app-header"> <header className="app-header">
@ -37,13 +27,13 @@ const HomePage: React.FC = () => {
<div className="category-tabs"> <div className="category-tabs">
<button <button
className={activeTab === 'drinks' ? 'active' : ''} className={activeTab === 'drinks' ? 'active' : ''}
onClick={() => handleTabChange('drinks')} onClick={() => setActiveTab('drinks')}
> >
Getränke Getränke
</button> </button>
<button <button
className={activeTab === 'food' ? 'active' : ''} className={activeTab === 'food' ? 'active' : ''}
onClick={() => handleTabChange('food')} onClick={() => setActiveTab('food')}
> >
Essen Essen
</button> </button>