Skip to content

Commit 4dff880

Browse files
committed
Send the site URL, not domain, when starting a chat
1 parent 673d05f commit 4dff880

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

client/landing/stepper/declarative-flow/internals/steps-repository/hundred-year-plan-site-picker/index.tsx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ const Placeholders = () => (
123123
const ConfirmationModal = ( {
124124
isFetching,
125125
siteTitle,
126-
siteDomain,
126+
siteUrl,
127127
siteId,
128128
onConfirm,
129129
closeModal,
130130
}: {
131131
isFetching: boolean;
132132
siteTitle?: string;
133-
siteDomain?: string;
133+
siteUrl?: string;
134134
siteId?: number;
135135
onConfirm: () => void;
136136
closeModal: () => void;
@@ -147,7 +147,7 @@ const ConfirmationModal = ( {
147147
setNewMessagingChat( {
148148
initialMessage,
149149
section: '100-year-plan',
150-
siteUrl: siteDomain,
150+
siteUrl,
151151
siteId: siteId,
152152
} );
153153
setShowHelpCenter( true, true );
@@ -171,7 +171,7 @@ const ConfirmationModal = ( {
171171
{
172172
args: {
173173
siteTitle: siteTitle || '',
174-
siteDomain: siteDomain || '',
174+
siteDomain: siteUrl || '',
175175
planTitle: getPlan( PLAN_100_YEARS )?.getTitle() || '',
176176
},
177177
components: {
@@ -238,13 +238,6 @@ const HundredYearPlanSitePicker: Step< { submits: { siteSlug: string; siteId: nu
238238
const [ selectedSiteId, setSelectedSiteId ] = useState< SiteId | null >( null );
239239
const [ showConfirmModal, setShowConfirmModal ] = useState( false );
240240

241-
const siteDomain = useSelect(
242-
( select ) =>
243-
( selectedSiteId &&
244-
( select( SITE_STORE ) as SiteSelect ).getPrimarySiteDomain( selectedSiteId ) ) ||
245-
undefined,
246-
[ selectedSiteId ]
247-
);
248241
const siteTitle = useSelect(
249242
( select ) =>
250243
( selectedSiteId &&
@@ -258,7 +251,7 @@ const HundredYearPlanSitePicker: Step< { submits: { siteSlug: string; siteId: nu
258251
null,
259252
[ selectedSiteId ]
260253
);
261-
const isFetching = ! site || ! siteDomain || ! siteTitle;
254+
const isFetching = ! site || ! siteTitle;
262255

263256
const selectSite = () => {
264257
const siteSlug = new URL( site?.URL || '' ).host;
@@ -315,7 +308,7 @@ const HundredYearPlanSitePicker: Step< { submits: { siteSlug: string; siteId: nu
315308
onConfirm={ selectSite }
316309
closeModal={ closeModal }
317310
siteTitle={ siteTitle }
318-
siteDomain={ siteDomain?.domain }
311+
siteUrl={ site?.URL }
319312
siteId={ site?.ID }
320313
/>
321314
) }

client/my-sites/plans-features-main/hooks/use-generate-action-callback.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { cancelPurchase } from 'calypso/me/purchases/paths';
1818
import { useFreeTrialPlanSlugs } from 'calypso/my-sites/plans-features-main/hooks/use-free-trial-plan-slugs';
1919
import { useSelector } from 'calypso/state';
2020
import { isCurrentUserCurrentPlanOwner } from 'calypso/state/sites/plans/selectors';
21-
import { getSiteSlug, isCurrentPlanPaid } from 'calypso/state/sites/selectors';
21+
import { getSiteSlug, getSiteUrl, isCurrentPlanPaid } from 'calypso/state/sites/selectors';
2222
import { IAppState } from 'calypso/state/types';
2323
import useCurrentPlanManageHref from './use-current-plan-manage-href';
2424
import { useNonOwnerHandler } from './use-non-owner-handler';
@@ -104,10 +104,10 @@ function useUpgradeHandler( {
104104
}
105105

106106
function useDowngradeHandler( {
107-
siteSlug,
107+
siteUrl,
108108
currentPlan,
109109
}: {
110-
siteSlug?: string | null;
110+
siteUrl?: string | null;
111111
currentPlan: Plans.SitePlan | undefined;
112112
} ) {
113113
const { setNewMessagingChat } = useDispatch( HELP_CENTER_STORE );
@@ -116,16 +116,16 @@ function useDowngradeHandler( {
116116
( planSlug: PlanSlug ) => {
117117
// A downgrade to the free plan is essentially cancelling the current plan.
118118
if ( isFreePlan( planSlug ) ) {
119-
page( cancelPurchase( siteSlug, currentPlan?.purchaseId ) );
119+
page( cancelPurchase( siteUrl, currentPlan?.purchaseId ) );
120120
return;
121121
}
122122

123123
setNewMessagingChat( {
124124
initialMessage: 'User wants to downgrade plan.',
125-
siteUrl: siteSlug,
125+
siteUrl,
126126
} );
127127
},
128-
[ currentPlan?.purchaseId, setNewMessagingChat, siteSlug ]
128+
[ currentPlan?.purchaseId, setNewMessagingChat, siteUrl ]
129129
);
130130
}
131131

@@ -151,6 +151,7 @@ function useGenerateActionCallback( {
151151
coupon?: string;
152152
} ): UseActionCallback {
153153
const siteSlug = useSelector( ( state: IAppState ) => getSiteSlug( state, siteId ) );
154+
const siteUrl = useSelector( ( state: IAppState ) => siteId && getSiteUrl( state, siteId ) );
154155
const freeTrialPlanSlugs = useFreeTrialPlanSlugs( {
155156
intent: intent ?? 'default',
156157
eligibleForFreeHostingTrial,
@@ -163,7 +164,7 @@ function useGenerateActionCallback( {
163164
);
164165
const handleUpgradeClick = useUpgradeHandler( { siteSlug, coupon, cartHandler } );
165166
const handleDowngradeClick = useDowngradeHandler( {
166-
siteSlug,
167+
siteUrl: siteUrl || '',
167168
currentPlan,
168169
} );
169170
const handleNonOwnerClick = useNonOwnerHandler( { siteId, currentPlan } );

0 commit comments

Comments
 (0)