• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

EcrituresNumeriques / stylo / 15066626824

16 May 2025 10:41AM UTC coverage: 37.574% (-0.02%) from 37.594%
15066626824

Pull #1517

github

web-flow
Merge e05a1c169 into 607ffe7f9
Pull Request #1517: Mise à jour vers react-router@7

549 of 776 branches covered (70.75%)

Branch coverage included in aggregate %.

13 of 373 new or added lines in 28 files covered. (3.49%)

5 existing lines in 4 files now uncovered.

5319 of 14841 relevant lines covered (35.84%)

2.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/front/src/layouts/App.jsx
NEW
1
import React, { useEffect, useMemo } from 'react'
×
NEW
2
import { setUser as setSentryUser } from '@sentry/react'
×
NEW
3
import { Outlet, ScrollRestoration, useLoaderData, useLocation, useNavigate } from 'react-router'
×
NEW
4
import { useDispatch } from 'react-redux'
×
NEW
5
import Footer from '../components/Footer.jsx'
×
NEW
6
import Header from '../components/Header.jsx'
×
NEW
7
import createReduxStore from '../createReduxStore.js'
×
NEW
8
import { getUserProfile } from '../helpers/user.js'
×
NEW
9
import { usePreferenceItem } from '../hooks/user.js'
×
10

NEW
11
export async function loader () {
×
NEW
12
  const store = createReduxStore()
×
NEW
13
  const { sessionToken } = store.getState()
×
14

NEW
15
  const { user } = await getUserProfile({ sessionToken })
×
NEW
16
  return user
×
NEW
17
}
×
18

NEW
19
export default function StyloApp () {
×
NEW
20
  const location = useLocation()
×
NEW
21
  const navigate = useNavigate()
×
NEW
22
  const user = useLoaderData()
×
NEW
23
  const dispatch = useDispatch()
×
NEW
24
  const { value: hasTrackingConsent } = usePreferenceItem('trackingConsent', 'user')
×
25

26
  // Setup user session
27
  useEffect(() => {
×
NEW
28
    dispatch({ type: 'PROFILE', user })
×
NEW
29
    setSentryUser({ id: user?._id })
×
30

NEW
31
    if (hasTrackingConsent) {
×
NEW
32
      const _paq = (window._paq = window._paq || [])
×
NEW
33
      _paq.push(['setUserId', user?._id])
×
34
    }
×
NEW
35
  }, [user?._id, hasTrackingConsent])
×
36

NEW
37
  useEffect(() => {
×
NEW
38
    if (location.pathname.match(/\/books/i)) {
×
NEW
39
      navigate(location.pathname.replace(/\/books/i, '/corpus'))
×
NEW
40
    }
×
NEW
41
  }, [location.pathname])
×
42

43
  // Forget tracking
NEW
44
  useEffect(() => {
×
NEW
45
    if (!hasTrackingConsent) {
×
NEW
46
      const _paq = (window._paq = window._paq || [])
×
NEW
47
      _paq.push(['forgetConsentGiven'])
×
NEW
48
    }
×
NEW
49
  }, [hasTrackingConsent])
×
50

51

52
  // Track location change
53
  useEffect(() => {
×
54
    if (hasTrackingConsent) {
×
NEW
55
      const _paq = (window._paq = window._paq || [])
×
NEW
56
      _paq.push(['setConsentGiven'])
×
NEW
57
      _paq.push(['setCustomUrl', location.pathname])
×
58
      //_paq.push(['setDocumentTitle', 'My New Title'])
NEW
59
      _paq.push(['trackPageView'])
×
NEW
60
    }
×
NEW
61
  }, [location.pathname, hasTrackingConsent])
×
62

NEW
63
  const hideHeader = useMemo(
×
NEW
64
    () => location.pathname.endsWith('/annotate'),
×
NEW
65
    [location.pathname]
×
NEW
66
  )
×
NEW
67
  const hideFooter = useMemo(
×
NEW
68
    () => {
×
NEW
69
      return location.pathname.endsWith('/annotate') || location.pathname.startsWith('/article')
×
NEW
70
    },
×
NEW
71
    [location.pathname]
×
NEW
72
  )
×
73

NEW
74
  return (<>
×
NEW
75
    {hideHeader || <Header/>}
×
NEW
76
    <main tabIndex="-1">
×
NEW
77
      <ScrollRestoration/>
×
NEW
78
      <Outlet/>
×
NEW
79
    </main>
×
NEW
80
    {hideFooter || <Footer/>}
×
NEW
81
  </>)
×
NEW
82
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc