Skip to content

Commit 4f150cf

Browse files
authored
Tidying up nearest library and mobile library (#143)
1 parent 1f94200 commit 4f150cf

13 files changed

+1270
-1138
lines changed

package-lock.json

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

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@
4545
"@emotion/react": "^11.14.0",
4646
"@emotion/styled": "^11.14.1",
4747
"@fontsource/roboto": "^5.2.9",
48-
"@mui/icons-material": "^7.3.5",
49-
"@mui/material": "^7.3.5",
50-
"@mui/x-data-grid": "^8.20.0",
51-
"@turf/turf": "^7.3.0",
48+
"@mui/icons-material": "^7.3.6",
49+
"@mui/material": "^7.3.6",
50+
"@mui/x-data-grid": "^8.21.0",
51+
"@turf/turf": "^7.3.1",
5252
"axios": "^1.13.2",
53-
"maplibre-gl": "^5.13.0",
53+
"maplibre-gl": "^5.14.0",
5454
"markdown-to-jsx": "^7.7.17",
5555
"moment": "^2.30.1",
56-
"react": "^19.2.0",
57-
"react-dom": "^19.2.0",
56+
"react": "^19.2.1",
57+
"react-dom": "^19.2.1",
5858
"react-map-gl": "^8.1.0",
59-
"react-router-dom": "^7.9.6",
59+
"react-router-dom": "^7.10.1",
6060
"rrule": "^2.8.1"
6161
}
6262
}

