import { Drawer, EllipsizedText, MenuItem, } from '@biom3/react'; import { motion } from 'framer-motion'; import { useRef, useState, } from 'react'; import { Checkout } from '@imtbl/checkout-sdk'; import { useProvidersContext } from '../../../../context/providers-context/ProvidersContext'; import { listVariants } from '../../../../lib/animation/listAnimation'; import { Chain, RouteData } from '../../../../lib/squid/types'; import { DirectCryptoPayData, DirectCryptoPayOptionType, FiatOptionType, SquidRouteOptionType, } from '../../types'; import { RouteOptions } from './RouteOptions'; type OptionsDrawerProps = { checkout: Checkout; routes: RouteData[] | undefined; chains: Chain[] | null; visible: boolean; onClose: () => void; onRouteClick: (route: RouteData) => void; onCardClick: (type: FiatOptionType) => void; onDirectCryptoPayClick: (route: DirectCryptoPayData) => void; onChangeWalletClick: () => void; showOnrampOption?: boolean; showDirectCryptoPayOption?: boolean; showSwapOption?: boolean; showBridgeOption?: boolean; insufficientBalance?: boolean; directCryptoPayRoutes?: DirectCryptoPayData[]; }; export function RouteOptionsDrawer({ checkout, routes, chains, visible, onClose, onRouteClick, onCardClick, onDirectCryptoPayClick, onChangeWalletClick, showOnrampOption, showDirectCryptoPayOption, // eslint-disable-next-line @typescript-eslint/no-unused-vars showSwapOption, // eslint-disable-next-line @typescript-eslint/no-unused-vars showBridgeOption, insufficientBalance, directCryptoPayRoutes, }: OptionsDrawerProps) { const { providersState: { fromProviderInfo, fromAddress }, } = useProvidersContext(); const selectedRouteIndex = useRef(0); // eslint-disable-next-line max-len const [selectedRouteType, setSelectedRouteType] = useState(undefined); const handleOnRouteClick = (route: RouteData, index: number) => { selectedRouteIndex.current = index; setSelectedRouteType(SquidRouteOptionType.SQUID_ROUTE); onRouteClick(route); }; const handleOnDirectCryptoPayClick = (route: DirectCryptoPayData, index: number) => { selectedRouteIndex.current = index; setSelectedRouteType(DirectCryptoPayOptionType.IMMUTABLE_ZKEVM); onDirectCryptoPayClick(route); }; const handleOnChangeWalletClick = () => { onClose(); onChangeWalletClick(); }; return ( } sx={{ pt: 'base.spacing.x3', px: 'base.spacing.x3', }} > )} sx={{ mx: 'base.spacing.x2' }} /> {fromProviderInfo?.name} ); }