Repository navigation
Open a support ticket straight from the Talk to a human link #104572
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
Open
ishpaul777
wants to merge
5
commits into
Expensify:main
Choose a base branch
from
ishpaul777:ishpaul/684546-talk-to-human-ticket
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+99
−15
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8b33174
Open a support ticket straight from the Talk to a human link
ishpaul777 27bbef5
Leave the action route before opening the ticket and justify the hook…
ishpaul777 8bb3d5b
Fall back to the Help page when a direct link has nothing to go back to
ishpaul777 37a9c92
Fix the Talk to a human afterTransition type
ishpaul777 723f39a
Set shouldUseGoBackButton explicitly on the Talk to a human loader
ishpaul777 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import Growl from '@libs/Growl'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
|
|
||
| import {isNoSupportRepAvailableResponse, openSupportTicket} from '@userActions/Report'; | ||
|
|
||
| import useLocalize from './useLocalize'; | ||
| import useOpenConciergeAnywhere from './useOpenConciergeAnywhere'; | ||
|
|
||
| /** | ||
| * Returns a callback that opens a support ticket, falling back to Concierge when no support rep is free. | ||
| * Shared by the Help page row and the Talk to a human route so both behave the same. | ||
| */ | ||
| function useOpenSupportTicket() { | ||
| const {translate} = useLocalize(); | ||
| const {openConciergeAnywhere} = useOpenConciergeAnywhere(); | ||
|
|
||
| const openSupportTicketOrConcierge = () => | ||
| openSupportTicket() | ||
| .then((response) => { | ||
| if (!isNoSupportRepAvailableResponse(response)) { | ||
| return; | ||
| } | ||
|
|
||
| Growl.error(translate('supportTicket.noSupportRepAvailable')); | ||
| Navigation.goBack(undefined, {afterTransition: () => openConciergeAnywhere({forceConcierge: true})}); | ||
| }) | ||
| .catch(() => undefined); | ||
|
|
||
| return {openSupportTicketOrConcierge}; | ||
| } | ||
|
|
||
| export default useOpenSupportTicket; |
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 |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; | ||
|
|
||
| import useNetwork from '@hooks/useNetwork'; | ||
| import useOpenSupportTicket from '@hooks/useOpenSupportTicket'; | ||
|
|
||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import navigationRef from '@libs/Navigation/navigationRef'; | ||
|
|
||
| import ROUTES from '@src/ROUTES'; | ||
|
|
||
| import React, {useEffect, useRef} from 'react'; | ||
|
|
||
| /** | ||
| * Opens a support ticket straight away, so the Talk to a human link in a Concierge message reaches a | ||
| * person without the customer having to find the row on the Help page. | ||
| */ | ||
| function TalkToHumanPage() { | ||
| const {openSupportTicketOrConcierge} = useOpenSupportTicket(); | ||
| const {isOffline} = useNetwork(); | ||
| const hasRequestedTicket = useRef(false); | ||
|
|
||
| useEffect(() => { | ||
| // Creating a ticket needs the network, so send the customer to the Help page to try again once they are back online. | ||
| if (isOffline) { | ||
| Navigation.goBack(ROUTES.SETTINGS_HELP); | ||
| return; | ||
| } | ||
|
|
||
| // A remount would otherwise open a second ticket that a support rep has to close. | ||
| if (hasRequestedTicket.current) { | ||
| return; | ||
| } | ||
| hasRequestedTicket.current = true; | ||
|
|
||
| // Leave this route before creating the ticket. The ticket stores the route it was opened from as its back target, | ||
| // so opening it from here would make Back return to this loader instead of the chat the link was pressed in. | ||
| // A direct link has nothing behind it to return to and goBack would then skip afterTransition, so it falls back | ||
| // to the Help page and opens the ticket from there. | ||
| const fallbackRoute = navigationRef.current?.canGoBack() ? undefined : ROUTES.SETTINGS_HELP; | ||
| Navigation.goBack(fallbackRoute, { | ||
| afterTransition: () => { | ||
| openSupportTicketOrConcierge(); | ||
| }, | ||
| }); | ||
|
|
||
| // openSupportTicketOrConcierge is a new function on every render and hasRequestedTicket already stops a second | ||
| // request, so this effect only needs to react to the connection changing. | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
|
ishpaul777 marked this conversation as resolved.
|
||
| }, [isOffline]); | ||
|
|
||
| return <FullScreenLoadingIndicator shouldUseGoBackButton />; | ||
| } | ||
|
|
||
| TalkToHumanPage.displayName = 'TalkToHumanPage'; | ||
|
|
||
| export default TalkToHumanPage; | ||
Oops, something went wrong.
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.
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.
On a narrow-layout cold load of
settings/help/talk-to-human,SplitRouter.adaptStateIfNecessary()prependsSCREENS.SETTINGS.ROOT(the cold-root behavior is also encoded intests/navigation/GoBackTests.tsx), so this broadcanGoBack()check returns true even though there is no originating page. The fallback is therefore omitted, the first Back pops only to Settings root, andopenSupportTicket()recordssettingsrather than the intended Help page as the ticket's Back target; determine whether there is outer/in-app history without counting the split navigator's injected sidebar.Useful? React with 👍 / 👎.