-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29309 from BeeMargarida/feat/28767-next-steps
[NoQA] feat: show next steps for draft reports
- Loading branch information
Showing
7 changed files
with
173 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, {useMemo} from 'react'; | ||
import {Text, View} from 'react-native'; | ||
import _ from 'underscore'; | ||
import styles from '../styles/styles'; | ||
import * as NextStepUtils from '../libs/NextStepUtils'; | ||
import useLocalize from '../hooks/useLocalize'; | ||
import nextStepPropTypes from '../pages/nextStepPropTypes'; | ||
import RenderHTML from './RenderHTML'; | ||
|
||
const propTypes = { | ||
/** The next step for the report */ | ||
nextStep: nextStepPropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
nextStep: {}, | ||
}; | ||
|
||
function MoneyReportHeaderStatusBar({nextStep}) { | ||
const {translate} = useLocalize(); | ||
|
||
const messageContent = useMemo(() => { | ||
const messageArray = _.isEmpty(nextStep.expenseMessage) ? nextStep.message : nextStep.expenseMessage; | ||
return NextStepUtils.parseMessage(messageArray); | ||
}, [nextStep.expenseMessage, nextStep.message]); | ||
|
||
return ( | ||
<View style={[styles.dFlex, styles.flexRow, styles.alignItemsCenter, styles.overflowHidden, styles.w100]}> | ||
<View style={styles.moneyRequestHeaderStatusBarBadge}> | ||
<Text style={[styles.textStrong, styles.textLabel]}>{translate('iou.nextSteps')}</Text> | ||
</View> | ||
<View style={[styles.dFlex, styles.flexRow, styles.flexShrink1]}> | ||
<RenderHTML html={messageContent} /> | ||
</View> | ||
</View> | ||
); | ||
} | ||
|
||
MoneyReportHeaderStatusBar.displayName = 'MoneyReportHeaderStatusBar'; | ||
MoneyReportHeaderStatusBar.propTypes = propTypes; | ||
MoneyReportHeaderStatusBar.defaultProps = defaultProps; | ||
|
||
export default MoneyReportHeaderStatusBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import _ from 'underscore'; | ||
import Str from 'expensify-common/lib/str'; | ||
|
||
function parseMessage(messageToParse) { | ||
let nextStepHTML = ''; | ||
|
||
_.each(messageToParse, (part) => { | ||
const tagType = part.type || 'span'; | ||
nextStepHTML += `<${tagType}>${Str.safeEscape(part.text)}</${tagType}>`; | ||
}); | ||
|
||
return nextStepHTML | ||
.replace(/%expenses/g, 'this expense') | ||
.replace(/%Expenses/g, 'This expense') | ||
.replace(/%tobe/g, 'is'); | ||
} | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export {parseMessage}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
const messagePropType = PropTypes.shape({ | ||
text: PropTypes.string, | ||
type: PropTypes.string, | ||
action: PropTypes.string, | ||
}); | ||
|
||
export default PropTypes.shape({ | ||
/** The message parts of the next step */ | ||
message: PropTypes.arrayOf(messagePropType), | ||
|
||
/** The title for the next step */ | ||
title: PropTypes.string, | ||
|
||
/** Whether the user should take some sort of action in order to unblock the report */ | ||
requiresUserAction: PropTypes.bool, | ||
|
||
/** The type of next step */ | ||
type: PropTypes.oneOf(['neutral', 'alert', null]), | ||
|
||
/** If the "Undo submit" button should be visible */ | ||
showUndoSubmit: PropTypes.bool, | ||
|
||
/** Deprecated - If the next step should be displayed on mobile, related to OldApp */ | ||
showForMobile: PropTypes.bool, | ||
|
||
/** If the next step should be displayed at the expense level */ | ||
showForExpense: PropTypes.bool, | ||
|
||
/** An optional alternate message to display on expenses instead of what is provided in the "message" field */ | ||
expenseMessage: PropTypes.arrayOf(messagePropType), | ||
|
||
/** The next person in the approval chain of the report */ | ||
nextReceiver: PropTypes.string, | ||
|
||
/** An array of buttons to be displayed next to the next step */ | ||
buttons: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
text: PropTypes.string, | ||
tooltip: PropTypes.string, | ||
disabled: PropTypes.bool, | ||
hidden: PropTypes.bool, | ||
// eslint-disable-next-line react/forbid-prop-types | ||
data: PropTypes.array, | ||
}), | ||
), | ||
}); |