import Link from '@/core/components/elements/Link/Link' import { getRandomInt } from '@/utils/getRandomInt' import Image from 'next/image' import { useMemo } from 'react' import { useQuery } from 'react-query' import { HeroBannerSkeleton } from '../skeleton/BannerSkeleton' import { bannerApi } from '@/api/bannerApi' const HeroBannerSecondary = () => { const heroBannerSecondary = useQuery('heroBannerSecondary', bannerApi({ type: 'index-a-2' })) const randomIndex = useMemo(() => { if (!heroBannerSecondary.data) return null const length = heroBannerSecondary.data?.length return getRandomInt(length) }, [heroBannerSecondary.data]) if (heroBannerSecondary.isLoading) return return ( heroBannerSecondary.data && ( {heroBannerSecondary.data[randomIndex].name} ) ) } export default HeroBannerSecondary