Skip to content

Commit c71349c

Browse files
authored
Merge pull request #116 from LibrariesHacked/115-refresh-packages-and-styling
Fixing bugs to make map page work again
2 parents 697869a + fd86e4a commit c71349c

File tree

14 files changed

+2482
-1612
lines changed

14 files changed

+2482
-1612
lines changed

package-lock.json

Lines changed: 2193 additions & 1348 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,29 @@
55
"type": "module",
66
"homepage": "https://www.mobilelibraries.org",
77
"dependencies": {
8-
"@emotion/react": "^11.11.4",
9-
"@emotion/styled": "^11.11.0",
8+
"@emotion/react": "^11.14.0",
9+
"@emotion/styled": "^11.14.0",
1010
"@fontsource/roboto": "^4.5.8",
11-
"@mui/icons-material": "^5.15.13",
12-
"@mui/material": "^5.15.13",
13-
"@mui/x-data-grid": "^6.19.6",
14-
"axios": "^1.7.4",
11+
"@mui/icons-material": "^5.16.14",
12+
"@mui/material": "^5.16.14",
13+
"@mui/x-data-grid": "^6.20.4",
14+
"axios": "^1.7.9",
1515
"maplibre-gl": "^2.4.0",
16-
"markdown-to-jsx": "^7.4.3",
16+
"markdown-to-jsx": "^7.7.3",
1717
"moment": "^2.30.1",
18-
"react": "^18.2.0",
18+
"react": "^18.3.1",
1919
"react-carbonbadge": "^2.0.0",
20-
"react-dom": "^18.2.0",
21-
"react-map-gl": "^7.1.7",
22-
"react-router-dom": "^6.22.3",
20+
"react-dom": "^18.3.1",
21+
"react-map-gl": "^7.1.9",
22+
"react-router-dom": "^6.29.0",
2323
"rrule": "^2.8.1"
2424
},
2525
"scripts": {
2626
"start": "vite",
2727
"build": "vite build",
2828
"serve": "vite preview",
2929
"predeploy": "vite build",
30-
"deploy": "gh-pages -d build",
31-
"analyze": "source-map-explorer 'build/static/js/*.js'"
30+
"deploy": "gh-pages -d build"
3231
},
3332
"eslintConfig": {
3433
"extends": "react-app",
@@ -39,7 +38,7 @@
3938
}
4039
},
4140
"devDependencies": {
42-
"@vitejs/plugin-react": "^4.2.1",
41+
"@vitejs/plugin-react": "^4.3.4",
4342
"gh-pages": "^5.0.0",
4443
"standard": "^16.0.4",
4544
"vite": "^5.4.14"

src/Footer.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const Footer = () => {
5858
>
5959
<Carbonbadge />
6060
</Grid>
61-
<Grid item xs={12} sm={12} md={3} lg={4} xl={4}></Grid>
61+
<Grid item xs={12} sm={12} md={3} lg={4} xl={4} />
6262
</Grid>
6363
)
6464
}

