Skip to content

Commit 472f7fd

Browse files
committed
Adds Loader on Filter change
1 parent be3fceb commit 472f7fd

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

packages/transaction-log/src/components/common/app.main.component.tsx

+24-9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {useAlert} from '../../contexts/alert.context'
3333
import {useBasicBackdrop} from '../../contexts/backdrop.context'
3434
import Loader from '../helpers/loader.helper.component'
3535
import {useConfirmation} from '../../contexts/confirmation.context'
36+
import { CircularProgress } from '@mui/material'
3637

3738
const App: React.FC = () => {
3839
const NO_FILTER = 'NoFilter'
@@ -61,6 +62,7 @@ const App: React.FC = () => {
6162
const [initialTransactionLoadComplete, setInitialTransactionLoadComplete] =
6263
useState(false)
6364
const [loading, setLoading] = useState(false)
65+
const [filterLoading, setFilterLoading] = useState(false)
6466
const {closeReRunDialog, showReRunDialog} =
6567
useTransactionRerunConfirmationDialog()
6668
const {showAlert, hideAlert} = useAlert()
@@ -145,6 +147,9 @@ const App: React.FC = () => {
145147
const fetchTransactionLogs = useCallback(
146148
async (timestampFilter?: string, filteredResults?: boolean) => {
147149
try {
150+
if (filteredResults) {
151+
setFilterLoading(true)
152+
}
148153
const fetchParams = getFilters(timestampFilter)
149154

150155
setHttpError(null)
@@ -198,6 +203,10 @@ const App: React.FC = () => {
198203
} catch (error) {
199204
console.error('Error fetching logs:', error)
200205
setHttpError(error)
206+
} finally {
207+
if (filteredResults) {
208+
setFilterLoading(false)
209+
}
201210
}
202211
},
203212
[
@@ -617,15 +626,21 @@ const App: React.FC = () => {
617626
<Box sx={{mt: 3}}>
618627
<Card elevation={4}>
619628
<CardContent>
620-
<TransactionLogTable
621-
transactions={filteredTransactions}
622-
loadMore={loadMore}
623-
loading={loading}
624-
initialTransactionLoadComplete={initialTransactionLoadComplete}
625-
onRowClick={handleRowClick}
626-
onSelectedChange={setSelectedTransactions}
627-
onAutoUpdateChange={handleAutoUpdateChange}
628-
/>
629+
{filterLoading ? (
630+
<Box display="flex" justifyContent="center" alignItems="center" p={3}>
631+
<CircularProgress />
632+
</Box>
633+
) : (
634+
<TransactionLogTable
635+
transactions={filteredTransactions}
636+
loadMore={loadMore}
637+
loading={loading}
638+
initialTransactionLoadComplete={initialTransactionLoadComplete}
639+
onRowClick={handleRowClick}
640+
onSelectedChange={setSelectedTransactions}
641+
onAutoUpdateChange={handleAutoUpdateChange}
642+
/>
643+
)}
629644
</CardContent>
630645
</Card>
631646
</Box>

0 commit comments

Comments
 (0)