Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

409
Views
Sorting array of objects in MUI cards depending on social media

I'm working on an app that displays athlete data in a grid using MUI Grid. The colors on the left border are based on which social network is associated with that card.

Webpage image

What I want to do is have a column for each social network, one for facebook, one for instagram, and one for reddit. That way each column will have the same color cards.

I just cant seem to figure out how to go about doing this. the data from my API is already sorted by social network, but Mui is taking the data from my API and adding the cards row by row instead of column by column.

Here is my code for the athletes cards

import React from 'react'
import { AthleteCardContainer, AthleteImage, AthleteDetailsContainer, TopContainer, BottomContainer, FBLogo, RedditLogo, InstaLogo, LinkIconLogo } from '../styles/athlete-styles'

export const AtheleteCard = ({athlete}) => {

    function numFormatter(num) {
        if(num > 999 && num < 1000000){
            return (num/1000).toFixed(1) + 'K';
        }else if(num > 1000000){
            return (num/1000000).toFixed(1) + 'M'; 
        }else if(num < 900){
            return num; 
        }
    }

  return (
    <AthleteCardContainer social={athlete.platform}>

        <AthleteImage src={athlete.profileImage}/>

        <AthleteDetailsContainer>
            <TopContainer>
            <h1>{athlete.name}</h1>
            <span>@{athlete.handle}</span>
            </TopContainer>
            <BottomContainer>
          
            <h3>{athlete.platform === "Instagram" ?  <InstaLogo/> : athlete.platform === "Facebook" ? <FBLogo/> : athlete.platform === "Reddit" ? <RedditLogo/> : null} {numFormatter(athlete.subscriberCount)}</h3>
            <a href={athlete.url}><p><LinkIconLogo/>{athlete.url}</p></a>
            </BottomContainer>
        </AthleteDetailsContainer>

    </AthleteCardContainer>
  )
}

and my code for the grid itself

export const Athletes = () => {
  const dispatch = useDispatch();
  const athletes = useSelector(state => state.athleteReducer.athletes.athletes)
  

  useEffect(() => {
    dispatch(actions.getAthletes());
  }, [])
  
  console.log(athletes, "from selector")

  return (
  <div>
    <Grid container >
    {athletes.map(athlete => (
      <Grid item xs={12} md={6} lg={4}>
      <AtheleteCard athlete={athlete}/>
    </Grid>
    ))}
    </Grid>
  </div>
  );
};
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use

<Box sx={{ flexWrap: 'wrap', display: flex}}>
    <Grid
      container
      direction="column"
      justifyContent="flex-start"
      alignItems="flex-start"
    >

To align items in columns. Check if this works for you. Remove div use Box and check if this works

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!