src/Header.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const Header = () => {
4444
<Tab
4545
icon={<ManageSearchRoundedIcon />}
4646
iconPosition='start'
47-
label={'Search'}
47+
label='Search'
4848
value='/'
4949
component={Link}
5050
to='/'
@@ -59,7 +59,7 @@ const Header = () => {
5959
<Tab
6060
icon={<AirportShuttleRoundedIcon />}
6161
iconPosition='start'
62-
label={'Tracker'}
62+
label='Tracker'
6363
value='/mobiles'
6464
component={Link}
6565
to='/mobiles'
@@ -74,7 +74,7 @@ const Header = () => {
7474
<Tab
7575
icon={<PlaceRoundedIcon />}
7676
iconPosition='start'
77-
label={'Map'}
77+
label='Map'
7878
value='/map'
7979
component={Link}
8080
to='/map'

src/MobileCard.jsx

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,11 @@ const MobileCard = props => {
103103
let statusMessage = null
104104
if (location) {
105105
const status = location.getStatus()
106-
if (status && status.type === 'offRoad')
107-
statusMessage = offRoadMessage(status)
108-
if (status && status.type === 'preRoute')
109-
statusMessage = preRouteMessage(status)
110-
if (status && status.type === 'atStop')
111-
statusMessage = atStopMessage(status)
112-
if (status && status.type === 'betweenStops')
113-
statusMessage = betweenStopsMessage(status)
114-
if (status && status.type === 'postRoute')
115-
statusMessage = postRouteMessage(status)
106+
if (status && status.type === 'offRoad') { statusMessage = offRoadMessage(status) }
107+
if (status && status.type === 'preRoute') { statusMessage = preRouteMessage(status) }
108+
if (status && status.type === 'atStop') { statusMessage = atStopMessage(status) }
109+
if (status && status.type === 'betweenStops') { statusMessage = betweenStopsMessage(status) }
110+
if (status && status.type === 'postRoute') { statusMessage = postRouteMessage(status) }
116111
}
117112

118113
const bull = <span></span>
@@ -156,16 +151,18 @@ const MobileCard = props => {
156151
View stops
157152
</Button>
158153
</Tooltip>
159-
{mobile.timetable ? (
160-
<>
161-
<Divider />
162-
<Tooltip title='Website timetable'>
163-
<IconButton onClick={() => this.goToWebsite()} size='large'>
164-
<WebIcon />
165-
</IconButton>
166-
</Tooltip>
167-
</>
168-
) : null}
154+
{mobile.timetable
155+
? (
156+
<>
157+
<Divider />
158+
<Tooltip title='Website timetable'>
159+
<IconButton onClick={() => this.goToWebsite()} size='large'>
160+
<WebIcon />
161+
</IconButton>
162+
</Tooltip>
163+
</>
164+
)
165+
: null}
169166
</CardActions>
170167
</Card>
171168
)

src/MobileLibraryDetails.jsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ const MobileLibraryDetails = () => {
2525
const [mobileLibrary, setMobileLibrary] = useState({})
2626

2727
useEffect(() => {
28-
if (currentMobileLibraryId != null && mobileLookup)
29-
setMobileLibrary(mobileLookup[currentMobileLibraryId])
28+
if (currentMobileLibraryId != null && mobileLookup) { setMobileLibrary(mobileLookup[currentMobileLibraryId]) }
3029
}, [currentMobileLibraryId, mobileLookup])
3130

3231
const close = () => {
@@ -48,17 +47,19 @@ const MobileLibraryDetails = () => {
4847
BackdropProps={{ invisible: true }}
4948
PaperProps={{ elevation: 0 }}
5049
>
51-
{mobileLibrary ? (
52-
<>
53-
<DialogTitle id='dlg-title'>{mobileLibrary.name}</DialogTitle>
54-
<DialogContent>
55-
<ListSubheader disableSticky>Actions</ListSubheader>
56-
<div />
57-
</DialogContent>
58-
</>
59-
) : (
60-
<CircularProgress color='primary' size={30} />
61-
)}
50+
{mobileLibrary
51+
? (
52+
<>
53+
<DialogTitle id='dlg-title'>{mobileLibrary.name}</DialogTitle>
54+
<DialogContent>
55+
<ListSubheader disableSticky>Actions</ListSubheader>
56+
<div />
57+
</DialogContent>
58+
</>
59+
)
60+
: (
61+
<CircularProgress color='primary' size={30} />
62+
)}
6263
<DialogActions>
6364
<Button
6465
onClick={() => close()}

src/MobileMap.jsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { useEffect, useState } from 'react'
22

3+
import moment from 'moment'
4+
35
import Box from '@mui/material/Box'
46
import Fab from '@mui/material/Fab'
57
import Tooltip from '@mui/material/Tooltip'
@@ -151,19 +153,22 @@ const MobileMap = () => {
151153
const millisecondsPassed = moment(Date.now()).diff(l.updated)
152154
const index = Math.round(millisecondsPassed / 500)
153155
const coords = l.routeSection.coordinates
154-
if (coords.length > index && index > 0)
156+
if (coords.length > index && index > 0) {
155157
locationPoint = coords[index]
156-
if (coords.length <= index && index > 0)
158+
}
159+
if (coords.length <= index && index > 0) {
157160
locationPoint = coords[coords.length - 1]
161+
}
158162
}
159163
const mobile = mobileLookup[l.mobileId]
160164
const organisation = mobile
161165
? organisationLookup[mobile.organisationId]
162166
: null
163167
return (
164168
<Marker
165-
key={'mkr_' + l.id}
166-
coordinates={locationPoint}
169+
key={'mkr_' + l.mobileId}
170+
longitude={locationPoint[0]}
171+
latitude={locationPoint[1]}
167172
anchor='bottom'
168173
>
169174
<MobileAvatar

src/Mobiles.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ const Mobiles = () => {
2424
mobileLocationLookup,
2525
mobilesNearestLookup,
2626
routeLookup
27-
},
28-
dispatchApplication
27+
}
2928
] = useApplicationStateValue() //eslint-disable-line
3029
const [
3130
{
@@ -35,8 +34,7 @@ const Mobiles = () => {
3534
searchType,
3635
searchDistance,
3736
searchPostcode
38-
},
39-
dispatchSearch
37+
}
4038
] = useSearchStateValue() //eslint-disable-line
4139
const [{ loadingMobileLocations }, dispatchView] = useViewStateValue() //eslint-disable-line
4240

@@ -85,21 +83,24 @@ const Mobiles = () => {
8583
routeFilter.length > 0 ? routeLookup[routeFilter[0]].name : ''
8684

8785
let title = 'Mobile libraries'
88-
if (organisationName !== '')
86+
if (organisationName !== '') {
8987
title = 'Mobile libraries serving ' + organisationName
88+
}
9089
if (mobileName !== '') title = organisationName + ' ' + mobileName
9190
if (routeName !== '') title = organisationName + ' ' + routeName
92-
if (searchPostcode !== '')
91+
if (searchPostcode !== '') {
9392
title =
9493
'Mobile libraries with stops within ' +
9594
Math.round(searchDistance / 1609) +
9695
' mile(s) of ' +
9796
searchPostcode
98-
if (searchType === 'gps')
97+
}
98+
if (searchType === 'gps') {
9999
title =
100100
'Mobile libraries with stops within ' +
101101
Math.round(searchDistance / 1609) +
102102
' mile(s) of your location'
103+
}
103104

104105
const displayMobiles = openTab === 0 ? activeMobiles : filteredMobiles
105106
const mobilesView = displayMobiles

src/PostcodeSearch.jsx

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -163,55 +163,61 @@ const PostcodeSearch = () => {
163163
fontWeight: 700
164164
}}
165165
/>
166-
{!loadingPostcode && !loadingLocation ? (
167-
<Tooltip title='Search by postcode'>
168-
<IconButton
169-
aria-label='Search'
170-
color='inherit'
171-
onClick={() => postcodeSearch()}
172-
size='large'
173-
disabled={loadingPostcode || loadingLocation}
174-
>
175-
<SearchIcon />
176-
</IconButton>
177-
</Tooltip>
178-
) : (
179-
<SearchBox>
180-
<CircularProgress color='inherit' size={22} />
181-
</SearchBox>
182-
)}
183-
<Tooltip title='Use your current location'>
184-
<>
185-
{!loadingLocation && !loadingPostcode ? (
166+
{!loadingPostcode && !loadingLocation
167+
? (
168+
<Tooltip title='Search by postcode'>
186169
<IconButton
187-
aria-label='Search by current location'
170+
aria-label='Search'
188171
color='inherit'
189-
onClick={() => getLocation()}
172+
onClick={() => postcodeSearch()}
190173
size='large'
191174
disabled={loadingPostcode || loadingLocation}
192175
>
193-
<MyLocationIcon />
176+
<SearchIcon />
194177
</IconButton>
195-
) : (
196-
<SearchBox>
197-
<CircularProgress color='inherit' size={22} />
198-
</SearchBox>
178+
</Tooltip>
179+
)
180+
: (
181+
<SearchBox>
182+
<CircularProgress color='inherit' size={22} />
183+
</SearchBox>
199184
)}
185+
<Tooltip title='Use your current location'>
186+
<>
187+
{!loadingLocation && !loadingPostcode
188+
? (
189+
<IconButton
190+
aria-label='Search by current location'
191+
color='inherit'
192+
onClick={() => getLocation()}
193+
size='large'
194+
disabled={loadingPostcode || loadingLocation}
195+
>
196+
<MyLocationIcon />
197+
</IconButton>
198+
)
199+
: (
200+
<SearchBox>
201+
<CircularProgress color='inherit' size={22} />
202+
</SearchBox>
203+
)}
200204
</>
201205
</Tooltip>
202-
{searchType === 'postcode' ? (
203-
<Tooltip title='Clear search'>
204-
<IconButton
205-
color='inherit'
206-
aria-label='Clear search'
207-
onClick={() => clearSearch()}
208-
size='large'
209-
disabled={loadingPostcode || loadingLocation}
210-
>
211-
<ClearIcon />
212-
</IconButton>
213-
</Tooltip>
214-
) : null}
206+
{searchType === 'postcode'
207+
? (
208+
<Tooltip title='Clear search'>
209+
<IconButton
210+
color='inherit'
211+
aria-label='Clear search'
212+
onClick={() => clearSearch()}
213+
size='large'
214+
disabled={loadingPostcode || loadingLocation}
215+
>
216+
<ClearIcon />
217+
</IconButton>
218+
</Tooltip>
219+
)
220+
: null}
215221
</Box>
216222
)
217223
}

0 commit comments

Comments
 (0)