diff --git a/src/app/page.tsx b/src/app/page.tsx index 036afac..939c052 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -8,6 +8,7 @@ import Summary from '@/components/Summary'; export default function Home() { const [transactions, setTransactions] = useState([]); + const [isHorizontalLayout, setIsHorizontalLayout] = useState(false); // Load transactions from localStorage on component mount useEffect(() => { @@ -15,12 +16,23 @@ export default function Home() { if (savedTransactions) { setTransactions(JSON.parse(savedTransactions)); } + + // Load layout preference from localStorage + const layoutPreference = localStorage.getItem('layoutPreference'); + if (layoutPreference) { + setIsHorizontalLayout(layoutPreference === 'horizontal'); + } }, []); // Save transactions to localStorage whenever they change useEffect(() => { localStorage.setItem('transactions', JSON.stringify(transactions)); }, [transactions]); + + // Save layout preference to localStorage whenever it changes + useEffect(() => { + localStorage.setItem('layoutPreference', isHorizontalLayout ? 'horizontal' : 'vertical'); + }, [isHorizontalLayout]); const handleAddTransaction = (transaction: Transaction) => { setTransactions([...transactions, transaction]); @@ -29,22 +41,52 @@ export default function Home() { const handleDeleteTransaction = (id: string) => { setTransactions(transactions.filter(transaction => transaction.id !== id)); }; + + const toggleLayout = () => { + setIsHorizontalLayout(!isHorizontalLayout); + }; return (
-

Ausgaben Tracker

- -
- - - - - +
+

Ausgaben Tracker

+
+ + {isHorizontalLayout ? ( + // Horizontal layout - TransactionList on the right +
+
+ + +
+
+ +
+
+ ) : ( + // Vertical layout - Original stacked layout +
+ + + +
+ )}
);