-
Notifications
You must be signed in to change notification settings - Fork 4k
Update chat with account manager banner #52682
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
66f969f
Update chat with account manager banner
mkzie2 cd82df4
fix prettier
mkzie2 07ea65e
update translations
mkzie2 0b62e74
get accountManagerReport using useOnyx instead of getReport
mkzie2 289d68a
use || instead of ??
mkzie2 ff52090
fix various comments
mkzie2 9def46f
fix translation
mkzie2 f5082e8
Merge branch 'main' into mkzie2-issue/51433
mkzie2 09dfe5c
merge main
mkzie2 f7dfcf3
change AM to accountManager
mkzie2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import {useOnyx} from 'react-native-onyx'; | |
| import Banner from '@components/Banner'; | ||
| import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; | ||
| import DragAndDropProvider from '@components/DragAndDrop/Provider'; | ||
| import * as Expensicons from '@components/Icon/Expensicons'; | ||
| import MoneyReportHeader from '@components/MoneyReportHeader'; | ||
| import MoneyRequestHeader from '@components/MoneyRequestHeader'; | ||
| import OfflineWithFeedback from '@components/OfflineWithFeedback'; | ||
|
|
@@ -32,6 +33,7 @@ import useViewportOffsetTop from '@hooks/useViewportOffsetTop'; | |
| import Log from '@libs/Log'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import clearReportNotifications from '@libs/Notification/clearReportNotifications'; | ||
| import * as OptionsListUtils from '@libs/OptionsListUtils'; | ||
| import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; | ||
| import * as ReportActionsUtils from '@libs/ReportActionsUtils'; | ||
| import * as ReportUtils from '@libs/ReportUtils'; | ||
|
|
@@ -113,6 +115,9 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro | |
| const [modal] = useOnyx(ONYXKEYS.MODAL); | ||
| const [isComposerFullSize] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${reportIDFromRoute}`, {initialValue: false}); | ||
| const [accountManagerReportID] = useOnyx(ONYXKEYS.ACCOUNT_MANAGER_REPORT_ID, {initialValue: ''}); | ||
| // If accountManagerReportID is an empty string, using ?? can crash the app. | ||
|
mkzie2 marked this conversation as resolved.
|
||
| // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
|
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. @marcaaron we needed to do this because |
||
| const [accountManagerReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${accountManagerReportID || '-1'}`); | ||
|
mkzie2 marked this conversation as resolved.
|
||
| const [userLeavingStatus] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_USER_IS_LEAVING_ROOM}${reportIDFromRoute}`, {initialValue: false}); | ||
| const [reportOnyx, reportResult] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportIDFromRoute}`, {allowStaleData: true}); | ||
| const [reportMetadata = defaultReportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportIDFromRoute}`, {initialValue: defaultReportMetadata}); | ||
|
|
@@ -157,6 +162,21 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro | |
| navigation.setParams({reportID: lastAccessedReportID}); | ||
| }, [activeWorkspaceID, canUseDefaultRooms, navigation, route, finishedLoadingApp]); | ||
|
|
||
| const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); | ||
| const chatWithAccountManagerText = useMemo(() => { | ||
| if (accountManagerReportID) { | ||
| const participants = ReportUtils.getParticipantsAccountIDsForDisplay(accountManagerReport, false, true); | ||
| const participantPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs([participants?.at(0) ?? -1], personalDetails); | ||
| const participantPersonalDetail = Object.values(participantPersonalDetails).at(0); | ||
| const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(participantPersonalDetail); | ||
| const login = participantPersonalDetail?.login; | ||
| if (displayName && login) { | ||
| return translate('common.chatWithAccountManager', {accountManagerDisplayName: `${displayName} (${login})`}); | ||
| } | ||
| } | ||
| return ''; | ||
| }, [accountManagerReportID, accountManagerReport, personalDetails, translate]); | ||
|
|
||
| /** | ||
| * Create a lightweight Report so as to keep the re-rendering as light as possible by | ||
| * passing in only the required props. | ||
|
|
@@ -760,12 +780,14 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro | |
| </OfflineWithFeedback> | ||
| {!!accountManagerReportID && ReportUtils.isConciergeChatReport(report) && isBannerVisible && ( | ||
| <Banner | ||
| containerStyles={[styles.mh4, styles.mt4, styles.p4, styles.bgDark]} | ||
| textStyles={[styles.colorReversed]} | ||
| text={translate('reportActionsView.chatWithAccountManager')} | ||
| containerStyles={[styles.mh4, styles.mt4, styles.p4, styles.br2]} | ||
| text={chatWithAccountManagerText} | ||
| onClose={dismissBanner} | ||
| onPress={chatWithAccountManager} | ||
| onButtonPress={chatWithAccountManager} | ||
| shouldShowCloseButton | ||
| icon={Expensicons.Lightbulb} | ||
| shouldShowIcon | ||
| shouldShowButton | ||
| /> | ||
| )} | ||
| <DragAndDropProvider isDisabled={!isCurrentReportLoadedFromOnyx || !ReportUtils.canUserPerformWriteAction(report)}> | ||
|
|
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.