From 7d514b045eed52064777dd13eb4489313c09b24c Mon Sep 17 00:00:00 2001 From: Rafael Gallani Date: Mon, 25 Nov 2024 12:32:06 -0300 Subject: [PATCH] Domains: Add 100-Year Domain specific Thank You page (#96568) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Rename component * Add new product prop to 100-year thank you component * Add type for productSlug prop * Conditional CTA for 100-year thank-you page * Add 100-year domain thank you specific changes * Style overrides specific for 100-domain flow * Fix wrong route 😬 * Add more specific 100-domain related flow changes * Remove placeholder - loading state is handled within inner component * Linter * Add back code removed by accident 😬 * Restore back to previous state - all previous commits were wrong 😬 * More style changes * Grammar correction * Add missing query component for 100-year thank you path * Fix conditional CTAs for 100-year plans + add fixed CTA for 100-year domain * Load style conditionally for 100-year flows * Use const instead of hardcoded string * Rename directory to match new component name * Rename references --- .../index.tsx | 83 ++++++++++++------- .../checkout/checkout-thank-you/index.tsx | 3 +- .../redesign-v2/pages/domain-only.tsx | 63 +++++++++++++- client/my-sites/checkout/controller.jsx | 7 +- .../calypso-products/src/constants/domain.ts | 2 +- 5 files changed, 122 insertions(+), 36 deletions(-) rename client/my-sites/checkout/checkout-thank-you/{hundred-year-plan-thank-you => hundred-year-thank-you}/index.tsx (74%) diff --git a/client/my-sites/checkout/checkout-thank-you/hundred-year-plan-thank-you/index.tsx b/client/my-sites/checkout/checkout-thank-you/hundred-year-thank-you/index.tsx similarity index 74% rename from client/my-sites/checkout/checkout-thank-you/hundred-year-plan-thank-you/index.tsx rename to client/my-sites/checkout/checkout-thank-you/hundred-year-thank-you/index.tsx index 498bead1ab0af..f632a63698a84 100644 --- a/client/my-sites/checkout/checkout-thank-you/hundred-year-plan-thank-you/index.tsx +++ b/client/my-sites/checkout/checkout-thank-you/hundred-year-thank-you/index.tsx @@ -1,4 +1,4 @@ -import { PLAN_100_YEARS, getPlan } from '@automattic/calypso-products'; +import { PLAN_100_YEARS, getPlan, domainProductSlugs } from '@automattic/calypso-products'; import page from '@automattic/calypso-router'; import { Button } from '@automattic/components'; import { useMobileBreakpoint } from '@automattic/viewport-react'; @@ -35,9 +35,15 @@ const VideoContainer = styled.div< { isMobile: boolean } >` min-height: ${ ( { isMobile } ) => ( isMobile ? '100%' : 'unset' ) }; } `; +const hundredYearProducts = [ + PLAN_100_YEARS, + domainProductSlugs.DOTCOM_DOMAIN_REGISTRATION, +] as const; + interface Props { siteSlug: string; receiptId: number; + productSlug: ( typeof hundredYearProducts )[ number ]; } const MasterBar = styled.div` @@ -129,7 +135,11 @@ function isSiteCreatedWithinLastHour( createdTime: string ): boolean { return Date.now() - new Date( createdTime ).getTime() < HOUR_IN_MS; } -export default function HundredYearPlanThankYou( { siteSlug, receiptId }: Props ) { +export default function HundredYearThankYou( { + siteSlug, + receiptId, + productSlug = PLAN_100_YEARS, +}: Props ) { const dispatch = useDispatch(); const translate = useTranslate(); @@ -166,6 +176,47 @@ export default function HundredYearPlanThankYou( { siteSlug, receiptId }: Props const isMobile = useMobileBreakpoint(); const isPageLoading = isReceiptLoading || isLoadingDomains; + const hundredYearPlanCta = + siteCreatedTimeStamp && isSiteCreatedWithinLastHour( siteCreatedTimeStamp ) ? ( + page( `/setup/site-setup/goals?siteSlug=${ siteSlug }` ) }> + { translate( 'Start building' ) } + + ) : ( + page( ` /home/${ siteSlug }` ) }> + { translate( 'Manage your site' ) } + + ); + const hundredYearDomainCta = ( + + page( ` /domains/manage/all/${ registeredDomain.name }/edit/${ registeredDomain.name }` ) + } + > + { translate( 'Manage your domain' ) } + + ); + const cta = productSlug === PLAN_100_YEARS ? hundredYearPlanCta : hundredYearDomainCta; + + const description = + productSlug === PLAN_100_YEARS + ? translate( + 'The %(planTitle)s for %(domain)s is active. Our Premier Support team will be in touch by email shortly to schedule a welcome session and walk you through your exclusive benefits. We’re looking forward to supporting you every step of the way.', + { + args: { + domain: registeredDomain?.domain || siteSlug, + planTitle: getPlan( PLAN_100_YEARS )?.getTitle() || '', + }, + } + ) + : translate( + 'Your 100-Year Domain %(domain)s has been registered. Our Premier Support team will be in touch by email shortly to schedule a welcome session and walk you through your exclusive benefits. We’re looking forward to supporting you every step of the way.', + { + args: { + domain: registeredDomain?.domain || siteSlug, + }, + } + ); + return ( <> { siteId && } @@ -194,32 +245,8 @@ export default function HundredYearPlanThankYou( { siteSlug, receiptId }: Props
{ translate( 'Your century-long legacy begins now' ) }
- - { translate( - 'The %(planTitle)s for %(domain)s is active. Our Premier Support team will be in touch by email shortly to schedule a welcome session and walk you through your exclusive benefits. We’re looking forward to supporting you every step of the way.', - { - args: { - domain: registeredDomain?.domain || siteSlug, - planTitle: getPlan( PLAN_100_YEARS )?.getTitle() || '', - }, - } - ) } - - { siteCreatedTimeStamp && ( - - { isSiteCreatedWithinLastHour( siteCreatedTimeStamp ) ? ( - page( `/setup/site-setup/goals?siteSlug=${ siteSlug }` ) } - > - { translate( 'Start building' ) } - - ) : ( - page( ` /home/${ siteSlug }` ) }> - { translate( 'Manage your site' ) } - - ) } - - ) } + { description } + { siteCreatedTimeStamp && { cta } }