-
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
Feat: Implement to use a 👍icon next to approved report preview #50387
Changes from all commits
ac0f5b9
0f83fed
0b2ec04
51842c4
27e2bee
4cbf68a
3ff8ba0
31ddb55
e53eab4
88cd775
db30782
3512844
9639ba6
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 |
---|---|---|
|
@@ -121,6 +121,7 @@ function ReportPreview({ | |
); | ||
|
||
const [isPaidAnimationRunning, setIsPaidAnimationRunning] = useState(false); | ||
const [isApprovedAnimationRunning, setIsApprovedAnimationRunning] = useState(false); | ||
const [isHoldMenuVisible, setIsHoldMenuVisible] = useState(false); | ||
const [requestType, setRequestType] = useState<ActionHandledType>(); | ||
const [nonHeldAmount, fullAmount] = ReportUtils.getNonHeldAndFullAmount(iouReport, policy); | ||
|
@@ -140,12 +141,18 @@ function ReportPreview({ | |
})); | ||
const checkMarkScale = useSharedValue(iouSettled ? 1 : 0); | ||
|
||
const isApproved = ReportUtils.isReportApproved(iouReport, action); | ||
const thumbsUpScale = useSharedValue(isApproved ? 1 : 0.25); | ||
const thumbsUpStyle = useAnimatedStyle(() => ({ | ||
...styles.defaultCheckmarkWrapper, | ||
transform: [{scale: thumbsUpScale.value}], | ||
})); | ||
|
||
const moneyRequestComment = action?.childLastMoneyRequestComment ?? ''; | ||
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(chatReport); | ||
const isInvoiceRoom = ReportUtils.isInvoiceRoom(chatReport); | ||
const isOpenExpenseReport = isPolicyExpenseChat && ReportUtils.isOpenExpenseReport(iouReport); | ||
|
||
const isApproved = ReportUtils.isReportApproved(iouReport, action); | ||
const canAllowSettlement = ReportUtils.hasUpdatedTotal(iouReport, policy); | ||
const numberOfRequests = allTransactions.length; | ||
const transactionsWithReceipts = ReportUtils.getTransactionsWithReceipts(iouReportID); | ||
|
@@ -195,11 +202,19 @@ function ReportPreview({ | |
const {isDelegateAccessRestricted, delegatorEmail} = useDelegateUserDetails(); | ||
const [isNoDelegateAccessMenuVisible, setIsNoDelegateAccessMenuVisible] = useState(false); | ||
|
||
const stopAnimation = useCallback(() => setIsPaidAnimationRunning(false), []); | ||
const stopAnimation = useCallback(() => { | ||
setIsPaidAnimationRunning(false); | ||
setIsApprovedAnimationRunning(false); | ||
}, []); | ||
|
||
const startAnimation = useCallback(() => { | ||
setIsPaidAnimationRunning(true); | ||
HapticFeedback.longPress(); | ||
}, []); | ||
const startApprovedAnimation = useCallback(() => { | ||
setIsApprovedAnimationRunning(true); | ||
HapticFeedback.longPress(); | ||
}, []); | ||
const confirmPayment = useCallback( | ||
(type: PaymentMethodType | undefined, payAsBusiness?: boolean) => { | ||
if (!type) { | ||
|
@@ -231,6 +246,8 @@ function ReportPreview({ | |
} else if (ReportUtils.hasHeldExpenses(iouReport?.reportID)) { | ||
setIsHoldMenuVisible(true); | ||
} else { | ||
setIsApprovedAnimationRunning(true); | ||
HapticFeedback.longPress(); | ||
IOU.approveMoneyRequest(iouReport, true); | ||
} | ||
}; | ||
|
@@ -328,14 +345,15 @@ function ReportPreview({ | |
|
||
const bankAccountRoute = ReportUtils.getBankAccountRoute(chatReport); | ||
const getCanIOUBePaid = useCallback( | ||
(onlyShowPayElsewhere = false) => IOU.canIOUBePaid(iouReport, chatReport, policy, allTransactions, onlyShowPayElsewhere), | ||
(onlyShowPayElsewhere = false, shouldCheckApprovedState = true) => IOU.canIOUBePaid(iouReport, chatReport, policy, allTransactions, onlyShowPayElsewhere, shouldCheckApprovedState), | ||
[iouReport, chatReport, policy, allTransactions], | ||
); | ||
|
||
const canIOUBePaid = useMemo(() => getCanIOUBePaid(), [getCanIOUBePaid]); | ||
const canIOUBePaidAndApproved = useMemo(() => getCanIOUBePaid(false, false), [getCanIOUBePaid]); | ||
const onlyShowPayElsewhere = useMemo(() => !canIOUBePaid && getCanIOUBePaid(true), [canIOUBePaid, getCanIOUBePaid]); | ||
const shouldShowPayButton = isPaidAnimationRunning || canIOUBePaid || onlyShowPayElsewhere; | ||
const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(iouReport, policy), [iouReport, policy]); | ||
const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(iouReport, policy), [iouReport, policy]) || isApprovedAnimationRunning; | ||
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. why do we need this 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. If we don't add |
||
|
||
const shouldDisableApproveButton = shouldShowApproveButton && !ReportUtils.isAllowedToApproveExpenseReport(iouReport); | ||
|
||
|
@@ -422,7 +440,7 @@ function ReportPreview({ | |
const shouldShowExportIntegrationButton = !shouldShowPayButton && !shouldShowSubmitButton && connectedIntegration && isAdmin && ReportUtils.canBeExported(iouReport); | ||
|
||
useEffect(() => { | ||
if (!isPaidAnimationRunning) { | ||
if (!isPaidAnimationRunning || isApprovedAnimationRunning) { | ||
return; | ||
} | ||
|
||
|
@@ -448,6 +466,14 @@ function ReportPreview({ | |
} | ||
}, [isPaidAnimationRunning, iouSettled, checkMarkScale]); | ||
|
||
useEffect(() => { | ||
if (!isApproved) { | ||
return; | ||
} | ||
|
||
thumbsUpScale.value = withSpring(1, {duration: 200}); | ||
}, [isApproved, thumbsUpScale]); | ||
|
||
return ( | ||
<OfflineWithFeedback | ||
pendingAction={iouReport?.pendingFields?.preview} | ||
|
@@ -482,7 +508,7 @@ function ReportPreview({ | |
<View style={styles.expenseAndReportPreviewTextContainer}> | ||
<View style={styles.flexRow}> | ||
<Animated.View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, previewMessageStyle]}> | ||
<Text style={[styles.textLabelSupporting, styles.lh16]}>{previewMessage}</Text> | ||
<Text style={[styles.textLabelSupporting, styles.lh20]}>{previewMessage}</Text> | ||
</Animated.View> | ||
{shouldShowRBR && ( | ||
<Icon | ||
|
@@ -510,6 +536,14 @@ function ReportPreview({ | |
/> | ||
</Animated.View> | ||
)} | ||
{isApproved && ( | ||
<Animated.View style={thumbsUpStyle}> | ||
<Icon | ||
src={Expensicons.ThumbsUp} | ||
fill={theme.icon} | ||
/> | ||
</Animated.View> | ||
)} | ||
</View> | ||
</View> | ||
{shouldShowSubtitle && !!supportText && ( | ||
|
@@ -536,6 +570,8 @@ function ReportPreview({ | |
<AnimatedSettlementButton | ||
onlyShowPayElsewhere={onlyShowPayElsewhere} | ||
isPaidAnimationRunning={isPaidAnimationRunning} | ||
isApprovedAnimationRunning={isApprovedAnimationRunning} | ||
canIOUBePaid={canIOUBePaidAndApproved || isPaidAnimationRunning} | ||
onAnimationFinish={stopAnimation} | ||
formattedAmount={getSettlementAmount() ?? ''} | ||
currency={iouReport?.currency} | ||
|
@@ -604,7 +640,13 @@ function ReportPreview({ | |
chatReport={chatReport} | ||
moneyRequestReport={iouReport} | ||
transactionCount={numberOfRequests} | ||
startAnimation={startAnimation} | ||
startAnimation={() => { | ||
if (requestType === CONST.IOU.REPORT_ACTION_TYPE.APPROVE) { | ||
startApprovedAnimation(); | ||
} else { | ||
startAnimation(); | ||
} | ||
}} | ||
/> | ||
)} | ||
</OfflineWithFeedback> | ||
|
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.
0.25 - where does this value come from? what issue with 0?
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.
bump ^
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.
If we use
0
, it will look less subtle than this . #49847 (comment)