mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import React from 'react';
|
|
|
|
import type { HomeStats } from 'types/api/stats';
|
|
|
|
import { Image } from '@luxfi/ui/image';
|
|
import { Skeleton } from '@luxfi/ui/skeleton';
|
|
import TokenLogoPlaceholder from 'ui/shared/TokenLogoPlaceholder';
|
|
|
|
import useFetchParentChainApi from '../home/useFetchParentChainApi';
|
|
|
|
interface Props {
|
|
isLoading?: boolean;
|
|
className?: string;
|
|
};
|
|
|
|
const NativeTokenIcon = ({ isLoading, className }: Props) => {
|
|
const parentChainApiFetch = useFetchParentChainApi();
|
|
const parentChainStatsQuery = useQuery({
|
|
queryKey: [ 'parent_chain', 'stats' ],
|
|
queryFn: () => parentChainApiFetch({ path: '/stats' }) as Promise<HomeStats>,
|
|
refetchOnMount: false,
|
|
});
|
|
|
|
if (isLoading || parentChainStatsQuery.isFetching) {
|
|
return <Skeleton borderRadius="base" loading className={ className }/>;
|
|
}
|
|
|
|
return (
|
|
<Image
|
|
className={ className }
|
|
borderRadius="base"
|
|
src={ parentChainStatsQuery.data?.coin_image || undefined }
|
|
alt="Native token logo"
|
|
fallback={ <TokenLogoPlaceholder/> }
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default NativeTokenIcon;
|