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';

export default function BrandsList() {
    const brands = useSelector((state) => state.brands.brands);
    const dispatch = useDispatch();

    useEffect(() => {
        dispatch(fetchBrands());
    }, [dispatch]);

    return (
        <div className='brands-list'>
            {brands.map((brand) => (
                <div className='brand-card shadow-xs' key={brand.id}>
                    <Card.Body>
                        <Card.Title className='text-primary fw-bold'>
                            <span className='card-logo'>{brand.name.slice(0, 1)}</span>
                            {brand.name.toUpperCase()}
                        </Card.Title>
                        <Card.Text className=''>
                            <span className='card-text-title'>
                                <Folders size={16} />
                                Category
                            </span>
                            <span className='card-text-content'>{brand.category}</span>
                        </Card.Text>
                        <Card.Text className=''>
                            <span className='card-text-title'>
                                <Hash size={16} />
                                Collab.
                            </span>
                            <span className='card-text-content'>{brand.collab}</span>
                        </Card.Text>
                        <Card.Text className=''>
                            <span className='card-text-title'>
                                <Users size={16} />
                                Creators
                            </span>
                            <span className='card-text-content'>{brand.creators}</span>
                        </Card.Text>
                        <Card.Text className=''>
                            <span className='card-text-title'>
                                <Link size={16} />
                                Source
                            </span>
                            <span className='card-text-content'>{brand.source}</span>
                        </Card.Text>
                    </Card.Body>
                </div>
            ))}
        </div>
    );
}
