feat: implement loading indicators in transactions page and loading component for improved user feedback during data fetching
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
import { RefreshCw } from "lucide-react";
|
||||||
|
|
||||||
export default function Loading() {
|
export default function Loading() {
|
||||||
return null;
|
return (
|
||||||
|
<div className="flex h-screen bg-background">
|
||||||
|
<main className="flex-1 flex items-center justify-center">
|
||||||
|
<RefreshCw className="w-8 h-8 animate-spin text-muted-foreground" />
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
import { useState, useMemo, useEffect, useCallback } from "react";
|
import { useState, useMemo, useEffect, useCallback } from "react";
|
||||||
import { useSearchParams } from "next/navigation";
|
import { useSearchParams } from "next/navigation";
|
||||||
import { PageLayout, LoadingState, PageHeader } from "@/components/layout";
|
import { PageLayout, PageHeader } from "@/components/layout";
|
||||||
|
import { RefreshCw } from "lucide-react";
|
||||||
import {
|
import {
|
||||||
TransactionFilters,
|
TransactionFilters,
|
||||||
TransactionBulkActions,
|
TransactionBulkActions,
|
||||||
@@ -252,10 +253,6 @@ export default function TransactionsPage() {
|
|||||||
queryClient.invalidateQueries({ queryKey: ["banking-metadata"] });
|
queryClient.invalidateQueries({ queryKey: ["banking-metadata"] });
|
||||||
}, [invalidateTransactions, queryClient]);
|
}, [invalidateTransactions, queryClient]);
|
||||||
|
|
||||||
if (isLoadingMetadata || !metadata) {
|
|
||||||
return <LoadingState />;
|
|
||||||
}
|
|
||||||
|
|
||||||
const formatCurrency = (amount: number) => {
|
const formatCurrency = (amount: number) => {
|
||||||
return new Intl.NumberFormat("fr-FR", {
|
return new Intl.NumberFormat("fr-FR", {
|
||||||
style: "currency",
|
style: "currency",
|
||||||
@@ -530,6 +527,17 @@ export default function TransactionsPage() {
|
|||||||
const totalTransactions = transactionsData?.total || 0;
|
const totalTransactions = transactionsData?.total || 0;
|
||||||
const hasMore = transactionsData?.hasMore || false;
|
const hasMore = transactionsData?.hasMore || false;
|
||||||
|
|
||||||
|
// Early return for loading state - prevents sidebar flash
|
||||||
|
if (isLoadingMetadata || !metadata) {
|
||||||
|
return (
|
||||||
|
<div className="flex h-screen bg-background">
|
||||||
|
<main className="flex-1 flex items-center justify-center">
|
||||||
|
<RefreshCw className="w-8 h-8 animate-spin text-muted-foreground" />
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageLayout>
|
<PageLayout>
|
||||||
<PageHeader
|
<PageHeader
|
||||||
@@ -600,7 +608,9 @@ export default function TransactionsPage() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{isLoadingTransactions ? (
|
{isLoadingTransactions ? (
|
||||||
<LoadingState />
|
<div className="flex items-center justify-center py-12">
|
||||||
|
<RefreshCw className="w-8 h-8 animate-spin text-muted-foreground" />
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<TransactionTable
|
<TransactionTable
|
||||||
|
|||||||
Reference in New Issue
Block a user