Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

164
Vistas
Mern - How could I increase value "clicked", when updating is only allowed to admins

Currently I am writing a news-website as mern stack. I am using redux toolkit. In my mongoDb, I have a value "clicked", which is default 0, and I want to increase it, when the article is clicked, for finding out the ten most clicked articles. I have build a handleClick function, which gets the value "clicked" and I have a updateInlineNews in my slice. Now I want to send the increased value to mongoDb, but updating news I only allow to users, who are admins. Has anyone an idea, how I could use "clicked" independent? Thanks foy your help.

My code:

const InLineNews = () => {
    const {inlineNews} = useSelector((state)=>state.inlineNews);
    const dispatch = useDispatch();
    useEffect(()=>{
        dispatch(getAllInlineNews());
    }, [dispatch]);
    const handleClick = (section)=>{
        section++;
        const inlineNewsData = {
            clicked: section,
        }
        dispatch(updateInlineNews(inlineNewsData));
        
    }
    
  return <Container>
            <Article>
                <ArticleTitle>InlineNews</ArticleTitle>
                {
                    inlineNews.map((item)=>(
                        <Link to={{pathname:`/${item.ressort}`}} className="link" key={item._id}>
                        <ArticleWrapper key={item._id} onClick={()=>handleClick(item.clicked)}>
                            <ImgHolder>
                            <Image src={item.img} alt={item.title} title={item.title}/>
                            </ImgHolder>
                            <ContentHolder>
                                <Ressort>{item.ressort}</Ressort>
                                <Theme>{item.theme}</Theme>
                                <ContentTitle>{item.title}</ContentTitle>
                                <Content>{item.content}</Content>
                            </ContentHolder>
                        </ArticleWrapper>
                        </Link>
                    ))
                }
            </Article>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda