Skip to content

Commit 6c5d794

Browse files
authored
[Wallet]: Group escrow reminder notification (#1580)
1 parent 466958c commit 6c5d794

32 files changed

+1332
-152
lines changed

packages/mobile/locales/en-US/inviteFlow11.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
"inviteFriendsToCelo": "Invite Friends to Celo",
2525
"inviteAnyone": "Invite Anyone in your address book to send and receive value",
2626
"inviteComplete": "Invite Complete",
27-
"inviteReceived": "Invite Received"
27+
"inviteReceived": "Invite Received",
28+
"pedningInvitations": "Pending Invitations"
2829
}

packages/mobile/locales/en-US/walletFlow5.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"paymentRequest": "Payment Request",
44
"paymentRequestWithCount_plural": "{{count}} Payment Requests",
55
"SMSError": "Error sending SMS",
6-
"SMSErrorDetails": "Error sending SMS to {{recipientNumber}}: {{errMsg}}",
76
"notifications": "Notifications",
87
"getBackupKey": "Get Backup Key",
98
"setBackupKey": "Set up your Backup Key to enable account recovery and improve account security",
@@ -55,7 +54,9 @@
5554
"refreshBalances": "Refresh Balances",
5655
"reclaimPayment": "Reclaim Payment",
5756
"sendMessage": "Send Message",
58-
"escrowedPaymentReminder": "Remind {{mobile}} to Accept Payment",
57+
"escrowedPaymentReminderListItemTitle": "Remind {{mobile}} to Accept Payment",
58+
"escrowedPaymentReminder": "Remind the recipient to Accept Payment",
59+
"escrowedPaymentReminderWithCount_plural": "Remind {{count}} recipients to Accept Payment",
5960
"escrowedPaymentReminderSms":
6061
"A friendly reminder that you haven't yet redeemed your Celo Dollars!",
6162
"testnetAlert": {

packages/mobile/locales/es-419/inviteFlow11.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
"inviteFriendsToCelo": "Invitar amigos a Celo",
2525
"inviteAnyone": "Invite a cualquiera en tu lista de contactos para enviar y recibir valor",
2626
"inviteComplete": "Invitación completa",
27-
"inviteReceived": "Invitación recibida"
27+
"inviteReceived": "Invitación recibida",
28+
"pedningInvitations": "Invitaciones pendientes"
2829
}

