@@ -12,6 +12,8 @@ import {
1212 TCACertificationProgress ,
1313} from '../../learn-lib'
1414import { EnrollCtaBtn } from '../enroll-cta-btn'
15+ import { EnvironmentConfig } from '../../../../config'
16+ import { StripeProduct , useGetStripeProduct } from '../../learn-lib/data-providers/payments'
1517
1618import styles from './CertificationDetailsSidebar.module.scss'
1719
@@ -33,9 +35,25 @@ function renderTooltipContents(icon: ReactNode, text: Array<string>): ReactNode
3335 )
3436}
3537
38+ // eslint-disable-next-line complexity
3639const CertificationDetailsSidebar : FC < CertificationDetailsSidebarProps > = ( props : CertificationDetailsSidebarProps ) => {
3740 const completed : boolean = ! ! props . certProgress ?. completedAt
3841
42+ const tcaMonetizationEnabled : boolean = EnvironmentConfig . REACT_APP_ENABLE_TCA_CERT_MONETIZATION || false
43+
44+ // fetch Stripe product data conditionally
45+ const { product } : { product : StripeProduct | undefined }
46+ = useGetStripeProduct (
47+ tcaMonetizationEnabled && ! completed && ! props . certProgress
48+ ? props . certification ?. stripeProductId as string
49+ : '' ,
50+ )
51+ const price : string
52+ = Number ( ( product ?. default_price . unit_amount || 0 ) / 100 )
53+ . toFixed ( 2 )
54+
55+ const suggestedRetailPrice : string = product ?. metadata ?. estimatedRetailPrice || '20'
56+
3957 return (
4058 < StickySidebar >
4159 < div className = { styles [ 'certificate-placeholder' ] } >
@@ -85,9 +103,34 @@ const CertificationDetailsSidebar: FC<CertificationDetailsSidebarProps> = (props
85103 < IconSolid . CurrencyDollarIcon />
86104 </ span >
87105 < span className = 'quote-main' >
88- < span className = 'strike' > $20 </ span >
89- < strong className = { styles . freeLabel } > FREE</ strong >
90- < span className = 'body-main-bold' > enrollment ends on April 30th</ span >
106+ < span className = 'strike' >
107+ $
108+ { suggestedRetailPrice }
109+
110+ </ span >
111+ { tcaMonetizationEnabled ? (
112+ < >
113+ < span >
114+ $
115+ { price }
116+
117+ </ span >
118+ < span > one-time payment</ span >
119+ < Tooltip
120+ content = { renderTooltipContents ( < IconSolid . CurrencyDollarIcon /> , [
121+ 'One-off, non-recurring payment' ,
122+ ] ) }
123+ place = 'bottom'
124+ trigger = { < IconOutline . InformationCircleIcon /> }
125+ triggerOn = 'hover'
126+ />
127+ </ >
128+ ) : (
129+ < >
130+ < strong className = { styles . freeLabel } > FREE</ strong >
131+ < span className = 'body-main-bold' > enrollment ends on April 30th</ span >
132+ </ >
133+ ) }
91134 </ span >
92135 </ li >
93136 ) }
0 commit comments