-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add dropdown button to empty report #64924
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
Changes from all commits
a76a0a4
c95eeb1
a305fa6
bfaec24
b35bd68
937cbf3
36301b6
1e7516b
9d2d601
1c19cd9
ce622a5
5431df9
dec8065
b902c45
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 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,17 +1,54 @@ | ||||||||||||
| import React from 'react'; | ||||||||||||
| import {View} from 'react-native'; | ||||||||||||
| import EmptyStateComponent from '@components/EmptyStateComponent'; | ||||||||||||
| import * as Expensicons from '@components/Icon/Expensicons'; | ||||||||||||
| import LottieAnimations from '@components/LottieAnimations'; | ||||||||||||
| import useLocalize from '@hooks/useLocalize'; | ||||||||||||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||||||||||||
| import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils'; | ||||||||||||
| import Navigation from '@navigation/Navigation'; | ||||||||||||
| import {startMoneyRequest} from '@userActions/IOU'; | ||||||||||||
| import {openUnreportedExpense} from '@userActions/Report'; | ||||||||||||
| import CONST from '@src/CONST'; | ||||||||||||
| import ROUTES from '@src/ROUTES'; | ||||||||||||
| import type {Policy} from '@src/types/onyx'; | ||||||||||||
|
|
||||||||||||
| const minModalHeight = 380; | ||||||||||||
|
|
||||||||||||
| function SearchMoneyRequestReportEmptyState() { | ||||||||||||
| function SearchMoneyRequestReportEmptyState({reportId, policy}: {reportId?: string; policy?: Policy}) { | ||||||||||||
| const {translate} = useLocalize(); | ||||||||||||
| const styles = useThemeStyles(); | ||||||||||||
|
|
||||||||||||
| const addExpenseDropdownOptions = [ | ||||||||||||
| { | ||||||||||||
| value: CONST.REPORT.ADD_EXPENSE_OPTIONS.CREATE_NEW_EXPENSE, | ||||||||||||
| text: translate('iou.createNewExpense'), | ||||||||||||
| icon: Expensicons.Plus, | ||||||||||||
| onSelected: () => { | ||||||||||||
| if (!reportId) { | ||||||||||||
| return; | ||||||||||||
| } | ||||||||||||
| if (policy && shouldRestrictUserBillableActions(policy.id)) { | ||||||||||||
| Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); | ||||||||||||
| return; | ||||||||||||
| } | ||||||||||||
| startMoneyRequest(CONST.IOU.TYPE.SUBMIT, reportId); | ||||||||||||
| }, | ||||||||||||
| }, | ||||||||||||
| { | ||||||||||||
| value: CONST.REPORT.ADD_EXPENSE_OPTIONS.ADD_UNREPORTED_EXPENSE, | ||||||||||||
| text: translate('iou.addUnreportedExpense'), | ||||||||||||
| icon: Expensicons.ReceiptPlus, | ||||||||||||
| onSelected: () => { | ||||||||||||
|
Contributor
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. Should this be here too?
Suggested change
|
||||||||||||
| if (policy && shouldRestrictUserBillableActions(policy.id)) { | ||||||||||||
| Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); | ||||||||||||
| return; | ||||||||||||
| } | ||||||||||||
| openUnreportedExpense(reportId); | ||||||||||||
| }, | ||||||||||||
| }, | ||||||||||||
| ]; | ||||||||||||
|
|
||||||||||||
| return ( | ||||||||||||
| <View style={styles.flex1}> | ||||||||||||
| <EmptyStateComponent | ||||||||||||
|
|
@@ -25,6 +62,7 @@ function SearchMoneyRequestReportEmptyState() { | |||||||||||
| lottieWebViewStyles={styles.emptyStateFolderWebStyles} | ||||||||||||
| headerContentStyles={styles.emptyStateFolderWebStyles} | ||||||||||||
| minModalHeight={minModalHeight} | ||||||||||||
| buttons={[{buttonText: translate('iou.addExpense'), buttonAction: () => {}, success: true, isDisabled: false, dropDownOptions: addExpenseDropdownOptions}]} | ||||||||||||
| /> | ||||||||||||
| </View> | ||||||||||||
| ); | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -312,10 +312,6 @@ function getReportPrimaryAction(params: GetReportPrimaryActionParams): ValueOf<t | |
|
|
||
| const isPayActionWithAllExpensesHeld = isPrimaryPayAction(report, policy, reportNameValuePairs, isChatReportArchived) && hasOnlyHeldExpenses(report?.reportID); | ||
|
|
||
| if (isAddExpenseAction(report, reportTransactions, isChatReportArchived)) { | ||
|
Contributor
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. We can remove the
Contributor
Author
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. it is still used in function getReportPreviewAction() |
||
| return CONST.REPORT.PRIMARY_ACTIONS.ADD_EXPENSE; | ||
| } | ||
|
|
||
| if (isMarkAsCashAction(report, reportTransactions, violations, policy)) { | ||
| return CONST.REPORT.PRIMARY_ACTIONS.MARK_AS_CASH; | ||
| } | ||
|
|
||
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.
docs