Skip to content

Commit 731e4a1

Browse files
authored
feat(app/profile): apply the new NFT list design
Merge commits below into one: * feat: change NFC list style of profile * refactor: refactor logic of NFT list
1 parent 7aabad1 commit 731e4a1

File tree

7 files changed

+108
-65
lines changed

7 files changed

+108
-65
lines changed

src/domain/profile/repository.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import { unwrapBlockData, wrapBlockData } from '@/components/control/block-editor/helper';
1818
import httpClient from '@/utils/http';
1919

20+
import { fetchGainedReputationList } from '../reputation/repository';
21+
2022
async function fetchWeb3BioProfile(address) {
2123
return httpClient.get(`https://api.web3.bio/profile/${address}`, {
2224
headers: { 'X-API-KEY': process.env.NEXT_PUBLIC_WEB3BIO },
@@ -37,6 +39,12 @@ async function fetchUser(handle) {
3739
data.web3Bio = web3BioProfile;
3840
}
3941

42+
const { data: reputation } = await fetchGainedReputationList(data?.base.user_id);
43+
data.extra = {
44+
...data.extra,
45+
reputationList: reputation.list,
46+
};
47+
4048
return { ...others, data, success: true };
4149
}
4250

src/domain/profile/views/individual-profile/IndividualProfile.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import SkillOverviewView from '../../../skill/views/skill-overview';
2525
import ActivityTabListWidget from '../../widgets/activity-tab-list';
2626
import SocialInfoWidget from '../../widgets/social-info';
2727
import TabBarWidget from '../../widgets/tab-bar';
28+
import style from './style.module.scss';
2829

2930
const tabs = [
3031
{
@@ -70,20 +71,20 @@ const tabs = [
7071
];
7172

7273
function IndividualProfileView({ data }) {
73-
const [tabActive, setTabActive] = useState(1);
74+
const [tabActive, setTabActive] = useState(2);
7475
const userId = data?.base.user_id;
7576

7677
const tabContent = [
7778
<SocialInfoWidget key="social" data={data} />,
78-
<GainedReputationListView key="reputation" userId={userId} />,
79+
<GainedReputationListView key="reputation" data={data?.extra.reputationList} />,
7980
<SkillOverviewView key="skill" userId={userId} />,
8081
];
8182

8283
return (
8384
<div className="md:pl-[410px] md:pb-14 md:pr-14">
8485
<TabBarWidget
8586
tabs={['Info', 'Reputation', 'Skill insight']}
86-
tabClassName="h-14 md:h-9 md:w-[119px] md:first:hidden"
87+
tabClassName={`h-14 md:h-9 md:w-[119px] ${style.Tab}`}
8788
current={tabActive}
8889
onChange={setTabActive}
8990
/>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2024 OpenBuild
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
.Tab {
18+
@media (min-width: 768px) {
19+
&:nth-child(1),
20+
&:nth-child(2) {
21+
display: none;
22+
}
23+
}
24+
}

src/domain/profile/widgets/social-info/SocialInfo.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { useMemo } from 'react';
1818

1919
import { SvgIcon } from '@/components/Image';
2020

21+
import GainedReputationListView from '../../../reputation/views/gained-reputation-list';
2122
import SocialLink from './SocialLink';
2223
import Web3BioProfile from './Web3BioProfile';
2324

@@ -95,6 +96,12 @@ function SocialInfoWidget({ className, data }) {
9596
</div>
9697
</>
9798
)}
99+
{data?.extra?.reputationList?.length > 0 && (
100+
<>
101+
<p className="mt-6 uppercase text-xs opacity-60 font-bold">Reputation</p>
102+
<GainedReputationListView data={data?.extra?.reputationList} compact />
103+
</>
104+
)}
98105
<Web3BioProfile data={data} />
99106
{data.base?.user_show_email && data?.social?.user_email !== '' && (
100107
<>

src/domain/reputation/views/gained-reputation-list/GainedReputationItem.js renamed to src/domain/reputation/views/gained-reputation-list/GainedReputationItem.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,20 @@
1717
import Avatar from '@/components/Avatar';
1818
import { formatTime } from '@/utils/date';
1919

20-
function GainedReputationItem({ data }) {
21-
return (
20+
function GainedReputationItem({
21+
data,
22+
compact = false,
23+
}: {
24+
data: {
25+
img: string;
26+
title: string;
27+
updated_at: number;
28+
};
29+
compact?: boolean;
30+
}) {
31+
return compact ? (
32+
<Avatar src={data.img} alt={data.title} size={55} />
33+
) : (
2234
<div className="w-full aspect-square md:w-[180px] text-center p-4 border border-gray-600 rounded">
2335
<div className="flex justify-center">
2436
<Avatar src={data.img} alt={data.title} size={100} />

src/domain/reputation/views/gained-reputation-list/GainedReputationList.js

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Copyright 2024 OpenBuild
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import clsx from 'clsx';
18+
19+
import { NoData } from '@/components/NoData';
20+
21+
import GainedReputationItem from './GainedReputationItem';
22+
23+
function GainedReputationListView({
24+
data,
25+
compact = false,
26+
}: {
27+
data?: Array<{
28+
img: string;
29+
title: string;
30+
updated_at: number;
31+
id: string;
32+
}>;
33+
compact?: boolean;
34+
}) {
35+
return data && data.length > 0 ? (
36+
<div
37+
className={clsx({
38+
'grid grid-cols-5 gap-2 mt-4': compact,
39+
'grid grid-cols-2 gap-5 md:flex md:gap-6 mt-6': !compact,
40+
})}
41+
>
42+
{data.map(item => (
43+
<GainedReputationItem key={`reputation-${item.id}`} data={item} compact={compact} />
44+
))}
45+
</div>
46+
) : (
47+
<NoData className="mt-6" />
48+
);
49+
}
50+
51+
export default GainedReputationListView;

0 commit comments

Comments
 (0)