Skip to content

Commit 4e1053d

Browse files
committed
feat: bounty-detail refactor
1 parent 33b31b7 commit 4e1053d

File tree

3 files changed

+7
-130
lines changed

3 files changed

+7
-130
lines changed

src/app/bounties/[id]/Activities.js

+5-129
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,17 @@
1616

1717
'use client';
1818

19-
import clsx from 'clsx';
20-
import Image from 'next/image';
2119
import useSWR from 'swr';
2220

23-
import { RefetchIcon, StartTimeIcon, PushDoorIcon, AddThreeIcon, FinishedIcon } from '@/components/Icons';
2421
import { NoData } from '@/components/NoData';
25-
import { fromNow } from '@/utils/date';
2622
import { fetcher } from '@/utils/request';
2723

28-
import { useMediaUrl } from '#/state/application/hooks';
24+
import { ActivityListView } from '#/domain/bounty';
25+
2926

3027
export function Activities({ id }) {
3128
const { data } = useSWR(`ts/v1/build/general/bounties/${id}/events/activities`, fetcher, {suspense: true});
32-
const mediaUrl = useMediaUrl();
33-
// console.log(data)
29+
3430
return (
3531
<div>
3632
<div className="mb-6 flex items-center justify-between">
@@ -39,128 +35,8 @@ export function Activities({ id }) {
3935
Publish a discussion
4036
</Button> */}
4137
</div>
42-
<div>
43-
{data?.list &&
44-
data?.list?.map((i, k) => (
45-
<div
46-
key={`bounty-activities-${k}`}
47-
className={clsx('relative flex items-center pb-9 text-sm max-md:items-start', {
48-
'before:absolute before:left-[15px] before:top-0 before:h-full before:border-l before:border-gray-400':
49-
k !== data?.list.length - 1,
50-
})}
51-
>
52-
<div
53-
className={clsx(
54-
'relative z-10 flex h-8 w-8 items-center justify-center rounded-full border-2 border-gray-1000 max-md:mt-[-4px]',
55-
{
56-
'bg-[#E6E6E6]': i.bounty_status !== 30,
57-
'bg-[#FFE5D0]': i.bounty_status === 30,
58-
}
59-
)}
60-
>
61-
{i.bounty_status === 3 && i.builder_status_before === 100 && i.builder_status === 101 && (
62-
<AddThreeIcon />
63-
)}
64-
{(i.bounty_status === 6 || i.bounty_status === 24 ) && <PushDoorIcon />}
65-
{i.bounty_status === 7 && i.builder_status_before === 101 && i.builder_status === 107 && (
66-
<StartTimeIcon />
67-
)}
68-
{i.bounty_status === 3 && i.bounty_task > 1 && i.builder_status === 0 && <RefetchIcon />}
69-
{i.bounty_status === 30 && '🎉'}
70-
{(i.bounty_status === 30 || i.bounty_status === 15 || i.bounty_status === 19 || i.bounty_status === 23 || i.bounty_status === 14 || i.bounty_status_before === 14) && <FinishedIcon />}
71-
72-
</div>
73-
{i.bounty_status === 3 && i.builder_status_before === 100 && i.builder_status === 101 &&
74-
<>
75-
{mediaUrl && <Image width={24} height={24} src={mediaUrl + i.builder_user.user_avatar} alt="" className="ml-4 mr-2 h-6 w-6 rounded-full object-fill"/>}
76-
<p className="mr-2 max-md:inline">
77-
<a href={`/u/${i.builder_user?.user_handle}`}>{i.builder_user.user_nick_name}</a>
78-
<>
79-
<span className="mx-1 rounded-full bg-[#4000e0] px-2 py-1 text-white">applied</span>
80-
<span>this bounty</span>
81-
</>
82-
</p>
83-
</>
84-
}
85-
{i.bounty_status === 6 && (
86-
<>
87-
{mediaUrl && <Image width={24} height={24} src={mediaUrl + i.employer_user.user_avatar} alt="" className="ml-4 mr-2 h-6 w-6 rounded-full object-fill"/>}
88-
<p className="max-md:inline">
89-
<a href={`/u/${i.employer_user?.user_handle}`}><strong>{i.employer_user.user_nick_name}</strong> </a>pledged the
90-
<span className="mx-1 rounded-full bg-[#3e9de6] px-2 py-1 text-white">deposit</span>
91-
</p>
92-
</>
93-
)}
94-
{i.bounty_status === 7 && i.builder_status_before === 101 && i.builder_status === 107 && (
95-
<>
96-
{mediaUrl && <Image width={24} height={24} src={mediaUrl + i.builder_user.user_avatar} alt="" className="ml-4 mr-2 h-6 w-6 rounded-full object-fill"/>}
97-
<p className="max-md:inline">
98-
<a href={`/u/${i.builder_user?.user_handle}`}><strong>{i.builder_user.user_nick_name}</strong></a>
99-
&nbsp;application was&nbsp;
100-
<span className="mx-1 rounded-full bg-[#009C8E] px-2 py-1 text-white">
101-
approved
102-
</span>
103-
&nbsp;and&nbsp;<span className="mx-1 rounded-full bg-[#ff7c17] px-2 py-1 text-white">started building</span>
104-
</p>
105-
</>
106-
)}
107-
{i.bounty_status === 7 && i.bounty_status_before === 14 && (
108-
<>
109-
{mediaUrl && <Image width={24} height={24} src={mediaUrl + i.employer_user.user_avatar} alt="" className="ml-4 mr-2 h-6 w-6 rounded-full object-fill"/>}
110-
<p className="mr-2 max-md:inline">
111-
<a href={`/u/${i.employer_user?.user_handle}`}>
112-
<strong>
113-
{i.employer_user.user_nick_name}
114-
</strong>
115-
</a>
116-
<>
117-
<span className="mx-1 rounded-full bg-[#e01f21] px-2 py-1 text-white">rejected</span>
118-
<span>the application</span>
119-
</>
120-
</p>
121-
</>
122-
)}
123-
124-
{i.bounty_status === 14 && (
125-
<>
126-
{mediaUrl && <Image width={24} height={24} src={mediaUrl + i.builder_user.user_avatar} alt="" className="ml-4 mr-2 h-6 w-6 rounded-full object-fill"/>}
127-
<p className="mr-2 max-md:inline">
128-
<a href={`/u/${i.builder_user?.user_handle}`}>
129-
<strong>
130-
{i.builder_user.user_nick_name}
131-
</strong>
132-
</a>
133-
<>
134-
<span className="mx-1 rounded-full bg-[#4000e0] px-2 py-1 text-white">applied to complete</span>
135-
<span>this bounty</span>
136-
</>
137-
</p>
138-
</>
139-
)}
140-
{(i.bounty_status === 30 || i.bounty_status === 15 || i.bounty_status === 19 || i.bounty_status === 23) && (
141-
<>
142-
{mediaUrl && <Image width={24} height={24} src={mediaUrl + i.builder_user.user_avatar} alt="" className="ml-4 mr-2 h-6 w-6 rounded-full object-fill"/>}
143-
<p className="max-md:inline">
144-
<a href={`/u/${i.builder_user?.user_handle}`}>
145-
<strong>{i.builder_user.user_nick_name}</strong>
146-
</a>
147-
&nbsp;program has been <span className="mx-1 rounded-full bg-[#009C8E] px-2 py-1 text-white">adopted</span> and got the bounty
148-
</p>
149-
</>
150-
)}
151-
{i.bounty_status === 3 && i.bounty_task > 1 && i.builder_status === 0 && (
152-
<>
153-
{mediaUrl && <Image width={24} height={24} src={mediaUrl + i.employer_user.user_avatar} alt="" className="ml-4 mr-2 h-6 w-6 rounded-full object-fill"/>}
154-
<p className="max-md:inline">
155-
Bounty&#39;s recruitment <strong className="mr-1">restarted</strong>
156-
</p>
157-
</>
158-
)}
159-
<p className="opacity-50 max-md:inline">&nbsp;· Posted {fromNow(i.created_at * 1000)}</p>
160-
</div>
161-
))}
162-
</div>
163-
<div className="pb-14">{(!data || data?.list.length === 0) && <NoData />}</div>
38+
<ActivityListView data={data?.list} />
39+
<div className="pb-14">{(!data || data?.list?.length === 0) && <NoData />}</div>
16440
</div>
16541
);
16642
}

src/domain/bounty/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
*/
1616

1717
export { default as BountyListView } from './views/bounty-list';
18+
export { default as ActivityListView } from './views/activity-list';

src/domain/bounty/views/bounty-list/BountyList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function BountyList({
3333
className
3434
)}
3535
>
36-
{data?.list?.map(item => (
36+
{data?.map?.(item => (
3737
<BountyItem key={`BountyItem-${item.id}`} data={item} />
3838
))}
3939
</div>

0 commit comments

Comments
 (0)