@@ -178,6 +178,7 @@ class ProfilePage extends React.Component {
178
178
visibilityLearningGoal,
179
179
languageProficiencies,
180
180
visibilityLanguageProficiencies,
181
+ courseCertificates,
181
182
visibilityCourseCertificates,
182
183
bio,
183
184
visibilityBio,
@@ -196,6 +197,17 @@ class ProfilePage extends React.Component {
196
197
changeHandler : this . handleChange ,
197
198
} ;
198
199
200
+ const isBlockVisible = ( blockInfo ) => this . isAuthenticatedUserProfile ( )
201
+ || ( ! this . isAuthenticatedUserProfile ( ) && Boolean ( blockInfo ) ) ;
202
+
203
+ const isLanguageBlockVisible = isBlockVisible ( languageProficiencies . length ) ;
204
+ const isEducationBlockVisible = isBlockVisible ( levelOfEducation ) ;
205
+ const isSocialLinksBLockVisible = isBlockVisible ( socialLinks . some ( ( link ) => link . socialLink !== null ) ) ;
206
+ const isBioBlockVisible = isBlockVisible ( bio ) ;
207
+ const isCertificatesBlockVisible = isBlockVisible ( courseCertificates . length ) ;
208
+ const isNameBlockVisible = isBlockVisible ( name ) ;
209
+ const isLocationBlockVisible = isBlockVisible ( country ) ;
210
+
199
211
return (
200
212
< div className = "container-fluid" >
201
213
< div className = "row align-items-center pt-4 mb-4 pt-md-0 mb-md-0" >
@@ -230,46 +242,58 @@ class ProfilePage extends React.Component {
230
242
< div className = "d-md-none mb-4" >
231
243
{ this . renderViewMyRecordsButton ( ) }
232
244
</ div >
233
- < Name
234
- name = { name }
235
- visibilityName = { visibilityName }
236
- formId = "name"
237
- { ...commonFormProps }
238
- />
239
- < Country
240
- country = { country }
241
- visibilityCountry = { visibilityCountry }
242
- formId = "country"
243
- { ...commonFormProps }
244
- />
245
- < PreferredLanguage
246
- languageProficiencies = { languageProficiencies }
247
- visibilityLanguageProficiencies = { visibilityLanguageProficiencies }
248
- formId = "languageProficiencies"
249
- { ...commonFormProps }
250
- />
251
- < Education
252
- levelOfEducation = { levelOfEducation }
253
- visibilityLevelOfEducation = { visibilityLevelOfEducation }
254
- formId = "levelOfEducation"
255
- { ...commonFormProps }
256
- />
257
- < SocialLinks
258
- socialLinks = { socialLinks }
259
- draftSocialLinksByPlatform = { draftSocialLinksByPlatform }
260
- visibilitySocialLinks = { visibilitySocialLinks }
261
- formId = "socialLinks"
262
- { ...commonFormProps }
263
- />
245
+ { isNameBlockVisible && (
246
+ < Name
247
+ name = { name }
248
+ visibilityName = { visibilityName }
249
+ formId = "name"
250
+ { ...commonFormProps }
251
+ />
252
+ ) }
253
+ { isLocationBlockVisible && (
254
+ < Country
255
+ country = { country }
256
+ visibilityCountry = { visibilityCountry }
257
+ formId = "country"
258
+ { ...commonFormProps }
259
+ />
260
+ ) }
261
+ { isLanguageBlockVisible && (
262
+ < PreferredLanguage
263
+ languageProficiencies = { languageProficiencies }
264
+ visibilityLanguageProficiencies = { visibilityLanguageProficiencies }
265
+ formId = "languageProficiencies"
266
+ { ...commonFormProps }
267
+ />
268
+ ) }
269
+ { isEducationBlockVisible && (
270
+ < Education
271
+ levelOfEducation = { levelOfEducation }
272
+ visibilityLevelOfEducation = { visibilityLevelOfEducation }
273
+ formId = "levelOfEducation"
274
+ { ...commonFormProps }
275
+ />
276
+ ) }
277
+ { isSocialLinksBLockVisible && (
278
+ < SocialLinks
279
+ socialLinks = { socialLinks }
280
+ draftSocialLinksByPlatform = { draftSocialLinksByPlatform }
281
+ visibilitySocialLinks = { visibilitySocialLinks }
282
+ formId = "socialLinks"
283
+ { ...commonFormProps }
284
+ />
285
+ ) }
264
286
</ div >
265
287
< div className = "pt-md-3 col-md-8 col-lg-7 offset-lg-1" >
266
288
{ ! this . isYOBDisabled ( ) && this . renderAgeMessage ( ) }
267
- < Bio
268
- bio = { bio }
269
- visibilityBio = { visibilityBio }
270
- formId = "bio"
271
- { ...commonFormProps }
272
- />
289
+ { isBioBlockVisible && (
290
+ < Bio
291
+ bio = { bio }
292
+ visibilityBio = { visibilityBio }
293
+ formId = "bio"
294
+ { ...commonFormProps }
295
+ />
296
+ ) }
273
297
{ getConfig ( ) . ENABLE_SKILLS_BUILDER_PROFILE && (
274
298
< LearningGoal
275
299
learningGoal = { learningGoal }
@@ -278,11 +302,13 @@ class ProfilePage extends React.Component {
278
302
{ ...commonFormProps }
279
303
/>
280
304
) }
281
- < Certificates
282
- visibilityCourseCertificates = { visibilityCourseCertificates }
283
- formId = "certificates"
284
- { ...commonFormProps }
285
- />
305
+ { isCertificatesBlockVisible && (
306
+ < Certificates
307
+ visibilityCourseCertificates = { visibilityCourseCertificates }
308
+ formId = "certificates"
309
+ { ...commonFormProps }
310
+ />
311
+ ) }
286
312
</ div >
287
313
</ div >
288
314
</ div >
@@ -348,7 +374,7 @@ ProfilePage.propTypes = {
348
374
349
375
// Learning Goal form data
350
376
learningGoal : PropTypes . string ,
351
- visibilityLearningGoal : PropTypes . string . isRequired ,
377
+ visibilityLearningGoal : PropTypes . string ,
352
378
353
379
// Other data we need
354
380
profileImage : PropTypes . shape ( {
@@ -397,6 +423,7 @@ ProfilePage.defaultProps = {
397
423
courseCertificates : null ,
398
424
requiresParentalConsent : null ,
399
425
dateJoined : null ,
426
+ visibilityLearningGoal : null ,
400
427
} ;
401
428
402
429
export default connect (
0 commit comments