Skip to content

Commit 4b5b136

Browse files
committed
feat: add clear history functionality and confirmation dialog
1 parent e998a06 commit 4b5b136

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

components/history/history.component.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import React, { useEffect, useRef, useState } from 'react'
44

5-
import { useTariAccountStore, setDetailedTx } from '@/store/account'
5+
import { useTariAccountStore, setDetailedTx, clearBridgeHistory } from '@/store/account'
66

77
import { useTranslation } from 'react-i18next'
88
import { BridgeHistoryListItem } from '../transactions/BridgeListItem'
@@ -51,7 +51,21 @@ export const TransactionHistory = () => {
5151
<div className="flex flex-wrap items-center justify-between gap-4">
5252
<div className="w-full flex flex-col p-1">
5353
<div className="relative">
54-
<div className="flex items-center justify-center"></div>
54+
<div className="flex items-center justify-between">
55+
<h3 className="text-lg font-bold">Transaction History</h3>
56+
{bridgeTxs && bridgeTxs.length > 0 && (
57+
<button
58+
onClick={() => {
59+
if (window.confirm(t('clear_history_confirmation'))) {
60+
clearBridgeHistory();
61+
}
62+
}}
63+
className="text-sm text-blue-500 hover:text-blue-700"
64+
>
65+
{t('clear_all')}
66+
</button>
67+
)}
68+
</div>
5569
<HistoryListWrapper ref={targetRef}>
5670
<ListWrapper>{bridgeTxs && bridgeTxs.length > 0 ? listMarkup : emptyState}</ListWrapper>
5771
</HistoryListWrapper>

store/account.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,11 @@ export const setDetailedTx = (detailedTx: CombinedBridgeTransaction | null) =>
113113
useTariAccountStore.setState({
114114
detailedTx: detailedTx,
115115
})
116+
117+
export const clearBridgeHistory = () => {
118+
useTariAccountStore.setState({
119+
backendBridgeTxs: [],
120+
backendUnwrapTxs: [],
121+
combinedBridgeTxs: [],
122+
})
123+
}

0 commit comments

Comments
 (0)