16
16
17
17
'use client' ;
18
18
19
- import clsx from 'clsx' ;
20
- import Image from 'next/image' ;
21
19
import useSWR from 'swr' ;
22
20
23
- import { RefetchIcon , StartTimeIcon , PushDoorIcon , AddThreeIcon , FinishedIcon } from '@/components/Icons' ;
24
21
import { NoData } from '@/components/NoData' ;
25
- import { fromNow } from '@/utils/date' ;
26
22
import { fetcher } from '@/utils/request' ;
27
23
28
- import { useMediaUrl } from '#/state/application/hooks' ;
24
+ import { ActivityListView } from '#/domain/bounty' ;
25
+
29
26
30
27
export function Activities ( { id } ) {
31
28
const { data } = useSWR ( `ts/v1/build/general/bounties/${ id } /events/activities` , fetcher , { suspense : true } ) ;
32
- const mediaUrl = useMediaUrl ( ) ;
33
- // console.log(data)
29
+
34
30
return (
35
31
< div >
36
32
< div className = "mb-6 flex items-center justify-between" >
@@ -39,128 +35,8 @@ export function Activities({ id }) {
39
35
Publish a discussion
40
36
</Button> */ }
41
37
</ 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
- application was
100
- < span className = "mx-1 rounded-full bg-[#009C8E] px-2 py-1 text-white" >
101
- approved
102
- </ span >
103
- and < 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
- 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's recruitment < strong className = "mr-1" > restarted</ strong >
156
- </ p >
157
- </ >
158
- ) }
159
- < p className = "opacity-50 max-md:inline" > · 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 >
164
40
</ div >
165
41
) ;
166
42
}
0 commit comments