@@ -27,16 +27,36 @@ type Plan = {
2727 number : string ;
2828 featured ?: boolean ;
2929 CTA ?: CTA | undefined ;
30+ localizations ?: Plan [ ] ;
31+ locale ?: string ;
32+ } ;
33+
34+ // Helper to ensure the plan object has the correct shape if needed
35+ const normalizePlan = ( plan : any ) : Plan => {
36+ return plan as Plan ;
37+ } ;
38+
39+ const translations = {
40+ en : {
41+ currency : '$' ,
42+ featured : 'Featured' ,
43+ } ,
44+ fr : {
45+ currency : '€' ,
46+ featured : 'En vedette' ,
47+ } ,
3048} ;
3149
3250export const Pricing = ( {
3351 heading,
3452 sub_heading,
3553 plans,
54+ locale = 'en' ,
3655} : {
3756 heading : string ;
3857 sub_heading : string ;
3958 plans : any [ ] ;
59+ locale ?: string ;
4060} ) => {
4161 const onClick = ( plan : Plan ) => {
4262 console . log ( 'click' , plan ) ;
@@ -51,95 +71,123 @@ export const Pricing = ({
5171 < Subheading className = "max-w-3xl mx-auto" > { sub_heading } </ Subheading >
5272 < div className = "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 max-w-7xl mx-auto gap-4 py-20 lg:items-start" >
5373 { plans . map ( ( plan ) => (
54- < Card onClick = { ( ) => onClick ( plan ) } key = { plan . name } plan = { plan } />
74+ < Card
75+ onClick = { onClick }
76+ key = { plan . name }
77+ plan = { plan }
78+ locale = { locale }
79+ />
5580 ) ) }
5681 </ div >
5782 </ Container >
5883 </ div >
5984 ) ;
6085} ;
6186
62- const Card = ( { plan, onClick } : { plan : Plan ; onClick : ( ) => void } ) => {
87+ const Card = ( {
88+ plan,
89+ onClick,
90+ locale,
91+ } : {
92+ plan : Plan ;
93+ onClick : ( plan : Plan ) => void ;
94+ locale : string ;
95+ } ) => {
96+ const t = translations [ locale as keyof typeof translations ] || translations . en ;
97+
98+ // Try to find the plan content that matches the current locale
99+ // This handles cases where the page links to the English plan but a French version exists
100+ let displayPlan = plan ;
101+ if ( plan . localizations && plan . localizations . length > 0 ) {
102+ const localizedPlan = plan . localizations . find ( ( p ) => p . locale === locale ) ;
103+ if ( localizedPlan ) {
104+ displayPlan = normalizePlan ( localizedPlan ) ; // helper to ensure shape matches if needed, but assuming same shape
105+ }
106+ }
107+
108+ // Ensure perks are also localized if the plan didn't switch or if structure is different
109+ // Assuming localizedPlan has its own perks.
110+
63111 return (
64112 < div
65113 className = { cn (
66114 'p-4 md:p-4 rounded-3xl bg-neutral-900 border-2 border-neutral-800' ,
67- plan . featured && 'border-neutral-50 bg-neutral-100'
115+ displayPlan . featured && 'border-neutral-50 bg-neutral-100'
68116 ) }
69117 >
70118 < div
71119 className = { cn (
72120 'p-4 bg-neutral-800 rounded-2xl shadow-[0px_-1px_0px_0px_var(--neutral-700)]' ,
73- plan . featured && 'bg-white shadow-aceternity'
121+ displayPlan . featured && 'bg-white shadow-aceternity'
74122 ) }
75123 >
76124 < div className = "flex justify-between items-center" >
77- < p className = { cn ( 'font-medium' , plan . featured && 'text-black' ) } >
78- { plan . name }
125+ < p className = { cn ( 'font-medium' , displayPlan . featured && 'text-black' ) } >
126+ { displayPlan . name }
79127 </ p >
80- { plan . featured && (
128+ { displayPlan . featured && (
81129 < div
82130 className = { cn (
83131 'font-medium text-xs px-3 py-1 rounded-full relative bg-neutral-900'
84132 ) }
85133 >
86134 < div className = "absolute inset-x-0 bottom-0 w-3/4 mx-auto h-px bg-gradient-to-r from-transparent via-indigo-500 to-transparent" > </ div >
87- Featured
135+ { t . featured }
88136 </ div >
89137 ) }
90138 </ div >
91- < div className = "mt-8" >
92- { plan . price && (
139+ < div className = "mt-8 flex items-baseline " >
140+ { displayPlan . price && (
93141 < span
94142 className = { cn (
95143 'text-lg font-bold text-neutral-500' ,
96- plan . featured && 'text-neutral-700'
144+ displayPlan . featured && 'text-neutral-700'
97145 ) }
98146 >
99- $
147+ { t . currency }
100148 </ span >
101149 ) }
102150 < span
103- className = { cn ( 'text-4xl font-bold' , plan . featured && 'text-black' ) }
151+ className = { cn ( 'text-4xl font-bold' , displayPlan . featured && 'text-black' ) }
104152 >
105- { plan . price || plan ?. CTA ?. text }
153+ { displayPlan . price || displayPlan ?. CTA ?. text }
106154 </ span >
107- { plan . price && (
155+ { displayPlan . price && (
108156 < span
109157 className = { cn (
110158 'text-lg font-normal text-neutral-500 ml-2' ,
111- plan . featured && 'text-neutral-700'
159+ displayPlan . featured && 'text-neutral-700'
112160 ) }
113161 >
114- / launch
162+ launch
115163 </ span >
116164 ) }
117165 </ div >
118166 < Button
119167 variant = "outline"
120168 className = { cn (
121169 'w-full mt-10 mb-4' ,
122- plan . featured &&
123- 'bg-black text-white hover:bg-black/80 hover:text-white'
170+ displayPlan . featured &&
171+ 'bg-black text-white hover:bg-black/80 hover:text-white'
124172 ) }
125- onClick = { onClick }
173+ onClick = { ( ) => onClick ( displayPlan ) }
126174 >
127- { plan ?. CTA ?. text }
175+ { displayPlan ?. CTA ?. text }
128176 </ Button >
129177 </ div >
130178 < div className = "mt-1 p-4" >
131- { plan . perks . map ( ( feature , idx ) => (
132- < Step featured = { plan . featured } key = { idx } >
179+ { displayPlan . perks . map ( ( feature , idx ) => (
180+ < Step featured = { displayPlan . featured } key = { idx } >
133181 { feature . text }
134182 </ Step >
135183 ) ) }
136184 </ div >
137- { plan . additional_perks && plan . additional_perks . length > 0 && (
138- < Divider featured = { plan . featured } />
185+ { displayPlan . additional_perks && displayPlan . additional_perks . length > 0 && (
186+ < Divider featured = { displayPlan . featured } />
139187 ) }
140188 < div className = "p-4" >
141- { plan . additional_perks ?. map ( ( feature , idx ) => (
142- < Step featured = { plan . featured } additional key = { idx } >
189+ { displayPlan . additional_perks ?. map ( ( feature , idx ) => (
190+ < Step featured = { displayPlan . featured } additional key = { idx } >
143191 { feature . text }
144192 </ Step >
145193 ) ) }
@@ -148,6 +196,7 @@ const Card = ({ plan, onClick }: { plan: Plan; onClick: () => void }) => {
148196 ) ;
149197} ;
150198
199+
151200const Step = ( {
152201 children,
153202 additional,
0 commit comments