packages/mobile/locales/es-419/walletFlow5.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"paymentRequest": "Solicitud de pago",
44
"paymentRequestWithCount_plural": "{{count}} solicitudes de pago",
55
"SMSError": "Error al enviar SMS",
6-
"SMSErrorDetails": "Error al enviar SMS a {{recipientNumber}}: {{errMsg}}`",
76
"notifications": "Notificaciones",
87
"getBackupKey": "Obtener clave de respaldo",
98
"setBackupKey":
@@ -56,7 +55,9 @@
5655
"refreshBalances": "Actualizar saldos",
5756
"reclaimPayment": "Reclamar el Pago",
5857
"sendMessage": "Enviar Mensaje",
59-
"escrowedPaymentReminder": "Recuérdele a {{mobile #}} que acepte el pago",
58+
"escrowedPaymentReminderListItemTitle": "Recuérdele a {{mobile #}} que acepte el pago",
59+
"escrowedPaymentReminder": "Reacuerda al receptor aceptar el pago",
60+
"escrowedPaymentReminderWithCount_plural": "Recordar {{count}} receptores to aceptar el pago",
6061
"escrowedPaymentReminderSms":
6162
"¡Un recordatorio amistoso de que aún no ha canjeado sus dólares de celo!",
6263
"testnetAlert": {

packages/mobile/src/analytics/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export enum CustomEventNames {
150150
request_payment_review = 'request_payment_review',
151151

152152
// Escrowed payments
153+
escrowed_payment_review = 'escrowed_payment_review',
153154
escrowed_payment_reclaimed_by_sender = 'escrowed_payment_reclaimed_by_sender',
154155
escrowed_payment_reclaimEdit_by_sender = 'escrowed_payment_reclaimEdit_by_sender',
155156
escrowed_payment_withdrawn_by_receiver = 'escrowed_payment_withdrawn_by_receiver',

packages/mobile/src/app/ErrorMessages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ export enum ErrorMessages {
4545
CORRUPTED_CHAIN_DELETED = 'corruptedChainDeleted',
4646
CALCULATE_FEE_FAILED = 'calculateFeeFailed',
4747
FAILED_TO_SWITCH_SYNC_MODES = 'failedToSwitchSyncModes',
48+
SMS_ERROR = 'walletFlow5:SMSError',
4849
}
Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import * as React from 'react'
22
import 'react-native'
33
import * as renderer from 'react-test-renderer'
4-
import PaymentRequestNotificationInner from 'src/paymentRequest/PaymentRequestNotificationInner'
5-
import { mockRecipientWithPhoneNumber } from 'test/values'
4+
import { escrowPaymentDouble } from 'src/escrow/__mocks__'
5+
import EscrowedPaymentLineItem from 'src/escrow/EscrowedPaymentLineItem'
6+
7+
const mockedPayment = escrowPaymentDouble({})
68

79
it('renders correctly', () => {
8-
const tree = renderer.create(
9-
<PaymentRequestNotificationInner
10-
requesterE164Number={mockRecipientWithPhoneNumber.e164PhoneNumber}
11-
comment="You owe me for coffee!"
12-
amount="5"
13-
requesterRecipient={mockRecipientWithPhoneNumber}
14-
/>
15-
)
10+
const tree = renderer.create(<EscrowedPaymentLineItem payment={mockedPayment} />)
1611

1712
expect(tree).toMatchSnapshot()
1813
})

packages/mobile/src/escrow/EscrowedPaymentLineItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fontStyles from '@celo/react-components/styles/fonts'
22
import * as React from 'react'
33
import { StyleSheet, Text } from 'react-native'
44
import { EscrowedPayment } from 'src/escrow/actions'
5-
import { divideByWei, getMoneyDisplayValue } from 'src/utils/formatting'
5+
import { divideByWei, getCentAwareMoneyDisplay } from 'src/utils/formatting'
66

77
interface Props {
88
payment: EscrowedPayment
@@ -17,7 +17,7 @@ export default function EscrowedPaymentLineItem(props: Props) {
1717
</Text>
1818
<Text style={[fontStyles.subSmall, fontStyles.semiBold]}>
1919
{' '}
20-
${getMoneyDisplayValue(divideByWei(amount.toString()))}
20+
${getCentAwareMoneyDisplay(divideByWei(amount.toString()))}
2121
</Text>
2222
</Text>
2323
)

packages/mobile/src/notifications/EscrowedPaymentReminderNotification.test.tsx renamed to packages/mobile/src/escrow/EscrowedPaymentListItem.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react'
22
import 'react-native'
33
import { Provider } from 'react-redux'
44
import * as renderer from 'react-test-renderer'
5-
import EscrowedPaymentReminderNotification from 'src/notifications/EscrowedPaymentReminderNotification'
5+
import EscrowedPaymentListItem from 'src/escrow/EscrowedPaymentListItem'
66
import { createMockStore } from 'test/utils'
77
import { mockEscrowedPayment } from 'test/values'
88

@@ -12,7 +12,7 @@ describe('EscrowedPaymentReminderNotification', () => {
1212
it('renders correctly', () => {
1313
const tree = renderer.create(
1414
<Provider store={store}>
15-
<EscrowedPaymentReminderNotification payment={mockEscrowedPayment} />
15+
<EscrowedPaymentListItem payment={mockEscrowedPayment} />
1616
</Provider>
1717
)
1818
expect(tree).toMatchSnapshot()

packages/mobile/src/notifications/EscrowedPaymentReminderNotification.tsx renamed to packages/mobile/src/escrow/EscrowedPaymentListItem.tsx

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import SendIntentAndroid from 'react-native-send-intent'
66
import CeloAnalytics from 'src/analytics/CeloAnalytics'
77
import { CustomEventNames } from 'src/analytics/constants'
88
import { componentWithAnalytics } from 'src/analytics/wrapper'
9+
import { ErrorMessages } from 'src/app/ErrorMessages'
910
import { EscrowedPayment } from 'src/escrow/actions'
10-
import EscrowedPaymentLineItem from 'src/escrow/EscrowedPaymentLineItem'
1111
import { Namespaces } from 'src/i18n'
1212
import { inviteFriendsIcon } from 'src/images/Images'
1313
import { navigate } from 'src/navigator/NavigationService'
1414
import { Screens } from 'src/navigator/Screens'
15+
import NotificationAmount from 'src/paymentRequest/NotificationAmount'
1516
import { navigateToURI } from 'src/utils/linking'
1617
import Logger from 'src/utils/Logger'
1718

@@ -21,41 +22,43 @@ interface OwnProps {
2122

2223
type Props = OwnProps & WithNamespaces
2324

24-
export class EscrowedPaymentReminderNotification extends React.PureComponent<Props> {
25-
getCTA = () => {
25+
const TAG = 'EscrowedPaymentListItem'
26+
27+
export class EscrowedPaymentListItem extends React.PureComponent<Props> {
28+
onSendMessage = () => {
2629
const { payment, t } = this.props
2730
const recipientPhoneNumber = payment.recipientPhone
31+
CeloAnalytics.track(CustomEventNames.clicked_escrowed_payment_send_message)
32+
// TODO: open up whatsapp/text message slider with pre populated message
33+
try {
34+
if (Platform.OS === 'android') {
35+
SendIntentAndroid.sendSms(recipientPhoneNumber, t('escrowedPaymentReminderSms'))
36+
} else {
37+
// TODO look into using MFMessageComposeViewController to prefill the body for iOS
38+
navigateToURI(`sms:${recipientPhoneNumber}`)
39+
}
40+
} catch (error) {
41+
// TODO: use the showError saga instead of the Logger.showError, which is a hacky temp thing we used for a while that doesn't actually work on iOS
42+
Logger.showError(ErrorMessages.SMS_ERROR)
43+
Logger.error(TAG, `Error sending SMS to ${recipientPhoneNumber}`, error)
44+
}
45+
}
46+
onReclaimPayment = () => {
47+
const { payment } = this.props
48+
const reclaimPaymentInput = payment
49+
CeloAnalytics.track(CustomEventNames.clicked_escrowed_payment_notification)
50+
navigate(Screens.ReclaimPaymentConfirmationScreen, { reclaimPaymentInput })
51+
}
52+
getCTA = () => {
53+
const { t } = this.props
2854
return [
2955
{
3056
text: t('sendMessage'),
31-
onPress: () => {
32-
CeloAnalytics.track(CustomEventNames.clicked_escrowed_payment_send_message)
33-
// TODO: open up whatsapp/text message slider with pre populated message
34-
try {
35-
if (Platform.OS === 'android') {
36-
SendIntentAndroid.sendSms(recipientPhoneNumber, t('escrowedPaymentReminderSms'))
37-
} else {
38-
// TODO look into using MFMessageComposeViewController to prefill the body for iOS
39-
navigateToURI(`sms:${recipientPhoneNumber}`)
40-
}
41-
} catch {
42-
Logger.showError(t('SMSError'))
43-
Logger.error(
44-
'EscrowedPaymentReminderNotification/',
45-
t('SMSErrorDetails', {
46-
recipientNumber: recipientPhoneNumber,
47-
})
48-
)
49-
}
50-
},
57+
onPress: this.onSendMessage,
5158
},
5259
{
53-
text: this.props.t('reclaimPayment'),
54-
onPress: () => {
55-
const reclaimPaymentInput = payment
56-
CeloAnalytics.track(CustomEventNames.clicked_escrowed_payment_notification)
57-
navigate(Screens.ReclaimPaymentConfirmationScreen, { reclaimPaymentInput })
58-
},
60+
text: t('reclaimPayment'),
61+
onPress: this.onReclaimPayment,
5962
},
6063
]
6164
}
@@ -65,7 +68,7 @@ export class EscrowedPaymentReminderNotification extends React.PureComponent<Pro
6568
const displayName = payment.recipientContact
6669
? payment.recipientContact.displayName
6770
: payment.recipientPhone
68-
return t('escrowedPaymentReminder', { mobile: displayName })
71+
return t('escrowedPaymentReminderListItemTitle', { mobile: displayName })
6972
}
7073

7174
render() {
@@ -76,13 +79,10 @@ export class EscrowedPaymentReminderNotification extends React.PureComponent<Pro
7679
title={this.getTitle()}
7780
icon={<Image source={inviteFriendsIcon} style={styles.image} resizeMode="contain" />}
7881
ctas={this.getCTA()}
79-
roundedBorders={true}
82+
roundedBorders={false}
83+
callout={<NotificationAmount amount={payment.amount} />}
8084
>
81-
<View style={styles.body}>
82-
<View style={styles.payment}>
83-
<EscrowedPaymentLineItem payment={payment} />
84-
</View>
85-
</View>
85+
<View style={styles.body} />
8686
</BaseNotification>
8787
)
8888
}
@@ -103,5 +103,5 @@ const styles = StyleSheet.create({
103103
})
104104

105105
export default componentWithAnalytics(
106-
withNamespaces(Namespaces.walletFlow5)(EscrowedPaymentReminderNotification)
106+
withNamespaces(Namespaces.walletFlow5)(EscrowedPaymentListItem)
107107
)

0 commit comments

Comments
 (0)