Skip to content

Commit a52c43d

Browse files
committed
feat: enhance account layout with wallet connection prompt and improved error handling
1 parent 3613389 commit a52c43d

File tree

1 file changed

+47
-25
lines changed

1 file changed

+47
-25
lines changed

src/routes/$chainSlug/_layout/account.tsx

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { useQuery } from '@tanstack/react-query';
55
import { createFileRoute } from '@tanstack/react-router';
66
import { LogOut } from 'lucide-react';
77
import React from 'react';
8+
import { ChainLink } from '@/components/ChainLink';
89
import avatarStyles from '@/components/navbar/profile.module.css';
10+
import { Button } from '@/components/ui/button';
911
import { useLoginLogout } from '@/hooks/useLoginLogout';
1012
import { useTabParam } from '@/hooks/usePageParam';
1113
import { ErrorAlert } from '@/modules/ErrorAlert';
@@ -25,7 +27,7 @@ export const Route = createFileRoute('/$chainSlug/_layout/account')({
2527
});
2628

2729
function RouteComponent() {
28-
const { logout } = useLoginLogout();
30+
const { logout, login } = useLoginLogout();
2931
const { address: userAddress, chainId } = useUserStore();
3032

3133
// Nested wallet activity panel uses address tabs
@@ -87,7 +89,20 @@ function RouteComponent() {
8789
);
8890

8991
if (!userAddress) {
90-
return <ErrorAlert message="Connect wallet to view activity." />;
92+
return (
93+
<div className="mt-20 flex flex-col items-center justify-center gap-6 text-center">
94+
<h1 className="text-2xl font-bold">You are not connected</h1>
95+
<p className="text-muted-foreground max-w-sm">
96+
To access the iExec Wallet Manager, please connect your wallet.
97+
</p>
98+
<div className="flex gap-4">
99+
<Button variant="outline">
100+
<ChainLink to="/">Go back home</ChainLink>
101+
</Button>
102+
<Button onClick={login}>Connect wallet</Button>
103+
</div>
104+
</div>
105+
);
91106
}
92107
if (isError && error && !account) {
93108
return <ErrorAlert message="No data found for this address." />;
@@ -120,23 +135,28 @@ function RouteComponent() {
120135
label: <>iExec Account</>,
121136
component: ManageIexecAccount,
122137
},
138+
123139
{
124140
titleText: 'Wallet Activity',
125141
label: <>Wallet Activity</>,
126142
component: WalletActivityPanel,
127143
},
128-
{
129-
titleText: 'Log out',
130-
label: (
131-
<>
132-
<span className="hidden sm:inline">Log out</span>
133-
<span className="inline-block">
134-
<LogOut size={20} />
135-
</span>
136-
</>
137-
),
138-
action: logout,
139-
},
144+
...(userAddress
145+
? [
146+
{
147+
titleText: 'Log out',
148+
label: (
149+
<>
150+
<span className="hidden sm:inline">Log out</span>
151+
<span className="inline-block">
152+
<LogOut size={20} />
153+
</span>
154+
</>
155+
),
156+
action: logout,
157+
},
158+
]
159+
: []),
140160
];
141161

142162
const tabLabels = tabs.map((tab) => tab.titleText);
@@ -154,17 +174,19 @@ function RouteComponent() {
154174
return (
155175
<div className="mt-8 grid gap-4 md:flex md:gap-10 lg:gap-20">
156176
<div className="top-4 h-fit space-y-4 self-start overflow-x-auto rounded-2xl border px-3 py-4 md:sticky md:top-8 md:max-w-56 md:px-6 md:py-8">
157-
<div className="sticky left-0 inline-flex items-center gap-1">
158-
<div
159-
className={cn(
160-
avatarStyles[avatarVisualBg],
161-
'bg-background relative z-10 size-5 rounded-full bg-cover'
162-
)}
163-
/>
164-
<span className="text-primary text-md">
165-
{truncateAddress(userAddress)}
166-
</span>
167-
</div>
177+
{userAddress && (
178+
<div className="sticky left-0 inline-flex items-center gap-1">
179+
<div
180+
className={cn(
181+
avatarStyles[avatarVisualBg],
182+
'bg-background relative z-10 size-5 rounded-full bg-cover'
183+
)}
184+
/>
185+
<span className="text-primary text-md">
186+
{truncateAddress(userAddress)}
187+
</span>
188+
</div>
189+
)}
168190
<div className="flex justify-between gap-2 md:flex-col md:gap-4">
169191
{tabs.map((tab, index) => (
170192
<button

0 commit comments

Comments
 (0)