Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions i18n/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ common:
walk: Walk
notifications:
email: email
push: push notifications
sms: SMS
places:
custom: custom
Expand Down Expand Up @@ -413,8 +412,6 @@ components:
description: The content you requested is not available.
header: Content not found
NotificationPrefsPane:
devicesRegistered: "{count, plural, one {# device} other {# devices}} registered"
noDeviceForPush: Register your device using the mobile app to access push notifications.
notificationChannelPrompt: "Receive notifications about your saved trips via:"
OTP2ErrorRenderer:
LOCATION_NOT_FOUND:
Expand Down
3 changes: 0 additions & 3 deletions i18n/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ common:
walk: Caminar
notifications:
email: correo electrónico
push: notificaciones push
sms: Mensaje de texto
places:
custom: personalizado
Expand Down Expand Up @@ -412,8 +411,6 @@ components:
description: El contenido que ha solicitado no está disponible.
header: No se encontró el contenido
NotificationPrefsPane:
devicesRegistered: "{count, plural, one {# device} other {# devices}} registrado"
noDeviceForPush: Regístrese con la aplicación móvil para acceder a esta configuración.
notificationChannelPrompt: "Recibir notificaciones para sus viajes guardados por:"
OTP2ErrorRenderer:
LOCATION_NOT_FOUND:
Expand Down
5 changes: 0 additions & 5 deletions i18n/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ common:
walk: À pied
notifications:
email: e-mail
push: notifications push
sms: SMS
places:
custom: divers
Expand Down Expand Up @@ -424,10 +423,6 @@ components:
description: Le contenu que vous avez demandé n'est pas disponible.
header: Contenu introuvable
NotificationPrefsPane:
devicesRegistered: >-
{count, plural, one {# appareil enregistré} other {# appareils
enregistrés}}
noDeviceForPush: Inscrivez-vous avec l'application mobile pour accéder à ce paramètre.
notificationChannelPrompt: "Recevoir des notifications sur vos trajets par :"
OTP2ErrorRenderer:
LOCATION_NOT_FOUND:
Expand Down
3 changes: 1 addition & 2 deletions i18n/i18n-exceptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"groups": {
"common.notifications.*": [
"email",
"sms",
"push"
"sms"
],
"components.UserAccountScreen.fields.*": [
"add-companion-form",
Expand Down
7 changes: 2 additions & 5 deletions i18n/ko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ common:
walk: 걷기
notifications:
email: 이메일
push: 푸시 알림
sms: SMS
places:
custom: 사용자 정의
Expand Down Expand Up @@ -370,8 +369,6 @@ components:
description: 요청한 콘텐츠를 사용할 수 없습니다.
header: 콘텐츠를 찾을 수 없음
NotificationPrefsPane:
devicesRegistered: "{count, plural, one {# device} other {# devices}} 등록됨"
noDeviceForPush: 푸시 알림을 이용하려면 모바일 앱을 사용해 기기를 등록하십시오.
notificationChannelPrompt: "저장된 여행의 알림을 받는 방법:"
OTP2ErrorRenderer:
LOCATION_NOT_FOUND:
Expand All @@ -392,8 +389,8 @@ components:
header: 탐색 창 내 대중교통 연결편 없음
OUTSIDE_BOUNDS:
body: >-
{inputFields} {inputFieldsCount, plural, =0 {} one {위치는} other {위치들은}} 트립
플래너 범위가 아닙니다.
{inputFields} {inputFieldsCount, plural, =0 {} one {위치는} other {위치들은}}
트립 플래너 범위가 아닙니다.
header: 범위 밖 위치
OUTSIDE_SERVICE_PERIOD:
body: 지정된 날짜가 현재 트립 플래너에 로드된 데이터 범위를 벗어납니다.
Expand Down
8 changes: 1 addition & 7 deletions i18n/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ common:
walk: Пешком
notifications:
email: электронная почта
push: всплывающие уведомления
sms: SMS
places:
custom: пользовательское
Expand Down Expand Up @@ -409,10 +408,6 @@ components:
description: Запрашиваемое содержимое недоступно.
header: Содержимое не обнаружено
NotificationPrefsPane:
devicesRegistered: "{count, plural, one {# устройство} other {# устройства}} зарегистрированы"
noDeviceForPush: >-
Зарегистрируйте свое устройство с помощью мобильного приложения, чтобы
получать всплывающие уведомления.
notificationChannelPrompt: "Получайте уведомления о сохраненных поездках через:"
OTP2ErrorRenderer:
LOCATION_NOT_FOUND:
Expand Down Expand Up @@ -741,8 +736,7 @@ components:
TripSummaryPane:
happensOnDays: "Проходит в такие дни: {days}"
monitoredTripDays: Дни наблюдения за поездками
notifications: за {leadTimeInMinutes} мин до запланированного времени
отправления
notifications: за {leadTimeInMinutes} мин до запланированного времени отправления
notificationsDisabled: "Уведомления: отключены"
timeAndDuration: Время и продолжительность поездки
TripTools:
Expand Down
7 changes: 0 additions & 7 deletions i18n/ta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ common:
walk: நடை
notifications:
email: மின்னஞ்சல்
push: அறிவிப்புகளை அழுத்தவும்
sms: எச்.எம்.எச்
places:
custom: தனிப்பயன்
Expand Down Expand Up @@ -414,12 +413,6 @@ components:
description: நீங்கள் கோரிய உள்ளடக்கம் கிடைக்கவில்லை.
header: உள்ளடக்கம் கிடைக்கவில்லை
NotificationPrefsPane:
devicesRegistered: >-
{எண்ணிக்கை, பன்மை, ஒன்று {# சாதனம்} பிற {# சாதனங்கள்}} பதிவு
செய்யப்பட்டுள்ளன
noDeviceForPush: >-
புச் அறிவிப்புகளை அணுக மொபைல் பயன்பாட்டைப் பயன்படுத்தி உங்கள் சாதனத்தை
பதிவு செய்யுங்கள்.
notificationChannelPrompt: "நீங்கள் சேமித்த பயணங்களைப் பற்றிய அறிவிப்புகளைப் பெறுங்கள்:"
OTP2ErrorRenderer:
LOCATION_NOT_FOUND:
Expand Down
5 changes: 0 additions & 5 deletions i18n/tl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ common:
walk: Naglalakad
notifications:
email: email
push: mga push notification
sms: SMS
places:
custom: custom
Expand Down Expand Up @@ -419,10 +418,6 @@ components:
description: Hindi available ang hiniling mong content.
header: Hindi nakita ang content
NotificationPrefsPane:
devicesRegistered: "{count, plural, one {# device} other {# mga device}} rehistrado"
noDeviceForPush: >-
Irehistro ang iyong device gamit ang mobile app para i-access ang mga push
notification.
notificationChannelPrompt: >-
Makatanggap ng mga notification tungkol sa iyong mga naka-save na biyahe
sa pamamagitan ng:
Expand Down
1 change: 0 additions & 1 deletion i18n/tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ common:
walk: Yürümek
notifications:
email: eposta
push: bildirimler
sms: SMS
places:
dining: yemek
Expand Down
8 changes: 3 additions & 5 deletions i18n/vi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ common:
walk: Đi bộ
notifications:
email: e-mail
push: thông báo đẩy
sms: tin nhắn
places:
custom: phong tục
Expand Down Expand Up @@ -397,8 +396,6 @@ components:
description: Nội dung bạn yêu cầu không có sẵn.
header: Không tìm thấy nội dung
NotificationPrefsPane:
devicesRegistered: "{count, plural, one {# device} other {# devices}} đã đăng ký"
noDeviceForPush: Đăng ký thiết bị của quý vị bằng ứng dụng di động để nhận thông báo đẩy.
notificationChannelPrompt: "Nhận thông báo về các chuyến đi đã lưu bằng:"
OTP2ErrorRenderer:
LOCATION_NOT_FOUND:
Expand Down Expand Up @@ -427,8 +424,9 @@ components:
kiếm
OUTSIDE_BOUNDS:
body: >-
{inputFields} {inputFieldsCount, plural, =0 {} one {Vị trí là} other {Các
vị trí là}} không nằm trong ranh giới của trình lên kế hoạch chuyến đi.
{inputFields} {inputFieldsCount, plural, =0 {} one {Vị trí là} other
{Các vị trí là}} không nằm trong ranh giới của trình lên kế hoạch chuyến
đi.
header: Địa điểm nằm ngoài ranh giới
OUTSIDE_SERVICE_PERIOD:
body: >-
Expand Down
7 changes: 2 additions & 5 deletions i18n/zh_Hans.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ common:
walk: 步行
notifications:
email: 电子邮件
push: 推送通知
sms: 短信
places:
custom: 习俗
Expand Down Expand Up @@ -365,8 +364,6 @@ components:
description: 您要求的内容不存在.
header: 未找到内容
NotificationPrefsPane:
devicesRegistered: "{count, plural, one {# device} other {# devices}}已注册"
noDeviceForPush: 使用移动应用程序注册您的设备以访问推送通知。
notificationChannelPrompt: "如何接收已保存行程的通知:"
OTP2ErrorRenderer:
LOCATION_NOT_FOUND:
Expand All @@ -387,8 +384,8 @@ components:
header: 搜索窗口中没有公交连接
OUTSIDE_BOUNDS:
body: >-
{inputFields} {inputFieldsCount, plural, =0 {} one {位置是} other {位置是}}不在Trip
Planner的范围内。
{inputFields} {inputFieldsCount, plural, =0 {} one {位置是} other
{位置是}}不在Trip Planner的范围内。
header: 位置超出边界
OUTSIDE_SERVICE_PERIOD:
body: 指定的日期不在当前加载到Trip Planner中的数据范围内。
Expand Down
3 changes: 0 additions & 3 deletions i18n/zh_Hant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ common:
walk: 步行
notifications:
email: 電子郵件
push: 推播通知
sms: 簡訊
places:
custom: 自訂
Expand Down Expand Up @@ -313,8 +312,6 @@ components:
description: 您要求的內容無法使用。
header: 找不到內容
NotificationPrefsPane:
devicesRegistered: "{count}個裝置 已註冊"
noDeviceForPush: 使用行動應用程式註冊您的裝置以存取推播通知。
notificationChannelPrompt: 透過以下方式接收有關您已儲存之行程的通知:
OTP2ErrorRenderer:
LOCATION_NOT_FOUND:
Expand Down
40 changes: 4 additions & 36 deletions lib/components/user/notification-prefs-pane.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import { connect } from 'react-redux'
import { Field, FormikProps } from 'formik'
import { FormattedMessage } from 'react-intl'
import { ListGroup, ListGroupItem } from 'react-bootstrap'
import React from 'react'
import styled from 'styled-components'

import { AppReduxState } from '../../util/state-types'
import { GREY_ON_WHITE } from '../util/colors'

import { FieldSet } from './styled'
import { User } from './types'
import PhoneNumberEditor from './phone-number-editor'

interface Props extends FormikProps<User> {
allowedNotificationChannels: string[]
loggedInUser: User
}

const allNotificationChannels = ['email', 'sms', 'push']
const emailAndSms = ['email', 'sms']

// Styles
Expand Down Expand Up @@ -48,27 +44,25 @@ const NotificationOption = styled(ListGroupItem)`
* User notification preferences pane.
*/
const NotificationPrefsPane = ({
allowedNotificationChannels,
handleChange, // Formik or custom handler
values: userData // Formik prop
}: Props): JSX.Element => {
const { email, isPhoneNumberVerified, phoneNumber, pushDevices } = userData
const { email, isPhoneNumberVerified, phoneNumber } = userData

return (
<FieldSet>
<legend>
<FormattedMessage id="components.NotificationPrefsPane.notificationChannelPrompt" />
</legend>
<ListGroup>
{allowedNotificationChannels.map((type) => {
{emailAndSms.map((type) => {
const inputId = `notification-channel-${type}`
const inputDescriptionId = `${inputId}-description`
return (
<NotificationOption key={type}>
<span>
<Field
aria-describedby={inputDescriptionId}
disabled={type === 'push' && !pushDevices}
id={inputId}
name="notificationChannel"
// Override onChange explicitly to use the custom one for existing accounts.
Expand All @@ -84,25 +78,12 @@ const NotificationPrefsPane = ({
</label>
{type === 'email' ? (
<span id={inputDescriptionId}>{email}</span>
) : type === 'sms' ? (
) : (
<PhoneNumberEditor
descriptorId={inputDescriptionId}
initialPhoneNumber={phoneNumber}
initialPhoneNumberVerified={isPhoneNumberVerified}
/>
) : (
<span id={inputDescriptionId}>
{pushDevices ? (
<FormattedMessage
id="components.NotificationPrefsPane.devicesRegistered"
values={{
count: pushDevices
}}
/>
) : (
<FormattedMessage id="components.NotificationPrefsPane.noDeviceForPush" />
)}
</span>
)}
</span>
</NotificationOption>
Expand All @@ -113,17 +94,4 @@ const NotificationPrefsPane = ({
)
}

const mapStateToProps = (state: AppReduxState) => {
const { persistence } = state.otp.config
const supportsPushNotifications =
persistence && 'otp_middleware' in persistence
? persistence.otp_middleware?.supportsPushNotifications
: false
return {
allowedNotificationChannels: supportsPushNotifications
? allNotificationChannels
: emailAndSms
}
}

export default connect(mapStateToProps)(NotificationPrefsPane)
export default NotificationPrefsPane
1 change: 0 additions & 1 deletion lib/components/user/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export interface User {
notificationChannel?: string
phoneNumber?: string
preferredLocale?: string
pushDevices?: number
relatedUsers?: CompanionInfo[]
savedLocations?: UserSavedLocation[]
storeTripHistory?: boolean
Expand Down
Loading