11import * as Sentry from '@sentry/electron/renderer' ;
22import { useI18n } from '@wordpress/react-i18n' ;
33import { useCallback , useMemo , useState } from 'react' ;
4+ import { updateBlueprintWithFormValues } from 'common/lib/blueprint-settings' ;
45import { BlueprintValidationWarning } from 'common/lib/blueprint-validation' ;
56import { generateCustomDomainFromSiteName } from 'common/lib/domains' ;
67import { useSyncSites } from 'src/hooks/sync-sites' ;
@@ -63,6 +64,9 @@ export function useAddSite() {
6364 const [ blueprintDeeplinkWarnings , setBlueprintDeeplinkWarnings ] = useState <
6465 BlueprintValidationWarning [ ] | undefined
6566 > ( ) ;
67+ const [ blueprintSuggestedDomain , setBlueprintSuggestedDomain ] = useState <
68+ string | undefined
69+ > ( ) ;
6670 const [ isDeeplinkFlow , setIsDeeplinkFlow ] = useState ( false ) ;
6771 const [ existingDomainNames , setExistingDomainNames ] = useState < string [ ] > ( [ ] ) ;
6872
@@ -75,6 +79,7 @@ export function useAddSite() {
7579 setSelectedBlueprint ( undefined ) ;
7680 setBlueprintPreferredVersions ( undefined ) ;
7781 setBlueprintDeeplinkWarnings ( undefined ) ;
82+ setBlueprintSuggestedDomain ( undefined ) ;
7883 } , [ ] ) ;
7984
8085 // For blueprint deeplinks - we need temporary state for PHP/WP versions
@@ -88,6 +93,7 @@ export function useAddSite() {
8893 setSelectedBlueprint ( undefined ) ;
8994 setBlueprintPreferredVersions ( undefined ) ;
9095 setBlueprintDeeplinkWarnings ( undefined ) ;
96+ setBlueprintSuggestedDomain ( undefined ) ;
9197 setSelectedRemoteSite ( undefined ) ;
9298 setDeeplinkPhpVersion ( defaultPhpVersion as AllowedPHPVersion ) ;
9399 setDeeplinkWpVersion ( defaultWordPressVersion ) ;
@@ -229,13 +235,25 @@ export function useAddSite() {
229235 // For import/sync workflows, the respective handlers will start the server
230236 const shouldSkipStart = ! ! fileForImport || ! ! selectedRemoteSite ;
231237
238+ const enableHttps = formValues . useCustomDomain ? formValues . enableHttps : false ;
239+ let updatedBlueprint : Blueprint | undefined ;
240+ if ( selectedBlueprint ?. blueprint ) {
241+ const updatedJson = updateBlueprintWithFormValues ( selectedBlueprint . blueprint , {
242+ phpVersion : formValues . phpVersion ,
243+ wpVersion : formValues . wpVersion ,
244+ customDomain : usedCustomDomain ,
245+ enableHttps,
246+ } ) ;
247+ updatedBlueprint = { ...selectedBlueprint , blueprint : updatedJson } ;
248+ }
249+
232250 await createSite (
233251 formValues . sitePath ,
234252 formValues . siteName ,
235253 formValues . wpVersion ,
236254 usedCustomDomain ,
237- formValues . useCustomDomain ? formValues . enableHttps : false ,
238- selectedBlueprint ,
255+ enableHttps ,
256+ updatedBlueprint ?? selectedBlueprint ,
239257 formValues . phpVersion ,
240258 async ( newSite ) => {
241259 if ( fileForImport ) {
@@ -302,6 +320,8 @@ export function useAddSite() {
302320 setBlueprintPreferredVersions,
303321 blueprintDeeplinkWarnings,
304322 setBlueprintDeeplinkWarnings,
323+ blueprintSuggestedDomain,
324+ setBlueprintSuggestedDomain,
305325 selectedRemoteSite,
306326 setSelectedRemoteSite,
307327 existingDomainNames,
@@ -326,6 +346,7 @@ export function useAddSite() {
326346 selectedBlueprint ,
327347 blueprintPreferredVersions ,
328348 blueprintDeeplinkWarnings ,
349+ blueprintSuggestedDomain ,
329350 selectedRemoteSite ,
330351 existingDomainNames ,
331352 loadAllCustomDomains ,
0 commit comments