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 default/delete popover and supporting methods #4437

Merged
merged 115 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
4d323c9
Add default/delete popover and supporting methods
stitesExpensify Aug 6, 2021
8e2ae55
Add popover and merge master
stitesExpensify Aug 9, 2021
3600ee6
Add ability to delete account and add scaffold for default
stitesExpensify Aug 9, 2021
b41716b
Correctly set password
stitesExpensify Aug 9, 2021
182a825
Move everything into a view to style easier
stitesExpensify Aug 12, 2021
0846fb8
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify Aug 12, 2021
b05c214
Merge commit 'refs/pull/4456/head' of github.com:Expensify/App into s…
stitesExpensify Aug 12, 2021
2874ede
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify Sep 9, 2021
6fbaf8d
Add new method for setting default wallet
stitesExpensify Sep 10, 2021
101d765
Send the whole payment method rather than just the id
stitesExpensify Sep 10, 2021
a2331bf
Update password component to call either default or delete
stitesExpensify Sep 10, 2021
6bc3cf3
Add ability to delete bank accounts
stitesExpensify Sep 10, 2021
a09a55a
Add ability to delete cards
stitesExpensify Sep 10, 2021
ca180ae
Add autofocus and hide input since it's a password
stitesExpensify Sep 10, 2021
386a97c
Move password popover to its own component
stitesExpensify Sep 10, 2021
43b5d12
Move password popover to its own component
stitesExpensify Sep 10, 2021
5bd6855
Convert the rest of the file to work with the new password popover
stitesExpensify Sep 10, 2021
d176916
Translate enter password text
stitesExpensify Sep 10, 2021
70b9383
Make enter work when entering password
stitesExpensify Sep 10, 2021
bef952c
fix onSubmit call
stitesExpensify Sep 10, 2021
658d2e9
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify Oct 1, 2021
cb1c713
Style
stitesExpensify Oct 2, 2021
150770d
Add default badge
stitesExpensify Oct 2, 2021
ac8f1eb
Style and defaults
stitesExpensify Oct 2, 2021
11f9278
Fix the card key
stitesExpensify Oct 2, 2021
0c01854
Update onyx when we finish setting the default
stitesExpensify Oct 2, 2021
aa0c6e9
Add growl
stitesExpensify Oct 2, 2021
55ff7fd
Check jsonCode and add failure growl
stitesExpensify Oct 2, 2021
959ae41
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify Oct 20, 2021
d27815a
Remove password requirement for deleting payments
stitesExpensify Oct 21, 2021
4d1c703
Remove password rewquirement from deleteBankAccount
stitesExpensify Oct 21, 2021
712a49e
Fix credit card import
stitesExpensify Oct 21, 2021
a31a10f
Fix password form styles
stitesExpensify Oct 21, 2021
a607f9d
Style
stitesExpensify Oct 21, 2021
3c45efe
Remove test log
stitesExpensify Oct 21, 2021
c7ace3b
Call correct API method and rename action function
stitesExpensify Oct 28, 2021
9a6dbde
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify Oct 28, 2021
296d6cb
Remove duplicate deleteBankAccount
stitesExpensify Oct 28, 2021
4921fa6
Remove duplicate export
stitesExpensify Oct 28, 2021
5362000
Get cards/banks as an object so that we can delete them easily
stitesExpensify Oct 28, 2021
eddab69
keep types consistent
stitesExpensify Oct 28, 2021
d5da408
Remove fund from onyx when we delete it
stitesExpensify Oct 29, 2021
db4036f
Delete bank account from onyx after we delete it
stitesExpensify Oct 29, 2021
12cc3f3
Don't require ownerEmail, it's an optional param
stitesExpensify Oct 29, 2021
fc013a4
Only delete from onyx if the call was successful
stitesExpensify Oct 29, 2021
e85eaf2
Fix deleting paypal.me by creating a new method
stitesExpensify Nov 17, 2021
2fad483
Remove unused imports
stitesExpensify Nov 17, 2021
e3c7a9e
Add error message for set default failure
stitesExpensify Nov 18, 2021
dfdf73e
Add error case for deleting a debit card
stitesExpensify Nov 18, 2021
4fba80c
Catch failure to delete bank account
stitesExpensify Nov 18, 2021
5fbefc7
Auto focus password input
stitesExpensify Nov 18, 2021
9c3dffc
Create new confirm popover component
stitesExpensify Nov 19, 2021
bae80dd
Add confirmation popover for deleting accounts
stitesExpensify Nov 19, 2021
aa00105
update styles
stitesExpensify Nov 19, 2021
9cc2d27
add success growls for deleting accounts
stitesExpensify Nov 19, 2021
bc09dcd
Add success growl for deleting paypal.me
stitesExpensify Nov 19, 2021
41309f1
Switch from buttons to touchableOpacity
stitesExpensify Nov 19, 2021
bbd5ed2
Use header instead of text
stitesExpensify Nov 19, 2021
d9634e6
Fix styles to be consistent
stitesExpensify Nov 20, 2021
90e2278
More styling
stitesExpensify Nov 20, 2021
640fc5a
Only set the width if we are on desktop
stitesExpensify Nov 20, 2021
0638aa9
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify Nov 20, 2021
4eaf091
Fix linting errors
stitesExpensify Nov 20, 2021
ffffae9
Style
stitesExpensify Dec 16, 2021
cebe9b5
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify Dec 20, 2021
22a6462
Replace text with ExpensifyText
stitesExpensify Dec 20, 2021
ed53387
Import growl and fix style
stitesExpensify Dec 21, 2021
8079896
Remove old consts
stitesExpensify Dec 21, 2021
f42a78d
Replace text with expensifyText
stitesExpensify Dec 21, 2021
78dc009
Fix translate methods
stitesExpensify Dec 22, 2021
e46ec76
Fix translate methods
stitesExpensify Dec 22, 2021
082b2d6
Fix imports
stitesExpensify Dec 22, 2021
0e6bc72
Fix translation import
stitesExpensify Dec 22, 2021
475e3df
Merge and solve lots of conflicts caused by moving to its own util m…
stitesExpensify Dec 22, 2021
1429865
Fix merge failures
stitesExpensify Dec 22, 2021
f3479d5
Use constants
stitesExpensify Dec 22, 2021
0f1232b
Fix styles for confirm dialog and all popover spacing
stitesExpensify Dec 23, 2021
31fd8b8
Fix styles
stitesExpensify Dec 23, 2021
696af51
Use expensifyText instead of header
stitesExpensify Dec 23, 2021
993c4d3
Updates style per design's requests
stitesExpensify Dec 23, 2021
2d09525
Replace useless style with existing one
stitesExpensify Dec 23, 2021
009c354
Swap ExpensifyText to Text as it has been renamed
stitesExpensify Dec 28, 2021
c1b3cb6
Swap ExpensifyText to Text as it has been renamed
stitesExpensify Dec 28, 2021
b41cb4f
Fix small screen menu choices
stitesExpensify Dec 28, 2021
b9384fd
Change styles to align menuItem on small screens
stitesExpensify Dec 28, 2021
d1118fb
Add spanish translation
stitesExpensify Dec 28, 2021
c7a2b07
Use constants
stitesExpensify Dec 28, 2021
fb1eefb
Use constants instead of strings
stitesExpensify Jan 8, 2022
103c85f
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify Jan 10, 2022
5a2ff14
Use commandName instead of the method
stitesExpensify Jan 10, 2022
ce0e21c
Add docs
stitesExpensify Jan 11, 2022
975cc3a
use const
stitesExpensify Jan 11, 2022
07adb74
Also use const for paypal
stitesExpensify Jan 11, 2022
74bd95e
Add translations
stitesExpensify Jan 11, 2022
5fc97a1
Use translate instead of translateLocal and use props instead of the …
stitesExpensify Jan 11, 2022
ebe5473
Translate paypal deletion message
stitesExpensify Jan 11, 2022
68a99bb
Use set instead of merge
stitesExpensify Jan 11, 2022
6af27cb
Don't put the callback in the state, it is no longer necessary
stitesExpensify Jan 11, 2022
b01d165
Remove unnecessary default prop
stitesExpensify Jan 11, 2022
d007257
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify Jan 11, 2022
06e53d4
Fix typo
stitesExpensify Jan 11, 2022
4784b52
Translation
stitesExpensify Jan 11, 2022
79f0520
Merge and change style to have a more general name
stitesExpensify Jan 11, 2022
e0d49f0
Fix spelling and make success messages show success growls
stitesExpensify Jan 11, 2022
9631375
Actually translate rather than showing the string, and make the growl…
stitesExpensify Jan 11, 2022
93047b4
Don't switch pages when clicking paypal.me and add description
stitesExpensify Jan 11, 2022
4d96d41
Do not allow users to attempt to make paypal their default
stitesExpensify Jan 11, 2022
f4462e0
Use proper icons for small viewport
stitesExpensify Jan 12, 2022
d0f5ccd
Remove unused import
stitesExpensify Jan 12, 2022
f106106
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify Jan 13, 2022
8f197d0
Remove unnecessary constructor
stitesExpensify Jan 13, 2022
779d0b8
Change text input to follow our style (and make it pretty)
stitesExpensify Jan 13, 2022
9a991e8
Left justify text
stitesExpensify Jan 13, 2022
27ce205
Add margin below text and left justify
stitesExpensify Jan 13, 2022
e11c3d3
Hide default behind a beta
stitesExpensify Jan 13, 2022
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
116 changes: 116 additions & 0 deletions src/components/ConfirmPopover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import React from 'react';
import {View, TouchableOpacity} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../styles/styles';
import Popover from './Popover';
import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import compose from '../libs/compose';
import Text from './Text';

