|
15 | 15 | */
|
16 | 16 |
|
17 | 17 | import { useState } from 'react';
|
18 |
| -import { useDebouncedCallback } from 'use-debounce'; |
19 | 18 |
|
20 |
| -import { isBlockDataValid } from '@/components/control/block-editor/helper'; |
21 | 19 | import useAppConfig from '@/hooks/useAppConfig';
|
22 |
| -import useMounted from '@/hooks/useMounted'; |
23 | 20 |
|
24 |
| -import { useViewingSelf } from '../../../auth/hooks'; |
25 | 21 | import PublishedBountyListView from '../../../bounty/views/published-bounty-list';
|
26 | 22 | import PublishedChallengeListView from '../../../challenge/views/published-challenge-list';
|
27 | 23 | import PublishedCourseListView from '../../../course/views/published-course-list';
|
28 | 24 | import PublishedQuizListView from '../../../quiz/views/published-quiz-list';
|
29 |
| -import { fetchBlockContent, updateBlockContent } from '../../repository'; |
30 | 25 | import ActivityTabListWidget from '../../widgets/activity-tab-list';
|
31 | 26 | import SocialInfoWidget from '../../widgets/social-info';
|
32 | 27 | import TabBarWidget from '../../widgets/tab-bar';
|
33 |
| -import CustomContent from './CustomContent'; |
34 |
| -import LatestActivityList from './LatestActivityList'; |
| 28 | +import DevPlaza from './DevPlaza'; |
35 | 29 |
|
36 |
| -function resolveTabs(published) { |
37 |
| - return [ |
| 30 | +function resolveTabs(published, extraTabs = []) { |
| 31 | + return [].concat(extraTabs, [ |
38 | 32 | {
|
39 | 33 | text: 'Open Course',
|
40 | 34 | node: (
|
@@ -75,56 +69,44 @@ function resolveTabs(published) {
|
75 | 69 | ),
|
76 | 70 | view: PublishedQuizListView,
|
77 | 71 | },
|
78 |
| - ]; |
| 72 | + ]); |
79 | 73 | };
|
80 | 74 |
|
81 |
| -function TeamProfileView({ data, activities }) { |
82 |
| - const [tabActive, setTabActive] = useState(1); |
83 |
| - const [blockContent, setBlockContent] = useState(null); |
84 |
| - const viewingSelf = useViewingSelf(data?.base.user_id); |
| 75 | +function TeamProfileView({ data }) { |
| 76 | + const [tabActive, setTabActive] = useState(0); |
85 | 77 | const devPlazaEnabled = useAppConfig('devPlaza.enabled');
|
86 | 78 |
|
87 |
| - useMounted(() => { |
88 |
| - devPlazaEnabled && |
89 |
| - fetchBlockContent(data?.base.user_id).then(res => { |
90 |
| - if (res.success) { |
91 |
| - setBlockContent(res.data); |
92 |
| - } |
93 |
| - }); |
94 |
| - }); |
95 |
| - |
96 |
| - const handleBlockChange = useDebouncedCallback(updateBlockContent, 3000); |
97 |
| - |
98 | 79 | const tabContent = [
|
99 | 80 | <SocialInfoWidget key="social" data={data} />,
|
100 |
| - <LatestActivityList key="activity" activities={activities} />, |
101 | 81 | ];
|
102 | 82 |
|
103 |
| - const rerenderKey = [ |
104 |
| - 'CustomContent', |
105 |
| - `${viewingSelf ? 'editable' : 'readonly'}`, |
106 |
| - isBlockDataValid(blockContent), |
107 |
| - ].join('-'); |
| 83 | + const extraTabs = []; |
| 84 | + |
| 85 | + if (devPlazaEnabled) { |
| 86 | + extraTabs.push({ |
| 87 | + text: 'DevPlaza', |
| 88 | + node: ( |
| 89 | + <> |
| 90 | + <span className="inline md:hidden">DevPlaza</span> |
| 91 | + <span className="hidden md:inline">DevPlaza</span> |
| 92 | + </> |
| 93 | + ), |
| 94 | + view: DevPlaza, |
| 95 | + filterable: false, |
| 96 | + }); |
| 97 | + } |
108 | 98 |
|
109 | 99 | return (
|
110 | 100 | <div className="md:pl-[410px] md:pb-14 md:pr-14">
|
111 |
| - {devPlazaEnabled && ( |
112 |
| - <CustomContent |
113 |
| - key={rerenderKey} |
114 |
| - className="mb-6" |
115 |
| - data={blockContent} |
116 |
| - onChange={handleBlockChange} |
117 |
| - editable={viewingSelf} |
118 |
| - /> |
119 |
| - )} |
120 | 101 | <TabBarWidget
|
121 |
| - tabs={['Info', 'Activities']} |
122 |
| - tabClassName="h-14 md:h-9 md:w-[111px] md:first:hidden" |
| 102 | + className="md:hidden" |
| 103 | + tabs={['Info']} |
| 104 | + tabClassName="h-14 md:h-9 md:w-[111px]" |
123 | 105 | current={tabActive}
|
124 | 106 | onChange={setTabActive}
|
125 | 107 | />
|
126 |
| - {tabContent[tabActive]} |
127 |
| - <ActivityTabListWidget userId={data?.base.user_id} tabs={resolveTabs(data?.num)} /> |
| 108 | + <div className="mb-9 md:hidden">{tabContent[tabActive]}</div> |
| 109 | + <ActivityTabListWidget userId={data?.base.user_id} tabs={resolveTabs(data?.num, extraTabs)} /> |
128 | 110 | </div>
|
129 | 111 | );
|
130 | 112 | }
|
|
0 commit comments