Commit 48fbf4f 1 parent ec0d096 commit 48fbf4f Copy full SHA for 48fbf4f
File tree 3 files changed +18
-14
lines changed
3 files changed +18
-14
lines changed Original file line number Diff line number Diff line change 18
18
19
19
import { revalidatePath } from 'next/cache' ;
20
20
21
- import { post } from '@/utils/request ' ;
21
+ import { applyOne } from '#/domain/bounty/repository ' ;
22
22
23
23
export async function applyAction ( id , comment ) {
24
24
try {
25
- const res = await post ( `ts/v1/build/general/bounties/${ id } /builders` , { comment } , { isServer : true } ) ;
26
- if ( res . code === 200 ) {
27
- return revalidatePath ( '/' ) ;
28
- } else {
29
- return res ;
30
- }
25
+ const res = await applyOne ( id , { comment } ) ;
26
+ return res . success ? revalidatePath ( '/' ) : res ;
31
27
} catch ( e ) {
32
28
return { message : 'Failed to request' } ;
33
29
}
Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ import { Suspense } from 'react';
18
18
19
19
import { PreviewAlert } from '@/components/PreviewAlert' ;
20
20
import { fromNow } from '@/utils/date' ;
21
- import { get } from '@/utils/request' ;
21
+
22
+ import { fetchOne } from '#/domain/bounty/repository' ;
22
23
23
24
import { ChainNetworkTips } from '../Tips' ;
24
25
import { Activities } from './Activities' ;
@@ -27,11 +28,7 @@ import { Employers } from './Employers';
27
28
import { BountiesHeader } from './Header' ;
28
29
29
30
export default async function Page ( { params, searchParams } ) {
30
- const datas = await Promise . all ( [
31
- get ( `ts/v1/build/general/bounties/${ params . id } ` , { isServer : true } ) ,
32
- // get(`ts/v1/build/general/bounties/${params.id}/builders`, {isServer: true})
33
- ] ) ;
34
- const [ { data } ] = [ ...datas ] ;
31
+ const { data } = await fetchOne ( params . id ) ;
35
32
36
33
return (
37
34
< >
Original file line number Diff line number Diff line change @@ -39,6 +39,14 @@ async function fetchList(params = {}) {
39
39
} ) ;
40
40
}
41
41
42
+ async function fetchOne ( id ) {
43
+ return httpClient . get ( `/build/general/bounties/${ id } ` ) ;
44
+ }
45
+
46
+ async function applyOne ( id , data ) {
47
+ return httpClient . post ( `/build/general/bounties/${ id } /builders` , data ) ;
48
+ }
49
+
42
50
async function fetchPublishedBountyList ( params = { } ) {
43
51
const { userId, ...others } = params ;
44
52
@@ -53,4 +61,7 @@ async function fetchAppliedBountyList(params = {}) {
53
61
} ) ;
54
62
}
55
63
56
- export { fetchList , fetchPublishedBountyList , fetchAppliedBountyList } ;
64
+ export {
65
+ fetchList , fetchOne , applyOne ,
66
+ fetchPublishedBountyList , fetchAppliedBountyList ,
67
+ } ;
You can’t perform that action at this time.
0 commit comments