Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TOS Link from Config #1080

Merged
merged 10 commits into from
Dec 7, 2023
5 changes: 5 additions & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ api:
# mobile: BOTH_LOCATIONS_CHANGED
# default: ONE_LOCATION_CHANGED

### If Terms of Service is hosted at an outside link, provide it here. If translations
### are provided, host each translation by including the language code (eg. en-US, fr, es)
### in the URL and use {locale} to represent the language in the link below
# termsOfServiceLink:

### The default query parameters can be overridden be uncommenting this object.
### Note: the override values must be valid values within otp-ui's query-params.js
# defaultQueryParams:
Expand Down
19 changes: 13 additions & 6 deletions lib/components/user/terms-of-use-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { connect } from 'react-redux'
import { FormattedMessage, useIntl } from 'react-intl'
import React, { FormEventHandler } from 'react'

import { AppReduxState } from '../../util/state-types'
import { LinkOpensNewWindow } from '../util/externalLink'
import {
TERMS_OF_SERVICE_PATH,
Expand All @@ -16,11 +17,15 @@ const TermsOfUsePane = ({
disableCheckTerms,
handleBlur,
handleChange,
locale,
termsOfServiceLink,
amy-corson-ibigroup marked this conversation as resolved.
Show resolved Hide resolved
values: userData
}: {
disableCheckTerms: boolean
handleBlur: () => void
handleChange: FormEventHandler<Checkbox>
locale: string
termsOfServiceLink?: string
values: {
hasConsentedToTerms: boolean
storeTripHistory: boolean
Expand All @@ -29,6 +34,10 @@ const TermsOfUsePane = ({
const intl = useIntl()
const { hasConsentedToTerms, storeTripHistory } = userData

const TOSLinkWithI18n = termsOfServiceLink?.replace('{locale}', locale)

const termsURL = TOSLinkWithI18n || `/#${TERMS_OF_SERVICE_PATH}`

return (
<div>
<ControlLabel>
Expand All @@ -46,11 +55,7 @@ const TermsOfUsePane = ({
id="components.TermsOfUsePane.termsOfServiceStatement"
values={{
termsOfUseLink: (contents: JSX.Element) => (
<LinkOpensNewWindow
contents={contents}
inline
url={`/#${TERMS_OF_SERVICE_PATH}`}
/>
<LinkOpensNewWindow contents={contents} inline url={termsURL} />
)
}}
/>
Expand Down Expand Up @@ -97,8 +102,10 @@ const TermsOfUsePane = ({
</div>
)
}
const mapStateToProps = (state: any) => {
const mapStateToProps = (state: AppReduxState) => {
return {
locale: state.otp.ui?.locale,
termsOfServiceLink: state.otp.config.termsOfServiceLink,
termsOfStorageSet: state.otp.config.persistence?.terms_of_storage
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/util/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ export type PersistenceConfig = (
| MiddlewarePersistenceConfig
) & {
enabled?: boolean
// eslint-disable-next-line camelcase
terms_of_storage?: boolean
}

/** Popup target settings */
Expand Down Expand Up @@ -370,6 +372,8 @@ export interface AppConfig {
/** Whether to show the x minutes late/early in the itinerary body */
showScheduleDeviation?: boolean
stopViewer?: StopViewerConfig
/** Externally hosted terms of service URL */
termsOfServiceLink?: string
/** App title shown in the browser title bar. */
title?: string
transitOperators?: TransitOperatorConfig[]
Expand Down
Loading