Skip to content

Commit

Permalink
Merge pull request #712 from ItsMurumba/CU-86c0qdnd9_Filter_Loading_S…
Browse files Browse the repository at this point in the history
…pinner

Cu 86c0qdnd9 filter loading spinner
  • Loading branch information
drizzentic authored Nov 5, 2024
2 parents d77492d + bf9db54 commit 76b4d3f
Showing 1 changed file with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {useAlert} from '../../contexts/alert.context'
import {useBasicBackdrop} from '../../contexts/backdrop.context'
import Loader from '../helpers/loader.helper.component'
import {useConfirmation} from '../../contexts/confirmation.context'
import { CircularProgress } from '@mui/material'

const App: React.FC = () => {
const NO_FILTER = 'NoFilter'
Expand Down Expand Up @@ -61,6 +62,7 @@ const App: React.FC = () => {
const [initialTransactionLoadComplete, setInitialTransactionLoadComplete] =
useState(false)
const [loading, setLoading] = useState(false)
const [filterLoading, setFilterLoading] = useState(false)
const {closeReRunDialog, showReRunDialog} =
useTransactionRerunConfirmationDialog()
const {showAlert, hideAlert} = useAlert()
Expand Down Expand Up @@ -145,6 +147,9 @@ const App: React.FC = () => {
const fetchTransactionLogs = useCallback(
async (timestampFilter?: string, filteredResults?: boolean) => {
try {
if (filteredResults) {
setFilterLoading(true)
}
const fetchParams = getFilters(timestampFilter)

setHttpError(null)
Expand Down Expand Up @@ -198,6 +203,10 @@ const App: React.FC = () => {
} catch (error) {
console.error('Error fetching logs:', error)
setHttpError(error)
} finally {
if (filteredResults) {
setFilterLoading(false)
}
}
},
[
Expand Down Expand Up @@ -617,15 +626,21 @@ const App: React.FC = () => {
<Box sx={{mt: 3}}>
<Card elevation={4}>
<CardContent>
<TransactionLogTable
transactions={filteredTransactions}
loadMore={loadMore}
loading={loading}
initialTransactionLoadComplete={initialTransactionLoadComplete}
onRowClick={handleRowClick}
onSelectedChange={setSelectedTransactions}
onAutoUpdateChange={handleAutoUpdateChange}
/>
{filterLoading ? (
<Box display="flex" justifyContent="center" alignItems="center" p={3}>
<CircularProgress />
</Box>
) : (
<TransactionLogTable
transactions={filteredTransactions}
loadMore={loadMore}
loading={loading}
initialTransactionLoadComplete={initialTransactionLoadComplete}
onRowClick={handleRowClick}
onSelectedChange={setSelectedTransactions}
onAutoUpdateChange={handleAutoUpdateChange}
/>
)}
</CardContent>
</Card>
</Box>
Expand Down

0 comments on commit 76b4d3f

Please sign in to comment.