1
- import { Suspense } from "react" ;
1
+ import React , { Suspense } from "react" ;
2
2
import { ProfileSubTabKey , subTabs } from "@/app/profile/[address]/tabs" ;
3
3
import ExploreListSkeleton from "@/components/explore/explore-list-skeleton" ;
4
4
import { SubTabsWithCount } from "@/components/profile/sub-tabs-with-count" ;
5
5
import { getBlueprints } from "@/blueprints/getBlueprints" ;
6
6
import BlueprintsList from "@/components/blueprints/blueprints-list" ;
7
+ import { CreateBlueprintButton } from "@/components/blueprints/buttons" ;
8
+ import { OwnAccountOnly } from "@/components/own-account-only" ;
9
+ import { BlueprintsTable } from "@/components/blueprints/blueprints-table" ;
10
+ import { BLUEPRINTS_PER_PAGE } from "@/configs/ui" ;
11
+ import Pagination from "@/components/pagination" ;
7
12
8
13
const BlueprintTabContentInner = async ( {
9
14
address,
10
15
activeTab,
16
+ searchParams,
11
17
} : {
12
18
address : string ;
13
19
activeTab : ProfileSubTabKey ;
20
+ searchParams : Record < string , string > ;
14
21
} ) => {
22
+ const currentPage = Number ( searchParams ?. p ) || 1 ;
23
+
15
24
const availableBlueprints = await getBlueprints ( {
16
25
filters : { minterAddress : address as `0x${string } `, minted : false } ,
26
+ first : BLUEPRINTS_PER_PAGE ,
27
+ offset : BLUEPRINTS_PER_PAGE * ( currentPage - 1 ) ,
17
28
} ) ;
18
29
const mintedBlueprints = await getBlueprints ( {
19
30
filters : { minterAddress : address as `0x${string } `, minted : true } ,
31
+ first : BLUEPRINTS_PER_PAGE ,
32
+ offset : BLUEPRINTS_PER_PAGE * ( currentPage - 1 ) ,
33
+ } ) ;
34
+ const blueprintsCreated = await getBlueprints ( {
35
+ filters : { adminAddress : address as `0x${string } ` } ,
36
+ first : BLUEPRINTS_PER_PAGE ,
37
+ offset : BLUEPRINTS_PER_PAGE * ( currentPage - 1 ) ,
20
38
} ) ;
21
39
22
40
const marketplaceSubTabs = subTabs . filter (
@@ -28,8 +46,10 @@ const BlueprintTabContentInner = async ({
28
46
> = {
29
47
"blueprints-claimable" : availableBlueprints ?. count ?? 0 ,
30
48
"blueprints-claimed" : mintedBlueprints ?. count ?? 0 ,
31
- "blueprints-created" : availableBlueprints ?. count ?? 0 ,
49
+ "blueprints-created" : blueprintsCreated ?. count ?? 0 ,
32
50
} ;
51
+ const currentCount =
52
+ tabBadgeCounts [ activeTab as ( typeof subTabs ) [ number ] [ "key" ] ] ;
33
53
return (
34
54
< section >
35
55
< SubTabsWithCount
@@ -38,6 +58,12 @@ const BlueprintTabContentInner = async ({
38
58
tabBadgeCounts = { tabBadgeCounts }
39
59
tabs = { marketplaceSubTabs }
40
60
/>
61
+
62
+ < OwnAccountOnly addressToMatch = { address } >
63
+ < div className = "flex justify-end mb-2" >
64
+ < CreateBlueprintButton />
65
+ </ div >
66
+ </ OwnAccountOnly >
41
67
{ activeTab === "blueprints-claimable" && (
42
68
< BlueprintsList blueprints = { availableBlueprints ?. blueprints || [ ] } />
43
69
) }
@@ -47,22 +73,34 @@ const BlueprintTabContentInner = async ({
47
73
) }
48
74
49
75
{ activeTab === "blueprints-created" && (
50
- < BlueprintsList blueprints = { availableBlueprints ?. blueprints || [ ] } />
76
+ < BlueprintsTable
77
+ blueprints = { blueprintsCreated ?. blueprints || [ ] }
78
+ count = { blueprintsCreated ?. count }
79
+ />
51
80
) }
81
+ < div className = "mt-5" >
82
+ < Pagination count = { currentCount || 0 } pageSize = { BLUEPRINTS_PER_PAGE } />
83
+ </ div >
52
84
</ section >
53
85
) ;
54
86
} ;
55
87
56
88
const BlueprintsTabContent = ( {
57
89
address,
58
90
activeTab,
91
+ searchParams,
59
92
} : {
60
93
address : string ;
61
94
activeTab : ProfileSubTabKey ;
95
+ searchParams : Record < string , string > ;
62
96
} ) => {
63
97
return (
64
98
< Suspense fallback = { < ExploreListSkeleton length = { 9 } /> } >
65
- < BlueprintTabContentInner address = { address } activeTab = { activeTab } />
99
+ < BlueprintTabContentInner
100
+ address = { address }
101
+ activeTab = { activeTab }
102
+ searchParams = { searchParams }
103
+ />
66
104
</ Suspense >
67
105
) ;
68
106
} ;
0 commit comments