Skip to content
Merged
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
6 changes: 5 additions & 1 deletion src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,11 @@ const CONST = {
LEAVE_ROOM: 'leaveRoom',
WELCOME_MESSAGE: 'welcomeMessage',
},

EDIT_REQUEST_FIELD: {
AMOUNT: 'amount',
DATE: 'date',
DESCRIPTION: 'description',
},
FOOTER: {
EXPENSE_MANAGEMENT_URL: `${USE_EXPENSIFY_URL}/expense-management`,
SPEND_MANAGEMENT_URL: `${USE_EXPENSIFY_URL}/spend-management`,
Expand Down
2 changes: 2 additions & 0 deletions src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export default {
NEW_TASK,
REPORT,
REPORT_WITH_ID: 'r/:reportID?',
EDIT_REQUEST: 'r/:threadReportID/edit/:field',
getEditRequestRoute: (threadReportID, field) => `r/${threadReportID}/edit/${field}`,
getReportRoute: (reportID) => `r/${reportID}`,
REPORT_WITH_ID_DETAILS_SHARE_CODE: 'r/:reportID/details/shareCode',
getReportShareCodeRoute: (reportID) => `r/${reportID}/details/shareCode`,
Expand Down
9 changes: 9 additions & 0 deletions src/components/MoneyRequestHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,23 @@ function MoneyRequestHeader(props) {
titleIcon={Expensicons.Checkmark}
description={`${props.translate('iou.amount')} • ${props.translate('iou.cash')}${isSettled ? ` • ${props.translate('iou.settledExpensify')}` : ''}`}
titleStyle={styles.newKansasLarge}
disabled={isSettled}
// Note: These options are temporarily disabled while we figure out the required API changes
Comment thread
luacmartins marked this conversation as resolved.
Resolved
// shouldShowRightIcon={!isSettled}
// onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(props.report.reportID, CONST.EDIT_REQUEST_FIELD.AMOUNT))}
/>
<MenuItemWithTopDescription
description={props.translate('common.description')}
title={transactionDescription}
disabled={isSettled}
// shouldShowRightIcon={!isSettled}
// onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(props.report.reportID, CONST.EDIT_REQUEST_FIELD.DESCRIPTION))}
/>
<MenuItemWithTopDescription
description={props.translate('common.date')}
title={formattedTransactionDate}
// shouldShowRightIcon={!isSettled}
// onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(props.report.reportID, CONST.EDIT_REQUEST_FIELD.DATE))}
/>
</>
)}
Expand Down
11 changes: 11 additions & 0 deletions src/libs/Navigation/AppNavigator/ModalStackNavigators.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,16 @@ const FlagCommentStackNavigator = createModalStackNavigator([
},
]);

const EditRequestStackNavigator = createModalStackNavigator([
{
getComponent: () => {
const EditRequestPage = require('../../../pages/EditRequestPage').default;
return EditRequestPage;
},
name: 'EditRequest_Root',
},
]);

