import {useEffect, useMemo} from 'react' import PropTypes from 'prop-types' import clsx from 'clsx' import {styled} from '@mui/system' import {useSwitch} from '@mui/base/SwitchUnstyled' const green = { 700: '#4CAF50', } const grey = { 400: '#BFC7CF', 800: '#2F3A45', } const SwitchRoot = styled('span')` display: inline-block; position: relative; width: 84px; height: 36px; padding: 8px; ` const SwitchInput = styled('input')` position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; z-index: 1; margin: 0; cursor: pointer; ` const SwitchThumb = styled('span')` position: absolute; display: block; background-color: ${green[700]}; width: 40px; height: 40px; border-radius: 8px; top: -1px; left: 4px; transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1); &::before { display: block; content: ''; width: 100%; height: 100%; background: url('data:image/svg+xml;utf8,') center center no-repeat; } &.focusVisible { background-color: #79b; } &.checked { transform: translateX(44px); &::before { background-image: url('data:image/svg+xml;utf8,'); } } ` const SwitchTrack = styled('span')( ({theme}) => ` background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[400]}; border-radius: 4px; width: 100%; height: 100%; display: block; `, ) function MUISwitch(props) { const {setIsPaypal} = props const {getInputProps, checked, disabled, focusVisible} = useSwitch(props) const stateClasses = useMemo(() => ({ checked, disabled, focusVisible, }), [checked, disabled, focusVisible]) useEffect(() => { setIsPaypal(stateClasses.checked) }, [setIsPaypal, stateClasses]) return ( ) } MUISwitch.propTypes = { setIsPaypal: PropTypes.func.isRequired } export default function PaymentMethod({setIsPaypal}) { return } PaymentMethod.propTypes = { setIsPaypal: PropTypes.func.isRequired }