mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-06-14 02:11:00 +00:00
Standardize loading states across all components
Replaced custom loading spinners with standardized LoadingState component from AsyncComponent.tsx. This ensures consistent UX for all data-loading operations. Changes: - web/src/components/staking/StakingDashboard.tsx: LoadingState for staking data - web/src/components/governance/GovernanceOverview.tsx: LoadingState for governance data - web/src/components/governance/ProposalsList.tsx: LoadingState for proposals - web/src/components/dex/PoolBrowser.tsx: LoadingState for liquidity pools - web/src/components/delegation/DelegationManager.tsx: LoadingState for delegation data - web/src/components/forum/ForumOverview.tsx: LoadingState for forum threads - web/src/components/treasury/TreasuryOverview.tsx: LoadingState for treasury data All components now show: - Kurdistan green animated spinner (Loader2) - Contextual loading messages - Consistent padding and centering - Professional appearance Button loading states (auth, wallet modals) left as-is since they appropriately disable during actions.
This commit is contained in:
@@ -13,6 +13,7 @@ import DelegateProfile from './DelegateProfile';
|
|||||||
import { useDelegation } from '@/hooks/useDelegation';
|
import { useDelegation } from '@/hooks/useDelegation';
|
||||||
import { usePolkadot } from '@/contexts/PolkadotContext';
|
import { usePolkadot } from '@/contexts/PolkadotContext';
|
||||||
import { formatNumber } from '@/lib/utils';
|
import { formatNumber } from '@/lib/utils';
|
||||||
|
import { LoadingState } from '@pezkuwi/components/AsyncComponent';
|
||||||
|
|
||||||
const DelegationManager: React.FC = () => {
|
const DelegationManager: React.FC = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -37,14 +38,7 @@ const DelegationManager: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return <LoadingState message="Loading delegation data from blockchain..." />;
|
||||||
<div className="container mx-auto px-4 py-8 max-w-7xl">
|
|
||||||
<div className="flex items-center justify-center py-12">
|
|
||||||
<Loader2 className="h-8 w-8 animate-spin text-green-600 mr-3" />
|
|
||||||
<span className="text-lg">Loading delegation data from blockchain...</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { TrendingUp, Droplet, BarChart3, Search, Plus } from 'lucide-react';
|
|||||||
import { PoolInfo } from '@/types/dex';
|
import { PoolInfo } from '@/types/dex';
|
||||||
import { fetchPools, formatTokenBalance } from '@pezkuwi/utils/dex';
|
import { fetchPools, formatTokenBalance } from '@pezkuwi/utils/dex';
|
||||||
import { isFounderWallet } from '@pezkuwi/utils/auth';
|
import { isFounderWallet } from '@pezkuwi/utils/auth';
|
||||||
|
import { LoadingState } from '@pezkuwi/components/AsyncComponent';
|
||||||
|
|
||||||
interface PoolBrowserProps {
|
interface PoolBrowserProps {
|
||||||
onAddLiquidity?: (pool: PoolInfo) => void;
|
onAddLiquidity?: (pool: PoolInfo) => void;
|
||||||
@@ -63,11 +64,7 @@ export const PoolBrowser: React.FC<PoolBrowserProps> = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (loading && pools.length === 0) {
|
if (loading && pools.length === 0) {
|
||||||
return (
|
return <LoadingState message="Loading liquidity pools..." />;
|
||||||
<div className="flex items-center justify-center py-12">
|
|
||||||
<div className="text-gray-400">Loading pools...</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { Badge } from '@/components/ui/badge';
|
|||||||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
|
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||||
|
import { LoadingState } from '@pezkuwi/components/AsyncComponent';
|
||||||
import {
|
import {
|
||||||
MessageSquare,
|
MessageSquare,
|
||||||
Users,
|
Users,
|
||||||
@@ -105,12 +106,7 @@ export function ForumOverview() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return <LoadingState message="Loading forum..." />;
|
||||||
<div className="flex items-center justify-center py-12">
|
|
||||||
<Loader2 className="h-8 w-8 animate-spin text-primary" />
|
|
||||||
<span className="ml-3 text-muted-foreground">Loading forum...</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { Badge } from '../ui/badge';
|
|||||||
import { Progress } from '../ui/progress';
|
import { Progress } from '../ui/progress';
|
||||||
import { usePolkadot } from '../../contexts/PolkadotContext';
|
import { usePolkadot } from '../../contexts/PolkadotContext';
|
||||||
import { formatBalance } from '@pezkuwi/lib/wallet';
|
import { formatBalance } from '@pezkuwi/lib/wallet';
|
||||||
|
import { LoadingState } from '@pezkuwi/components/AsyncComponent';
|
||||||
|
|
||||||
interface GovernanceStats {
|
interface GovernanceStats {
|
||||||
activeProposals: number;
|
activeProposals: number;
|
||||||
@@ -123,6 +124,10 @@ const GovernanceOverview: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return <LoadingState message="Loading governance data..." />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
{/* Stats Grid */}
|
{/* Stats Grid */}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Progress } from '../ui/progress';
|
|||||||
import { Alert, AlertDescription } from '../ui/alert';
|
import { Alert, AlertDescription } from '../ui/alert';
|
||||||
import { useGovernance } from '@/hooks/useGovernance';
|
import { useGovernance } from '@/hooks/useGovernance';
|
||||||
import { formatNumber } from '@/lib/utils';
|
import { formatNumber } from '@/lib/utils';
|
||||||
|
import { LoadingState } from '@pezkuwi/components/AsyncComponent';
|
||||||
|
|
||||||
interface Proposal {
|
interface Proposal {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -84,12 +85,7 @@ const ProposalsList: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return <LoadingState message="Loading proposals from blockchain..." />;
|
||||||
<div className="flex items-center justify-center py-12">
|
|
||||||
<Loader2 className="h-8 w-8 animate-spin text-primary mr-3" />
|
|
||||||
<span className="text-muted-foreground">Loading proposals from blockchain...</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
parseAmount,
|
parseAmount,
|
||||||
type StakingInfo
|
type StakingInfo
|
||||||
} from '@pezkuwi/lib/staking';
|
} from '@pezkuwi/lib/staking';
|
||||||
|
import { LoadingState } from '@pezkuwi/components/AsyncComponent';
|
||||||
|
|
||||||
export const StakingDashboard: React.FC = () => {
|
export const StakingDashboard: React.FC = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -421,11 +422,7 @@ export const StakingDashboard: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (isLoadingData) {
|
if (isLoadingData) {
|
||||||
return (
|
return <LoadingState message="Loading staking data..." />;
|
||||||
<div className="flex items-center justify-center h-64">
|
|
||||||
<div className="text-gray-400">Loading staking data...</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
ArrowDownRight,
|
ArrowDownRight,
|
||||||
Loader2
|
Loader2
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
|
import { LoadingState } from '@pezkuwi/components/AsyncComponent';
|
||||||
|
|
||||||
interface TreasuryMetrics {
|
interface TreasuryMetrics {
|
||||||
totalBalance: number;
|
totalBalance: number;
|
||||||
@@ -63,12 +64,7 @@ export const TreasuryOverview: React.FC = () => {
|
|||||||
const HealthIcon = healthStatus.icon;
|
const HealthIcon = healthStatus.icon;
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return <LoadingState message="Loading treasury data from blockchain..." />;
|
||||||
<div className="flex items-center justify-center py-12">
|
|
||||||
<Loader2 className="h-8 w-8 animate-spin text-primary" />
|
|
||||||
<span className="ml-3 text-muted-foreground">Loading treasury data from blockchain...</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user