|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
| 17 | +import clsx from 'clsx'; |
17 | 18 | import { useState } from 'react'; |
18 | 19 |
|
19 | 20 | import AppliedBountyListView from '../../../bounty/views/applied-bounty-list'; |
@@ -70,25 +71,45 @@ const tabs = [ |
70 | 71 | }, |
71 | 72 | ]; |
72 | 73 |
|
73 | | -function IndividualProfileView({ data }) { |
74 | | - const [tabActive, setTabActive] = useState(2); |
75 | | - const userId = data?.base.user_id; |
| 74 | +function resolveBasicTabGroup(data) { |
| 75 | + const { reputationList, skill } = data?.extra || {}; |
76 | 76 |
|
| 77 | + const tabLabels = ['Info', 'Reputation']; |
77 | 78 | const tabContent = [ |
78 | 79 | <SocialInfoWidget key="social" data={data} />, |
79 | | - <GainedReputationListView key="reputation" data={data?.extra.reputationList} />, |
80 | | - <SkillOverviewView key="skill" userId={userId} />, |
| 80 | + <GainedReputationListView key="reputation" data={reputationList} />, |
81 | 81 | ]; |
82 | 82 |
|
| 83 | + if (skill) { |
| 84 | + tabLabels.push('Skill insight'); |
| 85 | + tabContent.push(<SkillOverviewView key="skill" data={skill} />); |
| 86 | + } |
| 87 | + |
| 88 | + return { |
| 89 | + tabLabels, |
| 90 | + tabContent, |
| 91 | + hideInDesktop: !skill, |
| 92 | + }; |
| 93 | +} |
| 94 | + |
| 95 | +function IndividualProfileView({ data }) { |
| 96 | + const [tabActive, setTabActive] = useState(data?.extra.skill ? 2 : 1); |
| 97 | + |
| 98 | + const userId = data?.base.user_id; |
| 99 | + const { tabLabels, tabContent, hideInDesktop } = resolveBasicTabGroup(data); |
| 100 | + |
83 | 101 | return ( |
84 | 102 | <div className="md:pl-[410px] md:pb-14 md:pr-14"> |
85 | 103 | <TabBarWidget |
86 | | - tabs={['Info', 'Reputation', 'Skill insight']} |
87 | | - tabClassName={`h-14 md:h-9 md:w-[119px] ${style.Tab}`} |
| 104 | + className={clsx({ 'md:hidden': hideInDesktop })} |
| 105 | + tabs={tabLabels} |
| 106 | + tabClassName={clsx('h-14 md:h-9 md:w-[119px]', style.Tab)} |
88 | 107 | current={tabActive} |
89 | 108 | onChange={setTabActive} |
90 | 109 | /> |
91 | | - {tabContent[tabActive]} |
| 110 | + <div className={clsx('mb-9', { 'md:hidden': hideInDesktop })}> |
| 111 | + {tabContent[tabActive]} |
| 112 | + </div> |
92 | 113 | <ActivityTabListWidget userId={userId} tabs={tabs} /> |
93 | 114 | </div> |
94 | 115 | ); |
|
0 commit comments