Skip to content

Commit

Permalink
fix: get maps api key from server (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludtkemorgan authored Dec 1, 2023
1 parent 5330f01 commit 23ae6ed
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
1 change: 0 additions & 1 deletion sites/public/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module.exports = withBundleAnalyzer(
env: {
backendApiBase: BACKEND_API_BASE, // this has to be set for tests
backendProxyBase: process.env.BACKEND_PROXY_BASE,
googleMapsApiKey: process.env.GOOGLE_MAPS_API_KEY,
listingsQuery: LISTINGS_QUERY,
listingPhotoSize: process.env.LISTING_PHOTO_SIZE || "1302",
mapBoxToken: MAPBOX_TOKEN,
Expand Down
26 changes: 14 additions & 12 deletions sites/public/src/components/listings/ListingsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,21 @@ const ListingsList = (props: ListingsListProps) => {
const infoCards =
props.currentPage == props.lastPage || props.lastPage == 0 ? (
<div>
<InfoCard
title={t("t.signUpForAlerts")}
subtitle={t("t.subscribeToListingAlerts")}
className="is-normal-primary-lighter"
>
<LinkButton
href={process.env.notificationsSignUpUrl}
newTab={true}
className="is-primary"
{process.env.notificationsSignUpUrl && (
<InfoCard
title={t("t.signUpForAlerts")}
subtitle={t("t.subscribeToListingAlerts")}
className="is-normal-primary-lighter"
>
{t("t.signUp")}
</LinkButton>
</InfoCard>
<LinkButton
href={process.env.notificationsSignUpUrl}
newTab={true}
className="is-primary"
>
{t("t.signUp")}
</LinkButton>
</InfoCard>
)}
<InfoCard
title={t("t.needHelp")}
subtitle={t("t.emergencyShelter")}
Expand Down
13 changes: 11 additions & 2 deletions sites/public/src/pages/listings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ListingsSearchCombined, {
locations,
} from "../components/listings/search/ListingsSearchCombined"
import { FormOption } from "../components/listings/search/ListingsSearchModal"
import { runtimeConfig } from "../lib/runtime-config"

import Layout from "../layouts/application"

Expand All @@ -27,7 +28,6 @@ export default function ListingsPage(props: ListingsProps) {
const listingsEndpoint = `${process.env.backendProxyBase || process.env.backendApiBase}${
process.env.listingsQuery
}`
const googleMapsApiKey = process.env.googleMapsApiKey

// override the search value if present in url
if (searchParam) {
Expand All @@ -42,7 +42,7 @@ export default function ListingsPage(props: ListingsProps) {
<MetaTags title={t("nav.siteTitle")} image={metaImage} description={metaDescription} />
<ListingsSearchCombined
listingsEndpoint={listingsEndpoint}
googleMapsApiKey={googleMapsApiKey}
googleMapsApiKey={props.googleMapsApiKey}
searchString={searchString}
bedrooms={props.bedrooms}
bathrooms={props.bathrooms}
Expand All @@ -51,3 +51,12 @@ export default function ListingsPage(props: ListingsProps) {
</Layout>
)
}

export function getServerSideProps() {
return {
props: {
listingsEndpoint: runtimeConfig.getListingServiceUrl(),
googleMapsApiKey: runtimeConfig.getGoogleMapsApiKey(),
},
}
}

0 comments on commit 23ae6ed

Please sign in to comment.