const propTypes = {
/** Title of the modal */
title: PropTypes.string.isRequired,

/** A callback to call when the form has been submitted */
onConfirm: PropTypes.func.isRequired,

/** A callback to call when the form has been closed */
onCancel: PropTypes.func,

/** Modal visibility */
isVisible: PropTypes.bool.isRequired,

/** Confirm button text */
confirmText: PropTypes.string,

/** Cancel button text */
cancelText: PropTypes.string,

/** Is the action destructive */
danger: PropTypes.bool,

/** Whether we should show the cancel button */
shouldShowCancelButton: PropTypes.bool,

/** Where the popover should be positioned */
anchorPosition: PropTypes.shape({
top: PropTypes.number,
left: PropTypes.number,
}).isRequired,

...withLocalizePropTypes,

...windowDimensionsPropTypes,
};

const defaultProps = {
confirmText: '',
cancelText: '',
danger: false,
onCancel: () => {},
shouldShowCancelButton: true,
};

const ConfirmPopover = props => (
<Popover
onSubmit={props.onConfirm}
onClose={props.onCancel}
isVisible={props.isVisible}
anchorPosition={props.anchorPosition}
>
<View
style={[
styles.m5,
styles.alignItemsCenter,
!props.isSmallScreenWidth ? styles.sidebarPopover : '',
]}
>
<Text
style={[
styles.mb5,
]}
>
{props.title}
</Text>
<TouchableOpacity
style={[
styles.button,
styles.mt2,
styles.w100,
props.danger ? styles.buttonDanger : styles.buttonSuccess,
styles.alignSelfCenter,
]}
onPress={props.onConfirm}
>
<Text style={[styles.buttonText, props.danger && styles.textWhite]}>
{props.confirmText || props.translate('common.yes')}
</Text>
</TouchableOpacity>
{props.shouldShowCancelButton
&& (
<TouchableOpacity
style={[
styles.button,
styles.mt4,
styles.w100,
styles.alignSelfCenter,
]}
onPress={props.onCancel}
>
<Text style={[styles.buttonText]}>
{props.cancelText || props.translate('common.no')}
</Text>
</TouchableOpacity>
)}
</View>
</Popover>
);

