-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[NoQA] feat: show next steps for draft reports #29309
Changes from 6 commits
b4b68f8
b6a9476
8c71c20
a1467e6
4db6a9e
536ca6f
6dd690c
fa77838
c2ca6b0
127ccff
fdc60fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React, {useMemo} from 'react'; | ||
import {Text, View} from 'react-native'; | ||
import _ from 'underscore'; | ||
import Str from 'expensify-common/lib/str'; | ||
import styles from '../styles/styles'; | ||
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(() => { | ||
let nextStepHTML = ''; | ||
|
||
const messageArray = _.isEmpty(nextStep.expenseMessage) ? nextStep.message : nextStep.expenseMessage; | ||
_.each(messageArray, (part) => { | ||
const tagType = part.type || 'span'; | ||
nextStepHTML += `<${tagType}>${Str.safeEscape(part.text)}</${tagType}>`; | ||
}); | ||
|
||
return nextStepHTML | ||
mountiny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.replace(/%expenses/g, 'this expense') | ||
.replace(/%Expenses/g, 'This expense') | ||
.replace(/%tobe/g, 'is'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should move this to some Utils file. Maybe NextStepUtils.js and create a parseMessage method there |
||
}, [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; |
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 the user must take some sort of action in order to unblock the report */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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, | ||||||
|
||||||
/** If the next step should be displayed on mobile */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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, | ||||||
}), | ||||||
), | ||||||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last nitpick 🤓 @koko57 This leads to double bottom border if there is no next steps: