import { useEffect } from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { fetchBrands } from '../store/slices/brandsSlice'; import { Card } from 'react-bootstrap'; import { Folders, Hash, Link, Users } from 'lucide-react'; import SpinningComponent from './SpinningComponent'; export default function BrandsList({ openBrandDetail }) { const { brands, status, error } = useSelector((state) => state.brands); const dispatch = useDispatch(); useEffect(() => { dispatch(fetchBrands()); }, [dispatch]); if (status === 'loading') { return ; } // 如果加载失败,显示错误信息 if (status === 'failed') { return
{error || 'Failed to load brands. Please try again later.'}
; } return (
{brands?.length > 0 && brands.map((brand) => (
openBrandDetail(brand)}> {brand.name.slice(0, 1)} {brand.name.toUpperCase()} Category {brand.category} Collab. {brand.collab_count} Creators {brand.creators_count} Source {brand.source}
))}
); }