import React, { useState } from 'react'; import Dialog from '@mui/material/Dialog'; import DialogTitle from '@mui/material/DialogTitle'; import DialogContent from '@mui/material/DialogContent'; import DialogActions from '@mui/material/DialogActions'; import Button from '@mui/material/Button'; import RadioGroup from '@mui/material/RadioGroup'; import FormControlLabel from '@mui/material/FormControlLabel'; import Radio from '@mui/material/Radio'; import Typography from '@mui/material/Typography'; import List from '@mui/material/List'; import ListItem from '@mui/material/ListItem'; import Box from '@mui/material/Box'; const CartSyncDialog = ({ open, localCart = [], serverCart = [], onClose, onConfirm }) => { const [option, setOption] = useState('merge'); // Helper function to determine if an item is selected in the result const isItemSelected = (item, cart, isResultCart = false) => { if (isResultCart) return true; // All items in result cart are selected switch (option) { case 'deleteServer': return cart === localCart; case 'useServer': return cart === serverCart; case 'merge': return true; // Both carts contribute to merge default: return false; } }; const renderCartItem = (item, cart, isResultCart = false) => { const selected = isItemSelected(item, cart, isResultCart); return ( {item.name} x {item.quantity} ); }; return ( Warenkorb-Synchronisierung Sie haben einen gespeicherten Warenkorb in ihrem Account. Bitte wählen Sie, wie Sie verfahren möchten: setOption(e.target.value)}> {/*} label="Lokalen Warenkorb verwenden und Serverseitigen Warenkorb archivieren" />*/} } label="Server-Warenkorb löschen" /> } label="Server-Warenkorb übernehmen" /> } label="Warenkörbe zusammenführen" /> Ihr aktueller Warenkorb {localCart.length > 0 ? localCart.map(item => renderCartItem(item, localCart)) : leer} In Ihrem Profil gespeicherter Warenkorb {serverCart.length > 0 ? serverCart.map(item => renderCartItem(item, serverCart)) : leer} ); }; export default CartSyncDialog;