import type { JSX, Ref } from 'react' import { useImperativeHandle, useRef, useState } from 'react' import { BottomSheet } from '../BottomSheet/BottomSheet.js' import type { BottomSheetBase } from '../BottomSheet/types.js' import { TokenDetailsSheetContent } from './TokenDetailsSheetContent.js' import type { TokenDetailsSheetBase } from './types.js' export const TokenDetailsSheet = ({ ref, }: { ref?: Ref }): JSX.Element => { const bottomSheetRef = useRef(null) const [tokenAddress, setTokenAddress] = useState( undefined ) const [chainId, setChainId] = useState(undefined) const [withoutContractAddress, setWithoutContractAddress] = useState(false) useImperativeHandle( ref, () => ({ isOpen: () => bottomSheetRef.current?.isOpen(), open: (address: string, noContractAddress: boolean, chainId: number) => { setTokenAddress(address) setWithoutContractAddress(noContractAddress) setChainId(chainId) bottomSheetRef.current?.open() }, close: () => { bottomSheetRef.current?.close() }, }), [] ) return ( bottomSheetRef.current?.close()} tokenAddress={tokenAddress} withoutContractAddress={withoutContractAddress} chainId={chainId} /> ) }