Skip to content

Commit

Permalink
Add environment variables for flexible map settings
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Feb 13, 2025
1 parent 1bc7960 commit 0428a42
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions frontend/.env.docker.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ VITE_MI_MIN_LOCATIONS=4
VITE_MI_CONTACT_EMAIL=info@movinin.io
VITE_MI_WEBSITE_NAME="Movin' In"
VITE_MI_HIDE_AGENCIES=false
VITE_MI_MAP_LATITUDE=36.966428
VITE_MI_MAP_LONGITUDE=-95.844032
VITE_MI_MAP_ZOOM=5
3 changes: 3 additions & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ VITE_MI_MIN_LOCATIONS=4
VITE_MI_CONTACT_EMAIL=info@movinin.io
VITE_MI_WEBSITE_NAME="Movin' In"
VITE_MI_HIDE_AGENCIES=false
VITE_MI_MAP_LATITUDE=36.966428
VITE_MI_MAP_LONGITUDE=-95.844032
VITE_MI_MAP_ZOOM=5
2 changes: 1 addition & 1 deletion frontend/src/components/MapDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const MapDialog = ({
<DialogContent className="map-dialog-content">
{location && (
<Map
position={[location.latitude || 36.966428, location.longitude || -95.844032]}
position={[location.latitude || env.MAP_LATITUDE, location.longitude || env.MAP_LONGITUDE]}
initialZoom={location.latitude && location.longitude ? 10 : 2.5}
locations={[location]}
className="map"
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/config/env.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ const env = {
MIN_LOCATIONS: Number.parseInt(String(import.meta.env.VITE_MI_MIN_LOCATIONS), 10) || 4,
CONTACT_EMAIL: import.meta.env.VITE_MI_CONTACT_EMAIL,
HIDE_AGENCIES: (import.meta.env.VITE_MI_HIDE_AGENCIES && import.meta.env.VITE_MI_HIDE_AGENCIES.toLowerCase()) === 'true',
MAP_LATITUDE: Number(String(import.meta.env.VITE_MI_MAP_LATITUDE || '36.966428')),
MAP_LONGITUDE: Number(String(import.meta.env.VITE_MI_MAP_LONGITUDE || '-95.844032')),
MAP_ZOOM: Number(String(import.meta.env.VITE_MI_MAP_ZOOM || '5')),
}

export default env
2 changes: 1 addition & 1 deletion frontend/src/pages/Checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ const Checkout = () => {

{(location.latitude && location.longitude) && (
<Map
position={[location.latitude || 36.966428, location.longitude || -95.844032]}
position={[location.latitude || env.MAP_LATITUDE, location.longitude || env.MAP_LONGITUDE]}
initialZoom={location.latitude && location.longitude ? 10 : 2.5}
locations={[location]}
className="map"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ const Home = () => {
<div className="home-map">
<Map
title={strings.MAP_TITLE}
position={new L.LatLng(36.966428, -95.844032)}
initialZoom={5}
position={new L.LatLng(env.MAP_LATITUDE, env.MAP_LONGITUDE)}
initialZoom={env.MAP_ZOOM}
locations={locations}
onSelelectLocation={async (locationId) => {
setLocation(locationId)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/Locations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const Locations = () => {
<Layout onLoad={onLoad} strict={false}>
<div className="locations">
<Map
position={new L.LatLng(36.966428, -95.844032)}
initialZoom={5}
position={new L.LatLng(env.MAP_LATITUDE, env.MAP_LONGITUDE)}
initialZoom={env.MAP_ZOOM}
locations={locations}
onSelelectLocation={async (locationId) => {
setLocation(locationId)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const Properties = () => {
<>
{location.latitude && location.longitude && (
<Map
position={[location.latitude || 36.966428, location.longitude || -95.844032]}
position={[location.latitude || env.MAP_LATITUDE, location.longitude || env.MAP_LONGITUDE]}
initialZoom={location.latitude && location.longitude ? 10 : 2.5}
locations={[location]}
className="map"
Expand Down

0 comments on commit 0428a42

Please sign in to comment.