Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

BlogArticlesDataWrapper.jsx 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React, { useEffect, useState } from 'react';
  2. import { strapiApiBuilder } from './../../utils/strapiApiBuilder';
  3. import useFetchCollections from './../../hooks/useFetchCollections';
  4. import Wrapper from '../../layout/Wrapper';
  5. import Animation_Diligent from '../../assets/animation_diligent.webm';
  6. import ArticlesGrid from './ArticlesGrid';
  7. import ArticleCard from './ArticleCard';
  8. const api_url = process.env.REACT_APP_API_URL;
  9. const strapiPopulate = ['AuthorImage', 'ArticleImage', 'article_category'];
  10. const BlogArticlesDataWrapper = () => {
  11. const strapi = strapiApiBuilder('articles', strapiPopulate, '&sort=Date:desc');
  12. const [{ data, isLoading, isError }, doFetch] = useFetchCollections(strapi);
  13. //console.log(data);
  14. if (isLoading) {
  15. return (
  16. <div className="z-50 w-full h-screen bg-white dark:bg-dg-primary-1700 overflow-hidden dark:text-white flex items-center justify-center text-3xl font-semibold">
  17. <video id="animation" width="540" height="540" autoPlay muted loop>
  18. <source src={Animation_Diligent} type="video/webm" />
  19. Loading...
  20. </video>
  21. </div>
  22. );
  23. } else {
  24. return (
  25. <>
  26. {data && (
  27. <Wrapper>
  28. <ArticlesGrid>
  29. {data.map((element, index) => (
  30. <div key={index}>
  31. <ArticleCard data={element.attributes} />
  32. </div>
  33. ))}
  34. </ArticlesGrid>
  35. </Wrapper>
  36. )}
  37. </>
  38. );
  39. }
  40. };
  41. export default BlogArticlesDataWrapper;