Compare commits
No commits in common. "80232b80992906fd82c0e186a17890c208bf1586" and "a19c082d9a347a8121a0158c0c1465597a21c859" have entirely different histories.
80232b8099
...
a19c082d9a
@ -6,11 +6,7 @@ import './HomePage.css';
|
||||
|
||||
const HomePage: React.FC = () => {
|
||||
const [productsData, setProductsData] = useState<ProductsData>({ food: [], drinks: [] });
|
||||
const [activeTab, setActiveTab] = useState<'food' | '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';
|
||||
});
|
||||
const [activeTab, setActiveTab] = useState<'food' | 'drinks'>('drinks');
|
||||
|
||||
useEffect(() => {
|
||||
import('../data/products.json')
|
||||
@ -20,12 +16,6 @@ const HomePage: React.FC = () => {
|
||||
.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 (
|
||||
<div className="home-page">
|
||||
<header className="app-header">
|
||||
@ -37,13 +27,13 @@ const HomePage: React.FC = () => {
|
||||
<div className="category-tabs">
|
||||
<button
|
||||
className={activeTab === 'drinks' ? 'active' : ''}
|
||||
onClick={() => handleTabChange('drinks')}
|
||||
onClick={() => setActiveTab('drinks')}
|
||||
>
|
||||
Getränke
|
||||
</button>
|
||||
<button
|
||||
className={activeTab === 'food' ? 'active' : ''}
|
||||
onClick={() => handleTabChange('food')}
|
||||
onClick={() => setActiveTab('food')}
|
||||
>
|
||||
Essen
|
||||
</button>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user