-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the copy on site provision notification for dev sites. (#94562)
- Loading branch information
1 parent
f94e00d
commit 2cf3125
Showing
10 changed files
with
106 additions
and
71 deletions.
There are no files selected for viewing
This file contains 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
50 changes: 50 additions & 0 deletions
50
client/a8c-for-agencies/hooks/use-site-created-callback.ts
This file contains 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,50 @@ | ||
import page from '@automattic/calypso-router'; | ||
import { getQueryArg, addQueryArgs } from '@wordpress/url'; | ||
import { useCallback, useContext, useEffect } from 'react'; | ||
import { A4A_SITES_LINK } from 'calypso/a8c-for-agencies/components/sidebar-menu/lib/constants'; | ||
import useFetchPendingSites from 'calypso/a8c-for-agencies/data/sites/use-fetch-pending-sites'; | ||
import SitesDashboardContext from '../sections/sites/sites-dashboard-context'; | ||
|
||
const useSiteCreatedCallback = ( refetchRandomSiteName: () => Promise< void > ) => { | ||
const createdSiteId = getQueryArg( window.location.href, 'created_site' ) ?? null; | ||
const createdDevSiteId = getQueryArg( window.location.href, 'created_dev_site' ) ?? null; | ||
|
||
const recentlyCreatedSite = createdSiteId || createdDevSiteId; | ||
const { setRecentlyCreatedSiteId, setIsRecentlyCreatedSiteDevelopment } = | ||
useContext( SitesDashboardContext ); | ||
const { refetch: refetchPendingSites } = useFetchPendingSites(); | ||
|
||
useEffect( () => { | ||
if ( recentlyCreatedSite ) { | ||
setRecentlyCreatedSiteId( Number( recentlyCreatedSite ) ); | ||
} | ||
if ( createdDevSiteId ) { | ||
setIsRecentlyCreatedSiteDevelopment( true ); | ||
} | ||
}, [ | ||
createdDevSiteId, | ||
recentlyCreatedSite, | ||
setIsRecentlyCreatedSiteDevelopment, | ||
setRecentlyCreatedSiteId, | ||
] ); | ||
|
||
return useCallback( | ||
( id: number, isDevSite?: boolean ) => { | ||
refetchPendingSites(); | ||
refetchRandomSiteName(); | ||
setRecentlyCreatedSiteId( id ); | ||
setIsRecentlyCreatedSiteDevelopment( !! isDevSite ); | ||
|
||
const queryParams = isDevSite ? { created_dev_site: id } : { created_site: id }; | ||
page( addQueryArgs( A4A_SITES_LINK, queryParams ) ); | ||
}, | ||
[ | ||
refetchPendingSites, | ||
refetchRandomSiteName, | ||
setRecentlyCreatedSiteId, | ||
setIsRecentlyCreatedSiteDevelopment, | ||
] | ||
); | ||
}; | ||
|
||
export default useSiteCreatedCallback; |
This file contains 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 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 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 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 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 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 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 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