import Fuse from 'fuse.js' import { AwardIcon, BanIcon, LaptopIcon } from 'lucide-react' import { useMemo } from 'react' import { cn } from '@repo/ui/lib/utils' import { Currency } from '@repo/ui/components/currency' import { Card, CardFooter, CardHeader, CardTitle } from '@repo/ui/components/ui/card' import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from '@repo/ui/components/ui/empty' import type { Course, CustomPricing } from './data' import placeholder from '@/assets/placeholder.webp' export function Grid({ search, hits = [], customPricing = [] }: { search: string hits: Course[] customPricing: CustomPricing[] }) { const fuse = useMemo(() => { return new Fuse(hits, { keys: ['name'], threshold: 0.3, includeMatches: true }) }, [hits]) const hits_ = useMemo(() => { if (!search) { return hits } return fuse.search(search).map(({ item }) => item) }, [search, fuse, hits]) const customPricingMap = new Map( customPricing.map((x) => { const [, courseId] = x.sk.split('#') return [courseId, x.unit_price] }) ) if (hits_.length === 0) { return ( Nada encontrado Nenhum resultado para {search}. ) } return (
{hits_.map((props: Course, idx) => { return ( ) })}
) } function Course({ name, access_period, cert, metadata__unit_price, custom_pricing }: Course & { custom_pricing?: number }) { return ( {name} {name} ) } const currency = new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' })