src/Footer.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function Footer () {
2525
>
2626
<Container>
2727
<Grid container spacing={2}>
28-
<Grid xs={12} sm={12} md={4} lg={4} xl={4}>
28+
<Grid size={{ xs: 12, sm: 12, md: 4, lg: 4, xl: 4 }}>
2929
<Typography component='p' variant='h6'>
3030
<MaterialLink
3131
component={Link}
@@ -52,7 +52,7 @@ function Footer () {
5252
</MaterialLink>
5353
</Typography>
5454
</Grid>
55-
<Grid xs={12} sm={12} md={4} lg={4} xl={4}>
55+
<Grid size={{ xs: 12, sm: 12, md: 4, lg: 4, xl: 4 }}>
5656
<Typography component='p' variant='body1'>
5757
In memory of Paul Rowe
5858
<FavoriteIcon

src/Home.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import Typography from '@mui/material/Typography'
99

1010
import Libraries from './Libraries'
1111
import MobileLibraries from './MobileLibraries'
12-
import PostcodeInfo from './PostcodeInfo'
12+
import PostcodeInfoLibrary from './PostcodeInfoLibrary'
1313
import Search from './Search'
1414
import PostcodeServiceInfo from './PostcodeServiceInfo'
15+
import PostcodeInfoMobileStop from './PostcodeInfoMobileStop'
1516

1617
function Home () {
1718
return (
@@ -39,10 +40,13 @@ function Home () {
3940
<Search />
4041
</Box>
4142
<Grid container spacing={2}>
42-
<Grid xs={12} sm={6}>
43-
<PostcodeInfo />
43+
<Grid size={{ xs: 12, sm: 4 }}>
44+
<PostcodeInfoLibrary />
4445
</Grid>
45-
<Grid xs={12} sm={6}>
46+
<Grid size={{ xs: 12, sm: 4 }}>
47+
<PostcodeInfoMobileStop />
48+
</Grid>
49+
<Grid size={{ xs: 12, sm: 4 }}>
4650
<PostcodeServiceInfo />
4751
</Grid>
4852
</Grid>

src/Libraries.jsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ function Libraries () {
4545
pageSize: 5
4646
})
4747

48-
const initialState = {
49-
sorting: {
50-
sortModel
51-
},
52-
pagination: {
53-
paginationModel
54-
},
55-
filter: filterModel
56-
}
57-
5848
const { loadingLibraries, libraries, pageInfo, getLibrariesFromQuery } =
5949
useLibraryQuery()
6050

@@ -216,7 +206,6 @@ function Libraries () {
216206
}}
217207
onRowClick={params => selectLibrary(params.row)}
218208
columns={columns}
219-
initialState={initialState}
220209
/>
221210
</div>
222211
</div>

src/Library.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ function Library () {
6464
</Typography>
6565
</Box>
6666
<Grid container spacing={2}>
67-
<Grid xs={6}>
67+
<Grid size={{ xs: 6 }}>
6868
<LibraryDetails library={library} />
6969
</Grid>
70-
<Grid xs={6}>
70+
<Grid size={{ xs: 6 }}>
7171
<Box sx={{ border: '1px solid', borderColor: grey[200] }}>
7272
<LibraryMap
7373
containerStyle={{

src/MobileLibraries.jsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function MobileLibraries () {
3232
const [filterModel, setFilterModel] = useState({
3333
items: [
3434
{
35-
field: 'localAuthority',
35+
field: 'organisationName',
3636
operator: 'contains',
3737
value: ''
3838
}
@@ -43,16 +43,6 @@ function MobileLibraries () {
4343
pageSize: 5
4444
})
4545

46-
const initialState = {
47-
sorting: {
48-
sortModel
49-
},
50-
pagination: {
51-
paginationModel
52-
},
53-
filter: filterModel
54-
}
55-
5646
const { loadingMobileStops, mobileStops, pageInfo, getMobileStopsFromQuery } =
5747
useMobileStopsQuery()
5848

@@ -210,7 +200,6 @@ function MobileLibraries () {
210200
}}
211201
onRowClick={params => selectStop(params.row)}
212202
columns={columns}
213-
initialState={initialState}
214203
/>
215204
</div>
216205
</div>
Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Card from '@mui/material/Card'
66
import CardActions from '@mui/material/CardActions'
77
import CardContent from '@mui/material/CardContent'
88
import Button from '@mui/material/Button'
9+
import IconButton from '@mui/material/IconButton'
910
import Typography from '@mui/material/Typography'
1011

1112
import ArrowRightIcon from '@mui/icons-material/ArrowRightTwoTone'
@@ -14,13 +15,11 @@ import LocationOnIcon from '@mui/icons-material/LocationOnRounded'
1415

1516
import { lighten } from '@mui/material'
1617

17-
import { grey } from '@mui/material/colors'
18-
1918
import { useSearchStateValue } from './context/searchState'
2019
import { useViewStateValue } from './context/viewState'
2120
import { useApplicationStateValue } from './context/applicationState'
2221

23-
function PostcodeInfo () {
22+
function PostcodeInfoLibrary () {
2423
const [{ searchType, searchPostcode, nearestLibraries }, dispatchSearch] =
2524
useSearchStateValue()
2625
const [{}, dispatchView] = useViewStateValue() //eslint-disable-line
@@ -52,56 +51,61 @@ function PostcodeInfo () {
5251
{searchType === 'postcode' && searchPostcode && nearestLibrary && (
5352
<Card
5453
elevation={0}
55-
sx={{
56-
border: 1,
57-
borderColor: grey[200]
58-
}}
54+
sx={theme => ({
55+
border: 2,
56+
borderColor: lighten(theme.palette.staticLibraries.main, 0.6)
57+
})}
5958
>
6059
<CardContent>
6160
<Typography variant='h5' component='span' color='text.secondary'>
62-
{`${nearestLibrary?.name}`}
61+
{`${Math.round(
62+
nearestLibrary?.distance / 1609
63+
)} miles from nearest library`}
6364
</Typography>
64-
<br />
65-
<Typography variant='subtitle1' color='text.secondary'>
66-
{`${Math.round(nearestLibrary?.distance / 1609)} miles away`}
65+
<Typography
66+
color='staticLibraries.main'
67+
variant='h5'
68+
component='p'
69+
sx={{ fontWeight: 600 }}
70+
>
71+
{`${nearestLibrary?.name}`}
6772
</Typography>
6873
</CardContent>
6974
<CardActions
7075
sx={{
71-
backgroundColor: theme => lighten(grey[200], 0.6)
76+
backgroundColor: theme =>
77+
lighten(theme.palette.staticLibraries.main, 0.9),
78+
justifyContent: 'space-between'
7279
}}
7380
>
7481
<Button
75-
color='primary'
82+
color='secondary'
7683
variant='text'
7784
endIcon={<ArrowRightIcon />}
7885
to={`/service/${serviceSystemName}/${nearestLibrary?.systemName} `}
7986
component={Link}
8087
disableElevation
8188
>
82-
{nearestLibrary?.name}
83-
</Button>
84-
<Button
85-
endIcon={<InfoIcon />}
86-
sx={{ marginLeft: theme => theme.spacing(1) }}
87-
onClick={viewLibrary}
88-
>
89-
Quick info
89+
Library page
9090
</Button>
9191
<Button
9292
size='small'
9393
endIcon={<LocationOnIcon />}
9494
onClick={viewMap}
9595
component={Link}
9696
to='/map'
97+
color='secondary'
9798
>
98-
Map
99+
On map
99100
</Button>
101+
<IconButton onClick={viewLibrary} color='secondary' size='small'>
102+
<InfoIcon />
103+
</IconButton>
100104
</CardActions>
101105
</Card>
102106
)}
103107
</>
104108
)
105109
}
106110

107-
export default PostcodeInfo
111+
export default PostcodeInfoLibrary

src/PostcodeInfoMobileStop.jsx

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import React from 'react'
2+
3+
import { Link } from 'react-router-dom'
4+
5+
import Card from '@mui/material/Card'
6+
import CardActions from '@mui/material/CardActions'
7+
import CardContent from '@mui/material/CardContent'
8+
import Button from '@mui/material/Button'
9+
import IconButton from '@mui/material/IconButton'
10+
import Typography from '@mui/material/Typography'
11+
12+
import ArrowRightIcon from '@mui/icons-material/ArrowRightTwoTone'
13+
import InfoIcon from '@mui/icons-material/InfoOutlined'
14+
import LocationOnIcon from '@mui/icons-material/LocationOnRounded'
15+
16+
import { lighten } from '@mui/material'
17+
18+
import { useSearchStateValue } from './context/searchState'
19+
import { useViewStateValue } from './context/viewState'
20+
import { useApplicationStateValue } from './context/applicationState'
21+
22+
function PostcodeInfoMobileStop () {
23+
const [
24+
{ searchType, searchPostcode, nearestMobileLibraryStops },
25+
dispatchSearch
26+
] = useSearchStateValue()
27+
const [{}, dispatchView] = useViewStateValue() //eslint-disable-line
28+
const [{ serviceLookup }] = useApplicationStateValue()
29+
30+
const nearestMobileLibraryStop = nearestMobileLibraryStops?.[0]
31+
32+
const viewStop = () => {
33+
dispatchSearch({
34+
type: 'SetCurrentStop',
35+
currentStopId: nearestMobileLibraryStop.id,
36+
currentPoint: [
37+
nearestMobileLibraryStop.longitude,
38+
nearestMobileLibraryStop.latitude
39+
]
40+
})
41+
dispatchView({ type: 'SetStopDialog', stopDialogOpen: true })
42+
}
43+
44+
const viewMap = () => {
45+
dispatchView({
46+
type: 'FlyTo',
47+
mapFlyToPosition: [
48+
nearestMobileLibraryStop.longitude,
49+
nearestMobileLibraryStop.latitude
50+
],
51+
mapZoom: 18
52+
})
53+
}
54+
55+
const serviceSystemName =
56+
serviceLookup[nearestMobileLibraryStop?.organisationCode]?.systemName
57+
58+
return (
59+
<>
60+
{searchType === 'postcode' && searchPostcode && nearestMobileLibraryStop && (
61+
<Card
62+
elevation={0}
63+
sx={theme => ({
64+
border: 2,
65+
borderColor: lighten(theme.palette.mobileLibraries.main, 0.6)
66+
})}
67+
>
68+
<CardContent>
69+
<Typography variant='h5' component='span' color='text.secondary'>
70+
{`${Math.round(
71+
nearestMobileLibraryStop?.distance / 1609
72+
)} miles from nearest mobile`}
73+
</Typography>
74+
<Typography
75+
color='mobileLibraries.main'
76+
variant='h5'
77+
component='p'
78+
sx={{ fontWeight: 600 }}
79+
>
80+
{`${nearestMobileLibraryStop?.name}`}
81+
</Typography>
82+
</CardContent>
83+
<CardActions
84+
sx={{
85+
backgroundColor: theme =>
86+
lighten(theme.palette.mobileLibraries.main, 0.9),
87+
justifyContent: 'space-between'
88+
}}
89+
>
90+
<Button
91+
color='secondary'
92+
variant='text'
93+
endIcon={<ArrowRightIcon />}
94+
to={`/service/${serviceSystemName}/${nearestMobileLibraryStop?.systemName} `}
95+
component={Link}
96+
disableElevation
97+
>
98+
Stop page
99+
</Button>
100+
<Button
101+
size='small'
102+
endIcon={<LocationOnIcon />}
103+
onClick={viewMap}
104+
component={Link}
105+
to='/map'
106+
color='secondary'
107+
>
108+
On map
109+
</Button>
110+
<IconButton onClick={viewStop} color='secondary' size='small'>
111+
<InfoIcon />
112+
</IconButton>
113+
</CardActions>
114+
</Card>
115+
)}
116+
</>
117+
)
118+
}
119+
120+
export default PostcodeInfoMobileStop

0 commit comments

Comments
 (0)