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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import React, { useEffect, lazy, Suspense, useRef, useState, useContext } from 'react';
  2. import './App.css';
  3. import { Route, Routes, useNavigate } from 'react-router-dom';
  4. import Navigation from './components/shared/Navigation';
  5. import CookieBanner from './components/shared/CookieBanner';
  6. import Footer from './components/shared/Footer';
  7. import Loader from './components/shared/Loader';
  8. import ScrollToTop from './components/root/ScrollToTop';
  9. import ReactGA from 'react-ga4';
  10. import { useCookies } from 'react-cookie';
  11. import routes from './routes';
  12. import UIContextProvider from './context/UIContextProvider';
  13. const Home = lazy(() => import('./pages/Home'));
  14. const Portfolio = lazy(() => import('./pages/Portfolio'));
  15. const Services = lazy(() => import('./pages/Services'));
  16. const Careers = lazy(() => import('./pages/Careers'));
  17. const Culture = lazy(() => import('./pages/Culture'));
  18. const About = lazy(() => import('./pages/About'));
  19. const Blog = lazy(() => import('./pages/Blog'));
  20. const ProcessPage = lazy(() => import('./pages/ProcessPage'));
  21. const ContactPage = lazy(() => import('./pages/ContactPage'));
  22. const PrivacyPolicy = lazy(() => import('./pages/PrivacyPolicy'));
  23. const WorkWithUs = lazy(() => import('./pages/WorkWithUs'));
  24. const NotFoundPage = lazy(() => import('./pages/NotFoundPage'));
  25. const ArticlePage = lazy(() => import('./pages/ArticlePage'));
  26. const CaseStudyPage = lazy(() => import('./pages/CaseStudyPage'));
  27. // Navigation Links
  28. const links = routes.filter(item => item.nav === true);
  29. function App() {
  30. //tabs for contact form
  31. const link = useNavigate();
  32. const [cookies, setCookie, removeCookie] = useCookies(['user']);
  33. const [diligentCookie, setDiligentCookie] = useState(cookies.diligent_ga);
  34. //scroll to Contact segment
  35. const forwardedRef = useRef(null);
  36. useEffect(() => {
  37. if (diligentCookie === 'true') {
  38. ReactGA.initialize(process.env.REACT_APP_MEASUREMENT_ID);
  39. }
  40. }, [diligentCookie]);
  41. //scroll to Contact fn
  42. function scrollToView(event) {
  43. event.preventDefault();
  44. if (forwardedRef) {
  45. window.scrollTo({ behavior: 'smooth', top: forwardedRef.current.offsetTop });
  46. } else {
  47. link('/contact');
  48. }
  49. }
  50. //nav active links
  51. function activeLinks(activePage, bool = true) {
  52. const text = 'text-gray-500 ';
  53. if (bool === true) {
  54. return activePage ? 'activeLink dg-primary-900 ' : text;
  55. } else {
  56. return text;
  57. }
  58. }
  59. const handleAccept = () => {
  60. setCookie('diligent_ga', 'true', { path: '/' });
  61. setDiligentCookie(prevValue => !prevValue);
  62. };
  63. const handleDecline = () => {
  64. setCookie('diligent_ga', 'false', { path: '/' });
  65. setDiligentCookie(prevValue => !prevValue);
  66. };
  67. return (
  68. <div>
  69. <ScrollToTop />
  70. <UIContextProvider>
  71. <Navigation
  72. links={links}
  73. scrollToView={scrollToView}
  74. activeLinks={activeLinks}
  75. forwardedRef={forwardedRef}
  76. ></Navigation>
  77. {diligentCookie === undefined && (
  78. <CookieBanner handleAccept={handleAccept} handleDecline={handleDecline} />
  79. )}
  80. <Suspense fallback={<Loader />}>
  81. <Routes>
  82. <Route path="*" element={<NotFoundPage />} />
  83. <Route exact path="/" element={<Home forwardedRef={forwardedRef} />} />
  84. <Route exact path="/workwithus" element={<WorkWithUs />} />
  85. <Route exact path="/portfolio" element={<Portfolio />} />
  86. <Route exact path="/case-studies/:slug" element={<CaseStudyPage />} />
  87. <Route exact path="/process" element={<ProcessPage />} />
  88. <Route exact path="/careers" element={<Careers />} />
  89. <Route exact path="/culture" element={<Culture />} />
  90. <Route exact path="/about" element={<About />} />
  91. <Route exact path="/blog" element={<Blog />}/>
  92. <Route exact path="/articles/:slug" element={<ArticlePage />} />
  93. <Route exact path="/contact" element={<ContactPage />} />
  94. <Route exact path="/privacypolicy" element={<PrivacyPolicy />} />
  95. </Routes>
  96. </Suspense>
  97. <Footer
  98. links={links}
  99. activeLinks={activeLinks}
  100. scrollToView={scrollToView}
  101. forwardedRef={forwardedRef}
  102. />
  103. </UIContextProvider>
  104. </div>
  105. );
  106. }
  107. export default App;