Skip to content

Commit 13a8ccc

Browse files
Add teamId support for embedded wallet user queries
Co-authored-by: joaquim.verges <[email protected]>
1 parent af95f25 commit 13a8ccc

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

apps/dashboard/src/@/hooks/useEmbeddedWallets.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ const fetchAccountList = ({
88
jwt,
99
clientId,
1010
ecosystemSlug,
11+
teamId,
1112
pageNumber,
1213
}: {
1314
jwt: string;
1415
clientId?: string;
1516
ecosystemSlug?: string;
17+
teamId: string;
1618
pageNumber: number;
1719
}) => {
1820
return async () => {
@@ -31,6 +33,7 @@ const fetchAccountList = ({
3133
headers: {
3234
Authorization: `Bearer ${jwt}`,
3335
"Content-Type": "application/json",
36+
"x-team-id": teamId,
3437
...(clientId && { "x-client-id": clientId }),
3538
},
3639
method: "GET",
@@ -49,17 +52,19 @@ const fetchAccountList = ({
4952
export function useEmbeddedWallets(params: {
5053
clientId?: string;
5154
ecosystemSlug?: string;
55+
teamId: string;
5256
page: number;
5357
authToken: string;
5458
}) {
55-
const { clientId, ecosystemSlug, page, authToken } = params;
59+
const { clientId, ecosystemSlug, teamId, page, authToken } = params;
5660
const address = useActiveAccount()?.address;
5761

5862
return useQuery({
5963
enabled: !!address && !!(clientId || ecosystemSlug),
6064
queryFn: fetchAccountList({
6165
clientId,
6266
ecosystemSlug,
67+
teamId,
6368
jwt: authToken,
6469
pageNumber: page,
6570
}),
@@ -78,7 +83,7 @@ export function useAllEmbeddedWallets(params: { authToken: string }) {
7883
const address = useActiveAccount()?.address;
7984

8085
return useMutation({
81-
mutationFn: async ({ clientId, ecosystemSlug }: { clientId?: string; ecosystemSlug?: string }) => {
86+
mutationFn: async ({ clientId, ecosystemSlug, teamId }: { clientId?: string; ecosystemSlug?: string; teamId: string }) => {
8287
const responses: WalletUser[] = [];
8388
let page = 1;
8489

@@ -89,6 +94,7 @@ export function useAllEmbeddedWallets(params: { authToken: string }) {
8994
queryFn: fetchAccountList({
9095
clientId,
9196
ecosystemSlug,
97+
teamId,
9298
jwt: authToken,
9399
pageNumber: page,
94100
}),

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/users/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default async function EcosystemUsersPage(props: {
3636
authToken={authToken}
3737
client={client}
3838
ecosystemSlug={ecosystem.slug}
39+
teamId={team.id}
3940
/>
4041
);
4142
}

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/users/components/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const columnHelper = createColumnHelper<WalletUser>();
4141
export function InAppWalletUsersPageContent(props: {
4242
authToken: string;
4343
client: ThirdwebClient;
44+
teamId: string;
4445
} & (
4546
| { projectClientId: string; ecosystemSlug?: never }
4647
| { ecosystemSlug: string; projectClientId?: never }
@@ -122,6 +123,7 @@ export function InAppWalletUsersPageContent(props: {
122123
authToken: props.authToken,
123124
clientId: props.projectClientId,
124125
ecosystemSlug: props.ecosystemSlug,
126+
teamId: props.teamId,
125127
page: activePage,
126128
});
127129
const wallets = walletsQuery?.data?.users || [];
@@ -137,6 +139,7 @@ export function InAppWalletUsersPageContent(props: {
137139
props.authToken,
138140
props.projectClientId,
139141
props.ecosystemSlug,
142+
props.teamId,
140143
searchType,
141144
query
142145
);
@@ -163,6 +166,7 @@ export function InAppWalletUsersPageContent(props: {
163166
const usersWallets = await getAllEmbeddedWallets({
164167
clientId: props.projectClientId,
165168
ecosystemSlug: props.ecosystemSlug,
169+
teamId: props.teamId,
166170
});
167171
const csv = Papa.unparse(
168172
usersWallets.map((row) => {

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/users/components/searchUsers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export async function searchUsers(
66
authToken: string,
77
clientId: string | undefined,
88
ecosystemSlug: string | undefined,
9+
teamId: string,
910
searchType: SearchType,
1011
query: string,
1112
): Promise<WalletUser[]> {
@@ -38,6 +39,7 @@ export async function searchUsers(
3839
headers: {
3940
Authorization: `Bearer ${authToken}`,
4041
"Content-Type": "application/json",
42+
"x-team-id": teamId,
4143
...(clientId && { "x-client-id": clientId }),
4244
},
4345
method: "GET",

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/users/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default async function Page(props: {
3434
authToken={authToken}
3535
client={client}
3636
projectClientId={project.publishableKey}
37+
teamId={project.teamId}
3738
/>
3839
);
3940
}

0 commit comments

Comments
 (0)