ConfirmPopover.propTypes = propTypes;
ConfirmPopover.defaultProps = defaultProps;
ConfirmPopover.displayName = 'ConfirmPopover';
export default compose(
withWindowDimensions,
withLocalize,
)(ConfirmPopover);
119 changes: 119 additions & 0 deletions src/components/PasswordPopover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import {TouchableOpacity, View} from 'react-native';
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import styles from '../styles/styles';
import Text from './Text';
import Popover from './Popover';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import compose from '../libs/compose';
import withWindowDimensions from './withWindowDimensions';
import TextInput from './TextInput';

const propTypes = {
/** Is the popover currently showing? */
isVisible: PropTypes.bool.isRequired,

/** Function that gets called when the user closes the modal */
onClose: PropTypes.func.isRequired,

/** Where the popover should be placed */
anchorPosition: PropTypes.shape({
top: PropTypes.number,
left: PropTypes.number,
}).isRequired,

/** Function that gets called when the user clicks the delete / make default button */
onSubmit: PropTypes.func,

/** The text that should be displayed in the submit button */
submitButtonText: PropTypes.string,

...withLocalizePropTypes,
};

const defaultProps = {
onSubmit: () => {},
submitButtonText: '',
};

class PasswordPopover extends Component {
constructor(props) {
super(props);

this.passwordInput = undefined;

this.focusInput = this.focusInput.bind(this);

this.state = {
password: '',
};
}

/**
* Focus the password input
*/
focusInput() {
if (!this.passwordInput) {
return;
}
this.passwordInput.focus();
}

render() {
return (
<Popover
isVisible={this.props.isVisible}
onClose={this.props.onClose}
anchorPosition={this.props.anchorPosition}
onModalShow={this.focusInput}
>
<View
style={[
styles.m5,
!this.props.isSmallScreenWidth ? styles.sidebarPopover : '',
]}
>
<Text
style={[
styles.mb3,
]}
>
{this.props.translate('passwordForm.pleaseFillPassword')}
</Text>
<TextInput
label={this.props.translate('common.password')}
ref={el => this.passwordInput = el}
secureTextEntry
autoCompleteType="password"
textContentType="password"
value={this.state.currentPassword}
onChangeText={password => this.setState({password})}
returnKeyType="done"
onSubmitEditing={() => this.props.onSubmit(this.state.password)}
style={styles.mt3}
autoFocus
/>
<TouchableOpacity
onPress={() => this.props.onSubmit(this.state.password)}
style={[
styles.button,
styles.mt3,
styles.w100,
]}
>
<Text style={[styles.buttonText]}>
{this.props.submitButtonText}
</Text>
</TouchableOpacity>
</View>
</Popover>
);
}
}

