@@ -4,6 +4,7 @@ import classNames from "classnames";
4
4
import Sefaria from "./sefaria/sefaria" ;
5
5
import { EnglishText , HebrewText , InterfaceText , OnInView } from "./Misc" ;
6
6
import $ from "./sefaria/sefariaJquery" ;
7
+ import { NewsletterSignUpForm } from "./NewsletterSignUpForm" ;
7
8
8
9
const Promotions = ( ) => {
9
10
const [ inAppAds , setInAppAds ] = useState ( Sefaria . _inAppAds ) ; // local cache
@@ -36,6 +37,11 @@ const Promotions = () => {
36
37
buttonIcon : sidebarAd . buttonIcon ,
37
38
buttonLocation : sidebarAd . buttonAboveOrBelow ,
38
39
hasBlueBackground : sidebarAd . hasBlueBackground ,
40
+ isNewsletterSubscriptionInputForm : sidebarAd . isNewsletterSubscriptionInputForm ,
41
+ newsletterMailingLists :
42
+ sidebarAd . newsletterMailingLists ?. data . map (
43
+ ( mailingLists ) => mailingLists . attributes . newsletterName
44
+ ) ?? [ ] ,
39
45
trigger : {
40
46
showTo : sidebarAd . showTo ,
41
47
interfaceLang : "english" ,
@@ -209,40 +215,47 @@ const SidebarAd = React.memo(({ context, matchingAd }) => {
209
215
) ;
210
216
}
211
217
212
- return (
213
- < OnInView onVisible = { ( ) => trackSidebarAdImpression ( matchingAd ) } >
214
- < div className = { classes } >
215
- < h3
216
- className = { context . interfaceLang === "hebrew" ? "int-he" : "int-en" }
217
- >
218
- { matchingAd . title }
219
- </ h3 >
220
- { matchingAd . buttonLocation === "below" ? (
221
- < >
222
- < p
223
- className = {
224
- context . interfaceLang === "hebrew" ? "int-he" : "int-en"
225
- }
226
- >
227
- { matchingAd . bodyText }
228
- </ p >
229
- { getButton ( ) }
230
- </ >
231
- ) : (
232
- < >
233
- { getButton ( ) }
234
- < p
235
- className = {
236
- context . interfaceLang === "hebrew" ? "int-he" : "int-en"
237
- }
238
- >
239
- { matchingAd . bodyText }
240
- </ p >
241
- </ >
242
- ) }
243
- </ div >
244
- </ OnInView >
245
- ) ;
218
+ const isHebrew = context . interfaceLang === "hebrew" ;
219
+ const getLanguageClass = ( ) => ( isHebrew ? "int-he" : "int-en" ) ;
220
+
221
+ return (
222
+ < OnInView onVisible = { ( ) => trackSidebarAdImpression ( matchingAd ) } >
223
+ < div className = { classes } >
224
+ < h3 className = { getLanguageClass ( ) } > { matchingAd . title } </ h3 >
225
+ { matchingAd . buttonLocation === "below" ? (
226
+ matchingAd . isNewsletterSubscriptionInputForm ? (
227
+ < >
228
+ < p className = { getLanguageClass ( ) } > { matchingAd . bodyText } </ p >
229
+ < NewsletterSignUpForm
230
+ context = { "Sidebar Ad: " + context . keywordTargets . toString ( ) }
231
+ includeEducatorOption = { false }
232
+ additionalNewsletterMailingLists = { matchingAd . newsletterMailingLists }
233
+ />
234
+ </ >
235
+ ) : (
236
+ < >
237
+ < p className = { getLanguageClass ( ) } > { matchingAd . bodyText } </ p >
238
+ { getButton ( ) }
239
+ </ >
240
+ )
241
+ ) : matchingAd . isNewsletterSubscriptionInputForm ? (
242
+ < >
243
+ < NewsletterSignUpForm
244
+ context = { "Sidebar Ad: " + context . keywordTargets . toString ( ) }
245
+ includeEducatorOption = { false }
246
+ additionalNewsletterMailingLists = { matchingAd . newsletterMailingLists }
247
+ />
248
+ < p className = { getLanguageClass ( ) } > { matchingAd . bodyText } </ p >
249
+ </ >
250
+ ) : (
251
+ < >
252
+ { getButton ( ) }
253
+ < p className = { getLanguageClass ( ) } > { matchingAd . bodyText } </ p >
254
+ </ >
255
+ ) }
256
+ </ div >
257
+ </ OnInView >
258
+ ) ;
246
259
} ) ;
247
260
248
261
export { Promotions , GDocAdvertBox } ;
0 commit comments