Skip to content

Commit 497be29

Browse files
committed
feat: add BackButton component and integrate into various routes for improved navigation.
1 parent 070a2a1 commit 497be29

File tree

14 files changed

+87
-13
lines changed

14 files changed

+87
-13
lines changed

src/components/ui/BackButton.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { useRouter, useCanGoBack } from '@tanstack/react-router';
2+
import { ChevronLeft } from 'lucide-react';
3+
import { Button } from './button';
4+
5+
export function BackButton({ className = '' }: { className?: string }) {
6+
const router = useRouter();
7+
const canGoBack = useCanGoBack();
8+
9+
if (!canGoBack) return null;
10+
11+
return (
12+
<Button
13+
variant="outline"
14+
size="sm"
15+
className={`text-grey-400 border-grey-300 pr-4! uppercase ${className}`}
16+
onClick={() => router.history.back()}
17+
>
18+
<ChevronLeft />
19+
Back
20+
</Button>
21+
);
22+
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Stepper } from '@/components/Stepper';
1010
import IexecAccountIcon from '@/components/icons/IexecAccountIcon';
1111
import WalletIcon from '@/components/icons/WalletIcon';
1212
import { ChainSelector } from '@/components/navbar/ChainSelector';
13+
import { BackButton } from '@/components/ui/BackButton';
1314
import { Button } from '@/components/ui/button';
1415
import { getIExec } from '@/externals/iexecSdkClient';
1516
import { useLoginLogout } from '@/hooks/useLoginLogout';
@@ -184,7 +185,10 @@ function RouteComponent() {
184185

185186
return (
186187
<div className="mt-8 flex flex-col gap-10">
187-
<AccountBreadcrumbs />
188+
<div className="flex items-center gap-2">
189+
<BackButton />
190+
<AccountBreadcrumbs />
191+
</div>
188192
<div className="flex flex-col items-center gap-2">
189193
<h1 className="flex items-center gap-2 text-2xl font-extrabold">
190194
IExec Wallet Manager

src/routes/$chainSlug/_layout/address/$addressAddress.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createFileRoute } from '@tanstack/react-router';
55
import { LoaderCircle } from 'lucide-react';
66
import { useState } from 'react';
77
import AddressIcon from '@/components/icons/AddressIcon';
8+
import { BackButton } from '@/components/ui/BackButton';
89
import { DetailsTable } from '@/modules/DetailsTable';
910
import { ErrorAlert } from '@/modules/ErrorAlert';
1011
import { Tabs } from '@/modules/Tabs';
@@ -132,7 +133,10 @@ function AddressRoute() {
132133
<LoaderCircle className="animate-spin" />
133134
)}
134135
</h1>
135-
<AddressBreadcrumbs addressId={addressAddress} />
136+
<div className="flex items-center gap-2">
137+
<BackButton />
138+
<AddressBreadcrumbs addressId={addressAddress} />
139+
</div>
136140
</div>
137141

138142
{hasPastError && !addressOverview ? (

src/routes/$chainSlug/_layout/app/$appAddress.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useQuery } from '@tanstack/react-query';
44
import { createFileRoute } from '@tanstack/react-router';
55
import { LoaderCircle } from 'lucide-react';
66
import AppIcon from '@/components/icons/AppIcon';
7+
import { BackButton } from '@/components/ui/BackButton';
78
import { DetailsTable } from '@/modules/DetailsTable';
89
import { ErrorAlert } from '@/modules/ErrorAlert';
910
import { AppBreadcrumbs } from '@/modules/apps/app/AppBreadcrumbs';
@@ -92,7 +93,10 @@ function AppsRoute() {
9293
<LoaderCircle className="animate-spin" />
9394
)}
9495
</h1>
95-
<AppBreadcrumbs appId={appAddress} />
96+
<div className="flex items-center gap-2">
97+
<BackButton />
98+
<AppBreadcrumbs appId={appAddress} />
99+
</div>
96100
</div>
97101

98102
<div className="space-y-10">

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { LoaderCircle } from 'lucide-react';
66
import { DataTable } from '@/components/DataTable';
77
import { PaginatedNavigation } from '@/components/PaginatedNavigation';
88
import AppIcon from '@/components/icons/AppIcon';
9+
import { BackButton } from '@/components/ui/BackButton';
910
import { usePageParam } from '@/hooks/usePageParam';
1011
import { ErrorAlert } from '@/modules/ErrorAlert';
1112
import { AppBreadcrumbsList } from '@/modules/apps/AppBreadcrumbs';
@@ -94,7 +95,10 @@ function AppsRoute() {
9495
<LoaderCircle className="animate-spin" />
9596
)}
9697
</h1>
97-
<AppBreadcrumbsList />
98+
<div className="flex items-center gap-2">
99+
<BackButton />
100+
<AppBreadcrumbsList />
101+
</div>
98102
</div>
99103

