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

hasadna / open-bus-map-search / 9631367286

23 Jun 2024 06:19AM UTC coverage: 4.937%. Remained the same
9631367286

Pull #790

github

web-flow
Merge 35c886e4a into fa21f203f
Pull Request #790: feat: make us SEO compatible (#745)

37 of 619 branches covered (5.98%)

Branch coverage included in aggregate %.

0 of 1 new or added line in 1 file covered. (0.0%)

81 of 1771 relevant lines covered (4.57%)

1.82 hits per line

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

0.0
/src/routes/index.tsx
1
import { Navigate, Route, createBrowserRouter, createRoutesFromElements } from 'react-router-dom'
×
2
import { lazy } from 'react'
×
3

4
const HomePage = lazy(() => import('../pages/homepage/HomePage'))
×
5
const DashboardPage = lazy(() => import('../pages/dashboard/DashboardPage'))
×
6
const TimelinePage = lazy(() => import('../pages/historicTimeline'))
×
7
const GapsPage = lazy(() => import('../pages/gaps'))
×
8
const GapsPatternsPage = lazy(() => import('../pages/gapsPatterns'))
×
9
const TimeBasedMapPage = lazy(() => import('../pages/timeBasedMap'))
×
10
const SingleLineMapPage = lazy(() => import('../pages/singleLineMap'))
×
11
const About = lazy(() => import('../pages/about'))
×
12
const Profile = lazy(() => import('../pages/lineProfile/LineProfile'))
×
13
const BugReportForm = lazy(() => import('../pages/BugReportForm '))
×
14
const DataResearch = lazy(() =>
×
15
  import('../pages/DataResearch/DataResearch').then((m) => ({
×
16
    default: m.DataResearch,
17
  })),
18
)
19
const PublicAppeal = lazy(() => import('../pages/publicAppeal'))
×
20

21
import {
×
22
  HomeOutlined,
23
  RadarChartOutlined,
24
  InfoCircleOutlined,
25
  DollarOutlined,
26
  HeatMapOutlined,
27
  LaptopOutlined,
28
  FieldTimeOutlined,
29
  BugOutlined,
30
  BarChartOutlined,
31
  LineChartOutlined,
32
  GithubOutlined,
33
} from '@ant-design/icons'
34
import PsychologyIcon from '@mui/icons-material/Psychology'
×
35
import { MainRoute } from './MainRoute'
×
36
import { ErrorPage } from 'src/pages/ErrorPage'
×
37

38
export const PAGES = [
×
39
  {
40
    label: 'homepage_title',
41
    path: '/',
42
    icon: <HomeOutlined />,
43
    element: <HomePage />,
44
  },
45
  {
46
    label: 'dashboard_page_title',
47
    path: '/dashboard',
48
    icon: <LaptopOutlined />,
49
    element: <DashboardPage />,
50
  },
51
  {
52
    label: 'timeline_page_title',
53
    path: '/timeline',
54
    searchParamsRequired: true,
55
    icon: <FieldTimeOutlined />,
56
    element: <TimelinePage />,
57
  },
58
  {
59
    label: 'gaps_page_title',
60
    path: '/gaps',
61
    searchParamsRequired: true,
62
    icon: <BarChartOutlined />,
63
    element: <GapsPage />,
64
  },
65
  {
66
    label: 'gaps_patterns_page_title',
67
    path: '/gaps_patterns',
68
    icon: <LineChartOutlined />,
69
    element: <GapsPatternsPage />,
70
  },
71
  {
72
    label: 'time_based_map_page_title',
73
    path: '/map',
74
    icon: <HeatMapOutlined />,
75
    element: <TimeBasedMapPage />,
76
  },
77
  {
78
    label: 'singleline_map_page_title',
79
    path: '/single-line-map',
80
    searchParamsRequired: true,
81
    icon: <RadarChartOutlined />,
82
    element: <SingleLineMapPage />,
83
  },
84
  {
85
    label: 'about_title',
86
    path: '/about',
87
    icon: <InfoCircleOutlined />,
88
    element: <About />,
89
  },
90
  {
91
    label: 'donate_title',
92
    path: 'https://www.jgive.com/new/he/ils/donation-targets/3268#donation-modal',
93
    icon: <DollarOutlined />,
94
    element: null,
95
  },
96
  {
97
    label: 'public_appeal_title',
98
    path: '/public-appeal',
99
    icon: <PsychologyIcon />,
100
    element: <PublicAppeal />,
101
  },
102
] as const
103

104
export const HEADER_LINKS = [
×
105
  {
106
    label: 'report_a_bug_title',
107
    path: '/report-a-bug',
108
    icon: <BugOutlined />,
109
    element: <BugReportForm />,
110
  },
111
  {
112
    label: 'github_link',
113
    path: 'https://github.com/hasadna/open-bus-map-search',
114
    icon: <GithubOutlined />,
115
    element: null,
116
  },
117
] as const
118

119
const HIDDEN_PAGES = [
×
120
  {
121
    label: 'data-research',
122
    path: '/data-research',
123
    icon: <InfoCircleOutlined />,
124
    element: <DataResearch />,
125
  },
126
] as const
127

NEW
128
export const getRoutesList = () => {
×
129
  const pages = [...PAGES, ...HIDDEN_PAGES, ...HEADER_LINKS]
×
130
  const RedirectToHomepage = () => <Navigate to={pages[0].path} replace />
×
131
  const routes = pages.filter((r) => r.element)
×
132
  return (
×
133
    <Route element={<MainRoute />}>
134
      {routes.map(({ path, element }) => (
135
        <Route key={path} path={path} element={element} ErrorBoundary={ErrorPage} />
×
136
      ))}
137
      <Route
138
        path="/profile/:gtfsRideGtfsRouteId"
139
        key={'/profile/:gtfsRideGtfsRouteId'}
140
        element={<Profile />}
141
        ErrorBoundary={ErrorPage}
142
        loader={async ({ params: { gtfsRideGtfsRouteId } }) => {
143
          const resp = await fetch(
×
144
            `https://open-bus-stride-api.hasadna.org.il/gtfs_routes/get?id=${gtfsRideGtfsRouteId}`,
145
          )
146
          // eslint-disable-next-line @typescript-eslint/no-explicit-any
147
          const gtfs_route = await resp.json()
×
148
          // eslint-disable-next-line @typescript-eslint/no-unsafe-return
149
          return gtfs_route
×
150
        }}
151
      />
152
      <Route path="*" element={<RedirectToHomepage />} key="back" />
153
    </Route>
154
    // </Suspense>
155
  )
156
}
157

158
window.addEventListener('vite:preloadError', () => {
×
159
  window.location.reload() // in case new version is released, we will need to refresh the page. see https://vitejs.dev/guide/build#load-error-handling
×
160
})
161

162
const routes = createRoutesFromElements(getRoutesList())
×
163

164
const router = createBrowserRouter(routes)
×
165

166
export default router
×
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