* feat: add YourFilesSection to DashboardStorage page * refactor: remove file preview column * style: add monospace font to file size text * fix(components): fix YourFilesSection pagination and data fetching * fix(dropzone): Invalidate pinned files query on file upload * feat(storage): add file list refetch on upload * chore(useApi): keep the promise around to avoid multiple fetches * feat: Add AccountPermissionsV1 to guides and templates
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import { embeddedWalletsKeys } from "../cache-keys";
|
|
import { THIRDWEB_EWS_API_HOST } from "constants/urls";
|
|
import { useLoggedInUser } from "./useLoggedInUser";
|
|
|
|
// FIXME: Make API to return camelCase or transform
|
|
export type EmbeddedWalletUser = {
|
|
id: string;
|
|
client_id: string;
|
|
created_at: string;
|
|
last_accessed_at: string;
|
|
|
|
embedded_wallet: {
|
|
id: string;
|
|
address: string;
|
|
chain: string;
|
|
wallet_user_id: string;
|
|
}[];
|
|
ews_authed_user: {
|
|
id: string;
|
|
authed_user_id: string;
|
|
email: string;
|
|
}[];
|
|
};
|
|
|
|
export function useEmbeddedWallets(clientId: string) {
|
|
const { user, isLoggedIn } = useLoggedInUser();
|
|
|
|
return useQuery(
|
|
embeddedWalletsKeys.embeddedWallets(
|
|
user?.address as string,
|
|
clientId as string,
|
|
),
|
|
async () => {
|
|
const res = await fetch(
|
|
`${THIRDWEB_EWS_API_HOST}/api/thirdweb/embedded-wallet?clientId=${clientId}&lastAccessedAt=0`,
|
|
{
|
|
method: "GET",
|
|
credentials: "include",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
},
|
|
);
|
|
|
|
const json = await res.json();
|
|
|
|
return json.walletUsers as EmbeddedWalletUser[];
|
|
},
|
|
{ enabled: !!user?.address && isLoggedIn && !!clientId },
|
|
);
|
|
}
|