Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const SelectWithSearch = React.forwardRef<
? renderOption(selectedOption)
: selectedOption?.label || placeholder}
</span>
<ChevronDownIcon className="size-4 cursor-pointer text-muted-foreground" />
<ChevronDownIcon className="size-3.5 cursor-pointer text-muted-foreground shrink-0" />
</div>
</Button>
</PopoverTrigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import {
ArrowDownToLineIcon,
ArrowLeftIcon,
ArrowLeftRightIcon,
ArrowUpFromLineIcon,
EllipsisVerticalIcon,
ListCollapseIcon,
RefreshCcwIcon,
SendIcon,
ShuffleIcon,
WalletIcon,
Settings2Icon,
} from "lucide-react";
import { useTheme } from "next-themes";
import { useCallback, useMemo, useState } from "react";
Expand Down Expand Up @@ -49,6 +50,7 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import {
Expand Down Expand Up @@ -228,9 +230,12 @@ export function ProjectWalletDetailsSection(props: ProjectWalletControlsProps) {
return (
<div>
<div className="rounded-xl border border-border bg-card">
<div className="p-5 flex flex-col lg:flex-row gap-5">
<div className="flex-1">
<p className="text-sm text-foreground mb-1">Wallet Address</p>
<div className="px-5 py-4 border-b border-dashed flex justify-between items-center">
<div>
<h2 className="text-base font-semibold text-foreground mb-0.5 tracking-tight">
{projectWallet.label || "Project Wallet"}
</h2>

<CopyTextButton
textToShow={shortenAddress(projectWallet.address, 6)}
textToCopy={projectWallet.address}
Expand All @@ -241,14 +246,66 @@ export function ProjectWalletDetailsSection(props: ProjectWalletControlsProps) {
/>
</div>

<div className="flex-1">
<p className="text-sm text-foreground mb-1">Wallet Label</p>
<div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
<p className="text-sm break-all py-2 sm:py-0 text-muted-foreground">
{projectWallet.label || "N/A"}
</p>
</div>
</div>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="ghost"
size="sm"
className="w-auto h-auto p-2 rounded-full"
>
<EllipsisVerticalIcon className="size-5 text-muted-foreground" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent
align="end"
className="w-56 rounded-xl"
sideOffset={10}
>
<DropdownMenuItem
className="flex items-center gap-2"
onSelect={() => setIsReceiveOpen(true)}
>
<ArrowUpFromLineIcon className="size-4 text-muted-foreground" />
Deposit Funds
</DropdownMenuItem>
<DropdownMenuItem
className="flex items-center gap-2"
onSelect={() => setIsSendOpen(true)}
>
<ArrowDownToLineIcon className="size-4 text-muted-foreground" />
Withdraw Funds
</DropdownMenuItem>
<DropdownMenuItem
className="flex items-center gap-2"
onSelect={() => setIsSwapOpen(true)}
>
<ArrowLeftRightIcon className="size-4 text-muted-foreground" />
Swap Tokens
</DropdownMenuItem>
{/* add line */}
<DropdownMenuSeparator />
<DropdownMenuItem
className="flex items-center gap-2"
onSelect={() =>
router.push(
`/team/${props.teamSlug}/${props.project.slug}/transactions`,
)
}
>
<ListCollapseIcon className="size-4 text-muted-foreground" />
View Transactions
</DropdownMenuItem>
{canChangeWallet && (
<DropdownMenuItem
className="flex items-center gap-2"
onSelect={() => setIsChangeWalletOpen(true)}
>
<Settings2Icon className="size-4 text-muted-foreground" />
Change Project Wallet
</DropdownMenuItem>
)}
</DropdownMenuContent>
</DropdownMenu>
</div>

<div className="p-5 border-t border-dashed flex flex-col gap-4 sm:flex-row sm:justify-between sm:items-center">
Expand Down Expand Up @@ -280,10 +337,10 @@ export function ProjectWalletDetailsSection(props: ProjectWalletControlsProps) {
</div>
</div>

<div className="flex flex-col gap-2 sm:flex-row sm:items-center">
<div className="flex flex-col sm:flex-row sm:items-center">
<SingleNetworkSelector
chainId={selectedChainId}
className="w-full sm:w-fit rounded-full bg-background hover:bg-accent/50"
className="w-full sm:w-fit rounded-full bg-background hover:bg-accent/50 border-r-0 rounded-r-none"
client={props.client}
disableDeprecated
disableChainId
Expand All @@ -302,76 +359,16 @@ export function ProjectWalletDetailsSection(props: ProjectWalletControlsProps) {
chainId={selectedChainId}
client={props.client}
enabled={true}
disableAddress={true}
showCheck={true}
addNativeTokenIfMissing={true}
placeholder="Native token"
className="w-full sm:w-fit rounded-full bg-background hover:bg-accent/50"
className="w-full sm:w-fit rounded-full bg-background hover:bg-accent/50 rounded-l-none"
popoverContentClassName="!w-[320px] rounded-xl overflow-hidden"
align="end"
/>
</div>
</div>

<div className="p-4 border-t border-border flex justify-end gap-2">
<Button
variant="outline"
size="sm"
className="gap-2 bg-background hover:bg-accent/50"
onClick={() => setIsSendOpen(true)}
>
<SendIcon className="size-4" />
Withdraw
</Button>
<Button
variant="outline"
size="sm"
className="gap-2 bg-background hover:bg-accent/50"
onClick={() => setIsSwapOpen(true)}
>
<ArrowLeftRightIcon className="size-4" />
Swap
</Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="outline"
size="sm"
className="px-2 bg-background hover:bg-accent/50"
>
<EllipsisVerticalIcon className="size-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-48">
<DropdownMenuItem
className="flex items-center gap-2"
onSelect={() => setIsReceiveOpen(true)}
>
<WalletIcon className="size-4 text-muted-foreground" />
Deposit
</DropdownMenuItem>
<DropdownMenuItem
className="flex items-center gap-2"
onSelect={() =>
router.push(
`/team/${props.teamSlug}/${props.project.slug}/transactions`,
)
}
>
<ArrowLeftRightIcon className="size-4 text-muted-foreground" />
Transactions
</DropdownMenuItem>
{canChangeWallet && (
<DropdownMenuItem
className="flex items-center gap-2"
onSelect={() => setIsChangeWalletOpen(true)}
>
<ShuffleIcon className="size-4 text-muted-foreground" />
Change Wallet
</DropdownMenuItem>
)}
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>

<SendProjectWalletModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { storybookThirdwebClient } from "@/storybook/utils";
import { ProjectWalletSectionUI } from "./project-wallet";

const meta = {
component: ProjectWalletSectionUI,
component: Variant,
title: "Project/ProjectWalletSection",
parameters: {
nextjs: {
Expand Down Expand Up @@ -35,16 +35,16 @@ projectWithManagedAccessToken.services = [

const projectWithoutManagedAccessToken = projectStub("foo", "bar");

const projectWallet1: ProjectWalletSummary = {
const serverWallet1: ProjectWalletSummary = {
id: "server-wallet-id",
address: "0x1F846F6DAE38E1C88D71EAA191760B15f38B7A37",
label: "Project Wallet 1",
label: "XYZ",
};

const projectWallet2: ProjectWalletSummary = {
const serverWallet2: ProjectWalletSummary = {
id: "server-wallet-id-2",
address: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425",
label: "Project Wallet 2",
label: "FooBar",
};

export const NoProjectWalletSetNoManagedAccessToken: Story = {
Expand Down Expand Up @@ -84,7 +84,7 @@ export const NoProjectWalletSetWithManagedAccessTokenAndServerWallets: Story = {
projectWallet: undefined,
getProjectServerWallets: async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));
return [projectWallet1, projectWallet2];
return [serverWallet1, serverWallet2];
},
},
};
Expand All @@ -98,7 +98,7 @@ export const NoProjectWalletSetLoading: Story = {
projectWallet: undefined,
getProjectServerWallets: async () => {
await new Promise((resolve) => setTimeout(resolve, 100000));
return [projectWallet1, projectWallet2];
return [serverWallet1, serverWallet2];
},
},
};
Expand All @@ -109,10 +109,10 @@ export const ProjectWalletSetMultipleServerWallets: Story = {
project: projectWithManagedAccessToken,
teamSlug: "bar",
client: storybookThirdwebClient,
projectWallet: projectWallet1,
projectWallet: serverWallet1,
getProjectServerWallets: async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));
return [projectWallet1, projectWallet2];
return [serverWallet1, serverWallet2];
},
},
};
Expand All @@ -122,11 +122,23 @@ export const ProjectWalletSetSingleServerWallet: Story = {
layout: "column",
project: projectWithManagedAccessToken,
teamSlug: "bar",
projectWallet: projectWallet1,
projectWallet: serverWallet1,
client: storybookThirdwebClient,
getProjectServerWallets: async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));
return [projectWallet1];
return [serverWallet1];
},
},
};

function Variant(props: Parameters<typeof ProjectWalletSectionUI>[0]) {
return (
<div className="space-y-20">
<ProjectWalletSectionUI {...props} />

<div className="max-w-[660px]">
<ProjectWalletSectionUI {...props} />
</div>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { UnderlineLink } from "@workspace/ui/components/UnderlineLink";
import { ArrowUpRightIcon, ChevronDownIcon, XIcon } from "lucide-react";
import { ArrowUpRightIcon, ChevronDownIcon } from "lucide-react";
import Link from "next/link";
import { useMemo, useState } from "react";
import { toast } from "sonner";
Expand Down Expand Up @@ -134,11 +134,8 @@ function CreateProjectWalletSection(props: {

return (
<div className="rounded-xl border p-5 bg-card">
<div className="rounded-full p-2 border bg-background inline-flex mb-4">
<XIcon className="size-4 text-muted-foreground" />
</div>
<h2 className="text-base font-medium text-foreground mb-0.5">
No Project Wallet set
<h2 className="text-sm font-medium text-foreground mb-0.5 text-yellow-700 dark:text-yellow-500">
No project wallet set
</h2>
<p className="text-sm text-muted-foreground">
Set a project wallet to set the default sender in thirdweb API.
Expand Down
Loading