100104
{hasPastError && !data.length ? (

src/routes/$chainSlug/_layout/dataset/$datasetAddress.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useQuery } from '@tanstack/react-query';
44
import { createFileRoute } from '@tanstack/react-router';
55
import { LoaderCircle } from 'lucide-react';
66
import DatasetIcon from '@/components/icons/DatasetIcon';
7+
import { BackButton } from '@/components/ui/BackButton';
78
import { DetailsTable } from '@/modules/DetailsTable';
89
import { ErrorAlert } from '@/modules/ErrorAlert';
910
import { DatasetBreadcrumbs } from '@/modules/datasets/dataset/DatasetBreadcrumbs';
@@ -95,7 +96,10 @@ function DatasetsRoute() {
9596
<LoaderCircle className="animate-spin" />
9697
)}
9798
</h1>
98-
<DatasetBreadcrumbs datasetId={datasetAddress} />
99+
<div className="flex items-center gap-2">
100+
<BackButton />
101+
<DatasetBreadcrumbs datasetId={datasetAddress} />
102+
</div>
99103
</div>
100104

101105
<div className="space-y-10">

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { LoaderCircle } from 'lucide-react';
66
import { DataTable } from '@/components/DataTable';
77
import { PaginatedNavigation } from '@/components/PaginatedNavigation';
88
import DatasetIcon from '@/components/icons/DatasetIcon';
9+
import { BackButton } from '@/components/ui/BackButton';
910
import { usePageParam } from '@/hooks/usePageParam';
1011
import { ErrorAlert } from '@/modules/ErrorAlert';
1112
import { DatasetBreadcrumbsList } from '@/modules/datasets/DatasetBreadcrumbs';
@@ -94,7 +95,10 @@ function DatasetsRoute() {
9495
<LoaderCircle className="animate-spin" />
9596
)}
9697
</h1>
97-
<DatasetBreadcrumbsList />
98+
<div className="flex items-center gap-2">
99+
<BackButton />
100+
<DatasetBreadcrumbsList />
101+
</div>
98102
</div>
99103

100104
{hasPastError && !data.length ? (

src/routes/$chainSlug/_layout/deal/$dealAddress.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createFileRoute } from '@tanstack/react-router';
55
import { LoaderCircle } from 'lucide-react';
66
import { useState } from 'react';
77
import DealIcon from '@/components/icons/DealIcon';
8+
import { BackButton } from '@/components/ui/BackButton';
89
import { DetailsTable } from '@/modules/DetailsTable';
910
import { ErrorAlert } from '@/modules/ErrorAlert';
1011
import { Tabs } from '@/modules/Tabs';
@@ -97,7 +98,10 @@ function DealsRoute() {
9798
<LoaderCircle className="animate-spin" />
9899
)}
99100
</h1>
100-
<DealBreadcrumbs dealId={dealAddress} />
101+
<div className="flex items-center gap-2">
102+
<BackButton />
103+
<DealBreadcrumbs dealId={dealAddress} />
104+
</div>
101105
</div>
102106

103107
<Tabs

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { LoaderCircle } from 'lucide-react';
66
import { DataTable } from '@/components/DataTable';
77
import { PaginatedNavigation } from '@/components/PaginatedNavigation';
88
import DealIcon from '@/components/icons/DealIcon';
9+
import { BackButton } from '@/components/ui/BackButton';
910
import { usePageParam } from '@/hooks/usePageParam';
1011
import { ErrorAlert } from '@/modules/ErrorAlert';
1112
import { AllDealsBreadcrumbs } from '@/modules/deals/DealBreadcrumbs';
@@ -94,7 +95,10 @@ function DealsRoute() {
9495
<LoaderCircle className="animate-spin" />
9596
)}
9697
</h1>
97-
<AllDealsBreadcrumbs />
98+
<div className="flex items-center gap-2">
99+
<BackButton />
100+
<AllDealsBreadcrumbs />
101+
</div>
98102
</div>
99103
{hasPastError && !data.length ? (
100104
<ErrorAlert message="An error occurred during deals loading." />

src/routes/$chainSlug/_layout/task/$taskAddress.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useQuery } from '@tanstack/react-query';
44
import { createFileRoute } from '@tanstack/react-router';
55
import { LoaderCircle } from 'lucide-react';
66
import TaskIcon from '@/components/icons/TaskIcon';
7+
import { BackButton } from '@/components/ui/BackButton';
78
import { DetailsTable } from '@/modules/DetailsTable';
89
import { ErrorAlert } from '@/modules/ErrorAlert';
910
import { SearcherBar } from '@/modules/search/SearcherBar';
@@ -91,7 +92,10 @@ function TasksRoute() {
9192
<LoaderCircle className="animate-spin" />
9293
)}
9394
</h1>
94-
<TaskBreadcrumbs taskId={taskAddress} />
95+
<div className="flex items-center gap-2">
96+
<BackButton />
97+
<TaskBreadcrumbs taskId={taskAddress} />
98+
</div>
9599
</div>
96100

97101
{hasPastError && !taskDetails ? (

0 commit comments

Comments
 (0)