PasswordPopover.propTypes = propTypes;
PasswordPopover.defaultProps = defaultProps;
export default compose(
withWindowDimensions,
withLocalize,
)(PasswordPopover);
8 changes: 8 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,13 @@ export default {
},
paymentsPage: {
paymentMethodsTitle: 'Payment methods',
setDefaultConfirmation: 'Make default payment method',
setDefaultSuccess: 'Default payment method set!',
setDefaultFailure: 'Failed to set default payment method.',
deleteConfirmation: 'Are you sure that you want to delete this account?',
deleteBankAccountSuccess: 'Bank account successfully deleted',
deleteDebitCardSuccess: 'Debit Card successfully deleted',
deletePayPalSuccess: 'PayPal.me successfully deleted',
allSet: 'All Set!',
transferConfirmText: ({amount}) => `${amount} will hit your account shortly!`,
gotIt: 'Got it, Thanks!',
Expand All @@ -373,6 +380,7 @@ export default {
accountLastFour: 'Account ending in',
cardLastFour: 'Card ending in',
addFirstPaymentMethod: 'Add a payment method to send and receive payments directly in the app.',
defaultPaymentMethod: 'Default',
},
preferencesPage: {
mostRecent: 'Most recent',
Expand Down
8 changes: 8 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,13 @@ export default {
},
paymentsPage: {
paymentMethodsTitle: 'Métodos de pago',
setDefaultConfirmation: 'Marcar como método de pago predeterminado',
setDefaultSuccess: 'Método de pago configurado',
setDefaultFailure: 'No se ha podido configurar el método de pago.',
deleteConfirmation: '¿Estás seguro de que quieres eliminar esta cuenta?',
deleteBankAccountSuccess: 'Cuenta bancaria eliminada correctamente',
deleteDebitCardSuccess: 'Tarjeta de débito eliminada correctamente',
deletePayPalSuccess: 'PayPal.me eliminada correctamente',
allSet: 'Todo listo!',
transferConfirmText: ({amount}) => `${amount} llegará a tu cuenta en breve!`,
gotIt: 'Gracias!',
Expand All @@ -373,6 +380,7 @@ export default {
accountLastFour: 'Cuenta con terminación',
cardLastFour: 'Tarjeta con terminacíon',
addFirstPaymentMethod: 'Añade un método de pago para enviar y recibir pagos directamente desde la aplicación.',
defaultPaymentMethod: 'Predeterminado',
},
preferencesPage: {
mostRecent: 'Más recientes',
Expand Down
28 changes: 27 additions & 1 deletion src/libs/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,17 @@ function CreateLogin(parameters) {
return Network.post(commandName, parameters);
}

/**
* @param {Object} parameters
* @param {Number} parameters.fundID
* @returns {Promise}
*/
function DeleteFund(parameters) {
const commandName = 'DeleteFund';
requireParameters(['fundID'], parameters, commandName);
return Network.post(commandName, parameters);
}

/**
* @param {Object} parameters
* @param {String} parameters.partnerUserID
Expand Down Expand Up @@ -739,6 +750,19 @@ function SetPassword(parameters) {
return Network.post(commandName, parameters);
}

/**
* @param {Object} parameters
* @param {String} parameters.password
* @param {String|null} parameters.bankAccountID
* @param {String|null} parameters.fundID
* @returns {Promise}
*/
function SetWalletLinkedAccount(parameters) {
const commandName = 'SetWalletLinkedAccount';
requireParameters(['password'], parameters, commandName);
return Network.post(commandName, parameters);
}

/**
* @param {Object} parameters
* @param {String} parameters.subscribed
Expand Down Expand Up @@ -1007,7 +1031,7 @@ function BankAccount_SetupWithdrawal(parameters) {
*/
function DeleteBankAccount(parameters) {
const commandName = 'DeleteBankAccount';
requireParameters(['bankAccountID', 'ownerEmail'], parameters, commandName);
requireParameters(['bankAccountID'], parameters, commandName);
return Network.post(commandName, parameters);
}

Expand Down Expand Up @@ -1171,6 +1195,7 @@ export {
CreateChatReport,
CreateLogin,
CreatePolicyRoom,
DeleteFund,
DeleteLogin,
DeleteBankAccount,
Get,
Expand Down Expand Up @@ -1202,6 +1227,7 @@ export {
ResetPassword,
SetNameValuePair,
SetPassword,
SetWalletLinkedAccount,
UpdateAccount,
UpdatePolicy,
User_SignUp,
Expand Down
Loading