import { Box, type Theme, useMediaQuery } from '@mui/material' import type { FC, RefObject } from 'react' import { useRef } from 'react' import { useTranslation } from 'react-i18next' import { ChainSelect } from '../../components/ChainSelect/ChainSelect.js' import { FullPageContainer } from '../../components/FullPageContainer.js' import { TokenList } from '../../components/TokenList/TokenList.js' import { useHeader } from '../../hooks/useHeader.js' import { useListHeight } from '../../hooks/useListHeight.js' import { useNavigateBack } from '../../hooks/useNavigateBack.js' import { useScrollableOverflowHidden } from '../../hooks/useScrollableContainer.js' import { useSwapOnly } from '../../hooks/useSwapOnly.js' import { useWideVariant } from '../../hooks/useWideVariant.js' import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js' import type { FormType, FormTypeProps } from '../../stores/form/types.js' import { HiddenUI } from '../../types/widget.js' import { SearchTokenInput } from './SearchTokenInput.js' export const SelectTokenPage: FC = ({ formType }) => { useScrollableOverflowHidden() const headerRef = useRef(null) const swapOnly = useSwapOnly() const { subvariant, hiddenUI, subvariantOptions } = useWidgetConfig() const wideVariant = useWideVariant() const { t } = useTranslation() const title = formType === 'from' ? subvariant === 'custom' ? t('header.payWith') : t('header.from') : t('header.to') useHeader(title) const hideChainSelect = (wideVariant && subvariantOptions?.wide?.enableChainSidebar) || (swapOnly && formType === 'to') || hiddenUI?.includes(HiddenUI.ChainSelect) const isMobile = useMediaQuery((theme: Theme) => theme.breakpoints.down(theme.breakpoints.values.xs) ) const hideSearchTokenInput = hiddenUI?.includes(HiddenUI.SearchTokenInput) const hasHeader = !hideChainSelect || !hideSearchTokenInput return ( {!hideChainSelect ? : null} {!hideSearchTokenInput && ( )} ) } type WrappedTokenListProps = { headerRef: RefObject formType: FormType } const WrappedTokenList = ({ headerRef, formType }: WrappedTokenListProps) => { const { navigateBack } = useNavigateBack() const listParentRef = useRef(null) const { listHeight } = useListHeight({ listParentRef, headerRef, }) return ( ) }