import _ from 'lodash' import { useEffect } from 'react' import { useTranslations } from 'next-intl' import { useAppDispatch } from '@/store/hooks' import { InformationCircleIcon } from '@heroicons/react/outline' import Tooltip from '@tw/Tooltip' import { Switch } from '@headlessui/react' import { useKeyPress } from '@hooks/useKeyPress' import { setShowDestinationAddress, setShowSettingsSlideOver, } from '@/slices/bridgeDisplaySlice' import { setDeadlineMinutes, setDestinationAddress, } from '@/slices/bridge/reducer' import { useBridgeDisplayState } from '@/slices/bridge/hooks' const SettingsSlideOver = () => { const dispatch = useAppDispatch() const t = useTranslations('Settings') const { showDestinationAddress } = useBridgeDisplayState() const onClose = () => { dispatch(setShowSettingsSlideOver(false)) } const escPressed = useKeyPress('Escape', true) const escFunc = () => { if (escPressed) { onClose() } } useEffect(escFunc, [escPressed]) return (
{t('Options')}
{/* @ts-ignore */}
{t('Show withdrawal address')}{' '} { if (selected) { dispatch(setShowDestinationAddress(true)) onClose() } else { dispatch(setShowDestinationAddress(false)) dispatch(setDestinationAddress(null)) } }} className={` relative inline-flex items-center h-6 rounded-full w-11 transition-colors bg-gradient-to-r focus:outline-none ${ showDestinationAddress ? ' from-[#FF00FF] to-[#AC8FFF]' : 'from-gray-900 to-gray-900' } `} >
) } const DeadlineInput = ({ deadlineMinutes }: { deadlineMinutes: number }) => { const dispatch = useAppDispatch() const t = useTranslations('Time') return (
dispatch(setDeadlineMinutes(Number(e.target.value)))} value={deadlineMinutes} /> {t('min')}
) } export default SettingsSlideOver