import type { BoxProps } from '@mui/material'; import { Box, Button, Collapse } from '@mui/material'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; import { useRoutes } from '../../hooks'; import { useWidgetConfig } from '../../providers'; import { useValidation } from '../../stores'; import { navigationRoutes } from '../../utils'; import { Card, CardTitle } from '../Card'; import { ProgressToNextUpdate } from '../ProgressToNextUpdate'; import { RouteCard, RouteCardSkeleton, RouteNotFoundCard } from '../RouteCard'; export const Routes: React.FC = (props) => { const { t } = useTranslation(); const navigate = useNavigate(); const { subvariant, useRecommendedRoute } = useWidgetConfig(); const { isValid, isValidating } = useValidation(); const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useRoutes(); const currentRoute = routes?.[0]; if (!currentRoute && !isLoading && !isFetching && !isFetched) { return null; } const handleCardClick = () => { navigate(navigationRoutes.routes); }; const routeNotFound = !currentRoute && !isLoading && !isFetching; const onlyRecommendedRoute = subvariant === 'refuel' || useRecommendedRoute; const showAll = !onlyRecommendedRoute && !routeNotFound && (routes?.length ?? 0) > 1; return ( {subvariant === 'nft' ? t('main.fromAmount') : t('header.youGet')} refetch()} sx={{ position: 'absolute', top: 8, right: 8, }} /> {isLoading ? ( ) : !currentRoute ? ( ) : ( )} ); };