export {
MoneyRequestModalStackNavigator,
SplitDetailsModalStackNavigator,
Expand All @@ -737,4 +747,5 @@ export {
WalletStatementStackNavigator,
YearPickerStackNavigator,
FlagCommentStackNavigator,
EditRequestStackNavigator,
};
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ function RigthModalNavigator() {
options={defaultModalScreenOptions}
component={ModalStackNavigators.FlagCommentStackNavigator}
/>
<Stack.Screen
name="EditRequest"
options={defaultModalScreenOptions}
component={ModalStackNavigators.EditRequestStackNavigator}
/>
</Stack.Navigator>
);
}
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ export default {
FlagComment_Root: ROUTES.FLAG_COMMENT,
},
},
EditRequest: {
screens: {
EditRequest_Root: ROUTES.EDIT_REQUEST,
},
},
},
},
},
Expand Down
1 change: 1 addition & 0 deletions src/libs/TransactionUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function buildOptimisticTransaction(amount, currency, reportID, comment = '', so
return {
transactionID,
amount,
currency,
reportID,
comment: commentJSON,
merchant,
Expand Down
59 changes: 59 additions & 0 deletions src/pages/EditRequestDescriptionPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React, {useRef} from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import TextInput from '../components/TextInput';
import withLocalize, {withLocalizePropTypes} from '../components/withLocalize';
import ScreenWrapper from '../components/ScreenWrapper';
import HeaderWithBackButton from '../components/HeaderWithBackButton';
import Form from '../components/Form';
import ONYXKEYS from '../ONYXKEYS';
import styles from '../styles/styles';
import Navigation from '../libs/Navigation/Navigation';

const propTypes = {
...withLocalizePropTypes,

/** Transaction description default value */
defaultDescription: PropTypes.string.isRequired,

/** Callback to fire when the Save button is pressed */
onSubmit: PropTypes.func.isRequired,
};

function EditRequestDescriptionPage(props) {
const descriptionInputRef = useRef(null);
return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
shouldEnableMaxHeight
onEntryTransitionEnd={() => descriptionInputRef.current && descriptionInputRef.current.focus()}
>
<HeaderWithBackButton
title={props.translate('common.description')}
onBackButtonPress={() => Navigation.goBack()}
/>
<Form
style={[styles.flexGrow1, styles.ph5]}
formID={ONYXKEYS.FORMS.MONEY_REQUEST_DESCRIPTION_FORM}
onSubmit={props.onSubmit}
submitButtonText={props.translate('common.save')}
enabledWhenOffline
>
<View style={styles.mb4}>
<TextInput
inputID="modifiedComment"
name="modifiedComment"
defaultValue={props.defaultDescription}
label={props.translate('moneyRequestConfirmationList.whatsItFor')}
ref={descriptionInputRef}
/>
</View>
</Form>
</ScreenWrapper>
);
}

EditRequestDescriptionPage.propTypes = propTypes;
EditRequestDescriptionPage.displayName = 'EditRequestDescriptionPage';

export default withLocalize(EditRequestDescriptionPage);
77 changes: 77 additions & 0 deletions src/pages/EditRequestPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React from 'react';
import PropTypes from 'prop-types';
import lodashGet from 'lodash/get';
import {withOnyx} from 'react-native-onyx';
import CONST from '../CONST';
import Navigation from '../libs/Navigation/Navigation';
import compose from '../libs/compose';
import withLocalize, {withLocalizePropTypes} from '../components/withLocalize';
import ONYXKEYS from '../ONYXKEYS';
import * as ReportActionsUtils from '../libs/ReportActionsUtils';
import EditRequestDescriptionPage from './EditRequestDescriptionPage';
import reportPropTypes from './reportPropTypes';
import * as ReportUtils from '../libs/ReportUtils';

const propTypes = {
...withLocalizePropTypes,

/** Route from navigation */
route: PropTypes.shape({
/** Params from the route */
params: PropTypes.shape({
/** Which field we are editing */
field: PropTypes.string,

/** reportID for the "transaction thread" */
threadReportID: PropTypes.string,
}),
}).isRequired,

/** The report object for the thread report */
report: reportPropTypes,
};

const defaultProps = {
report: {},
};

function EditRequestPage(props) {
const parentReportAction = ReportActionsUtils.getParentReportAction(props.report);
const moneyRequestReportAction = ReportUtils.getMoneyRequestAction(parentReportAction);
const transactionDescription = moneyRequestReportAction.comment;
const field = lodashGet(props, ['route', 'params', 'field'], '');

function updateTransactionWithChanges(changes) {
// Update the transaction...
// eslint-disable-next-line no-console
console.log({changes});

// Note: The "modal" we are dismissing is the MoneyRequestAmountPage
Navigation.dismissModal();
}

if (field === CONST.EDIT_REQUEST_FIELD.DESCRIPTION) {
return (
<EditRequestDescriptionPage
defaultDescription={transactionDescription}
onSubmit={(changes) => {
updateTransactionWithChanges(changes);
}}
/>
);
}

return null;
}

EditRequestPage.displayName = 'EditRequestPage';
EditRequestPage.propTypes = propTypes;
EditRequestPage.defaultProps = defaultProps;
export default compose(
withLocalize,
withOnyx({
report: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`,
},
}),
)(EditRequestPage);