@@ -18,12 +18,13 @@ import {
1818 AWS_MARKETPLACE_SETUP_TURNAROUND ,
1919 type AwsMarketplaceOnboardingError ,
2020} from '@/lib/billing/aws-marketplace/onboarding'
21- import { organizationRoutes , WORKSPACE_BILLING_PATH } from '@/lib/navigation/paths'
21+ import { organizationRoutes } from '@/lib/navigation/paths'
2222import { buildAuthCrossLink } from '@/app/(auth)/auth-redirect'
2323import { InviteLayout , InviteStatusCard } from '@/app/invite/components'
2424import { useBrandConfig } from '@/ee/whitelabeling'
2525import {
2626 useAwsMarketplaceClaim ,
27+ useAwsMarketplaceLicenses ,
2728 useLinkAwsMarketplaceLicense ,
2829 useRegisterAwsMarketplaceLicenseToAccount ,
2930 useSaveAwsMarketplaceClaimContact ,
@@ -59,6 +60,12 @@ const REGISTRATION_ERROR_COPY: Record<
5960/** AWS's manual-setup guidance: being set up, wait to be contacted, turnaround, contact. */
6061const BEING_SET_UP = `Your account is being set up. Please wait for us to contact you. We expect to finish ${ AWS_MARKETPLACE_SETUP_TURNAROUND } .`
6162
63+ const LICENSE_STATUS_LABELS = {
64+ active : 'Active' ,
65+ pending : 'Confirming with AWS' ,
66+ inactive : 'Inactive' ,
67+ } as const
68+
6269function authLink ( path : '/login' | '/signup' ) : string {
6370 return buildAuthCrossLink ( path , {
6471 callbackUrl : AWS_MARKETPLACE_ONBOARDING_PATH ,
@@ -80,6 +87,69 @@ function SupportContact({ supportEmail }: SupportContactProps) {
8087 )
8188}
8289
90+ /** Status for a buyer with no organization, who may not be able to open any billing page. */
91+ function AccountSubscriptionStatus ( ) {
92+ const { data : licenses } = useAwsMarketplaceLicenses ( null )
93+ if ( ! licenses ?. length ) return null
94+ return (
95+ < ul className = 'au:w-full au:space-y-1 au:text-center au:text-sm' >
96+ { licenses . map ( ( license ) => (
97+ < li key = { license . id } >
98+ { LICENSE_STATUS_LABELS [ license . status ] }
99+ { license . expiresAt && `, expires ${ formatDate ( new Date ( license . expiresAt ) ) } ` }
100+ </ li >
101+ ) ) }
102+ </ ul >
103+ )
104+ }
105+
106+ interface NoSetupInProgressProps {
107+ supportContact : ReactNode
108+ actions : Array < { label : string ; onClick : ( ) => void } >
109+ }
110+
111+ /** A finished buyer who returns sees their account's status; anyone else, how to start. */
112+ function NoSetupInProgress ( { supportContact, actions } : NoSetupInProgressProps ) {
113+ const { data : licenses , isPending } = useAwsMarketplaceLicenses ( null )
114+ if ( isPending ) {
115+ return (
116+ < InviteLayout >
117+ < InviteStatusCard type = 'loading' title = '' description = 'Loading your subscription...' />
118+ </ InviteLayout >
119+ )
120+ }
121+ if ( licenses ?. length ) {
122+ const underway = licenses . some ( ( license ) => license . status !== 'inactive' )
123+ return (
124+ < InviteLayout >
125+ < InviteStatusCard
126+ type = { underway ? 'success' : 'warning' }
127+ title = 'Your AWS Marketplace subscription'
128+ description = { underway ? BEING_SET_UP : 'This subscription is no longer active.' }
129+ details = {
130+ < div className = 'au:w-full au:space-y-2' >
131+ < AccountSubscriptionStatus />
132+ { supportContact }
133+ </ div >
134+ }
135+ actions = { actions }
136+ />
137+ </ InviteLayout >
138+ )
139+ }
140+ return (
141+ < InviteLayout >
142+ < InviteStatusCard
143+ type = 'warning'
144+ title = 'No setup in progress'
145+ description = { `${ RESTART_FROM_AWS } If you already finished setup, we will contact you ${ AWS_MARKETPLACE_SETUP_TURNAROUND } .` }
146+ details = { supportContact }
147+ actions = { actions }
148+ />
149+ </ InviteLayout >
150+ )
151+ }
152+
83153interface AwsMarketplaceOnboardingProps {
84154 registrationError : AwsMarketplaceOnboardingError | null
85155 registrationDisabled : boolean
@@ -134,7 +204,11 @@ export function AwsMarketplaceOnboarding({
134204 < InviteStatusCard
135205 type = 'login'
136206 title = 'Set up your AWS Marketplace subscription'
137- description = 'Sign in or create an account to set up this subscription.'
207+ description = {
208+ registrationDisabled
209+ ? 'Sign in to set up this subscription.'
210+ : 'Sign in or create an account to set up this subscription.'
211+ }
138212 details = { supportContact }
139213 actions = { [
140214 ...( registrationDisabled
@@ -157,17 +231,17 @@ export function AwsMarketplaceOnboarding({
157231 description = { BEING_SET_UP }
158232 details = {
159233 < div className = 'au:w-full au:space-y-2 au:text-center au:text-sm' >
160- < p >
161- < AuthTextLink
162- href = {
163- organizationId
164- ? organizationRoutes ( organizationId ) . settingsSection ( 'billing' )
165- : WORKSPACE_BILLING_PATH
166- }
167- >
168- View subscription status
169- </ AuthTextLink >
170- </ p >
234+ { organizationId ? (
235+ < p >
236+ < AuthTextLink
237+ href = { organizationRoutes ( organizationId ) . settingsSection ( 'billing' ) }
238+ >
239+ View subscription status
240+ </ AuthTextLink >
241+ </ p >
242+ ) : (
243+ < AccountSubscriptionStatus / >
244+ ) }
171245 { supportContact }
172246 </ div >
173247 }
@@ -200,17 +274,7 @@ export function AwsMarketplaceOnboarding({
200274
201275 const claim = claimQuery . data
202276 if ( claim . status === 'missing' ) {
203- return (
204- < InviteLayout >
205- < InviteStatusCard
206- type = 'warning'
207- title = 'No setup in progress'
208- description = { `${ RESTART_FROM_AWS } If you already finished setup, we will contact you ${ AWS_MARKETPLACE_SETUP_TURNAROUND } .` }
209- details = { supportContact }
210- actions = { [ returnHome ] }
211- />
212- </ InviteLayout >
213- )
277+ return < NoSetupInProgress supportContact = { supportContact } actions = { [ returnHome ] } />
214278 }
215279
216280 if ( claim . status === 'linked' ) {
0 commit comments