Reorganize repository into monorepo structure

Restructured the project to support multiple frontend applications:
- Move web app to web/ directory
- Create pezkuwi-sdk-ui/ for Polkadot SDK clone (planned)
- Create mobile/ directory for mobile app development
- Add shared/ directory with common utilities, types, and blockchain code
- Update README.md with comprehensive documentation
- Remove obsolete DKSweb/ directory

This monorepo structure enables better code sharing and organized
development across web, mobile, and SDK UI projects.
This commit is contained in:
Claude
2025-11-14 00:46:35 +00:00
parent d66e46034a
commit 24be8d4411
206 changed files with 502 additions and 4 deletions
@@ -0,0 +1,296 @@
import React, { useState } from 'react';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Textarea } from '@/components/ui/textarea';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
import { Badge } from '@/components/ui/badge';
import { useTranslation } from 'react-i18next';
import {
Plus,
Trash2,
Calculator,
FileText,
Users,
Calendar,
DollarSign,
AlertCircle
} from 'lucide-react';
interface BudgetItem {
id: string;
description: string;
amount: number;
category: string;
justification: string;
}
interface Milestone {
id: string;
title: string;
deliverables: string;
amount: number;
deadline: string;
}
export const FundingProposal: React.FC = () => {
const { t } = useTranslation();
const [proposalTitle, setProposalTitle] = useState('');
const [proposalDescription, setProposalDescription] = useState('');
const [category, setCategory] = useState('');
const [budgetItems, setBudgetItems] = useState<BudgetItem[]>([
{ id: '1', description: '', amount: 0, category: '', justification: '' }
]);
const [milestones, setMilestones] = useState<Milestone[]>([
{ id: '1', title: '', deliverables: '', amount: 0, deadline: '' }
]);
const addBudgetItem = () => {
setBudgetItems([...budgetItems, {
id: Date.now().toString(),
description: '',
amount: 0,
category: '',
justification: ''
}]);
};
const removeBudgetItem = (id: string) => {
setBudgetItems(budgetItems.filter(item => item.id !== id));
};
const updateBudgetItem = (id: string, field: keyof BudgetItem, value: any) => {
setBudgetItems(budgetItems.map(item =>
item.id === id ? { ...item, [field]: value } : item
));
};
const addMilestone = () => {
setMilestones([...milestones, {
id: Date.now().toString(),
title: '',
deliverables: '',
amount: 0,
deadline: ''
}]);
};
const removeMilestone = (id: string) => {
setMilestones(milestones.filter(m => m.id !== id));
};
const updateMilestone = (id: string, field: keyof Milestone, value: any) => {
setMilestones(milestones.map(m =>
m.id === id ? { ...m, [field]: value } : m
));
};
const totalBudget = budgetItems.reduce((sum, item) => sum + (item.amount || 0), 0);
const totalMilestoneAmount = milestones.reduce((sum, m) => sum + (m.amount || 0), 0);
return (
<div className="space-y-6">
{/* Proposal Header */}
<Card>
<CardHeader>
<CardTitle>Create Funding Proposal</CardTitle>
<CardDescription>Submit a detailed budget request for treasury funding</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
<div className="space-y-2">
<Label htmlFor="title">Proposal Title</Label>
<Input
id="title"
placeholder="Enter a clear, descriptive title"
value={proposalTitle}
onChange={(e) => setProposalTitle(e.target.value)}
/>
</div>
<div className="space-y-2">
<Label htmlFor="category">Category</Label>
<Select value={category} onValueChange={setCategory}>
<SelectTrigger>
<SelectValue placeholder="Select category" />
</SelectTrigger>
<SelectContent>
<SelectItem value="development">Development</SelectItem>
<SelectItem value="marketing">Marketing</SelectItem>
<SelectItem value="operations">Operations</SelectItem>
<SelectItem value="community">Community</SelectItem>
<SelectItem value="research">Research</SelectItem>
<SelectItem value="infrastructure">Infrastructure</SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label htmlFor="description">Description</Label>
<Textarea
id="description"
placeholder="Provide a detailed description of the proposal"
rows={4}
value={proposalDescription}
onChange={(e) => setProposalDescription(e.target.value)}
/>
</div>
</CardContent>
</Card>
{/* Budget Items */}
<Card>
<CardHeader>
<CardTitle className="flex items-center justify-between">
<span>Budget Breakdown</span>
<Badge variant="outline" className="text-lg px-3 py-1">
Total: ${totalBudget.toLocaleString()}
</Badge>
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
{budgetItems.map((item, index) => (
<div key={item.id} className="p-4 border rounded-lg space-y-3">
<div className="flex items-center justify-between">
<span className="font-medium">Item {index + 1}</span>
{budgetItems.length > 1 && (
<Button
variant="ghost"
size="sm"
onClick={() => removeBudgetItem(item.id)}
>
<Trash2 className="h-4 w-4" />
</Button>
)}
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
<div className="space-y-2">
<Label>Description</Label>
<Input
placeholder="Budget item description"
value={item.description}
onChange={(e) => updateBudgetItem(item.id, 'description', e.target.value)}
/>
</div>
<div className="space-y-2">
<Label>Amount ($)</Label>
<Input
type="number"
placeholder="0"
value={item.amount || ''}
onChange={(e) => updateBudgetItem(item.id, 'amount', parseFloat(e.target.value) || 0)}
/>
</div>
</div>
<div className="space-y-2">
<Label>Justification</Label>
<Textarea
placeholder="Explain why this expense is necessary"
rows={2}
value={item.justification}
onChange={(e) => updateBudgetItem(item.id, 'justification', e.target.value)}
/>
</div>
</div>
))}
<Button onClick={addBudgetItem} variant="outline" className="w-full">
<Plus className="h-4 w-4 mr-2" />
Add Budget Item
</Button>
</CardContent>
</Card>
{/* Milestones */}
<Card>
<CardHeader>
<CardTitle>Milestones & Deliverables</CardTitle>
<CardDescription>Define clear milestones with payment schedule</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
{milestones.map((milestone, index) => (
<div key={milestone.id} className="p-4 border rounded-lg space-y-3">
<div className="flex items-center justify-between">
<span className="font-medium">Milestone {index + 1}</span>
{milestones.length > 1 && (
<Button
variant="ghost"
size="sm"
onClick={() => removeMilestone(milestone.id)}
>
<Trash2 className="h-4 w-4" />
</Button>
)}
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
<div className="space-y-2">
<Label>Title</Label>
<Input
placeholder="Milestone title"
value={milestone.title}
onChange={(e) => updateMilestone(milestone.id, 'title', e.target.value)}
/>
</div>
<div className="space-y-2">
<Label>Payment Amount ($)</Label>
<Input
type="number"
placeholder="0"
value={milestone.amount || ''}
onChange={(e) => updateMilestone(milestone.id, 'amount', parseFloat(e.target.value) || 0)}
/>
</div>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
<div className="space-y-2">
<Label>Deliverables</Label>
<Textarea
placeholder="What will be delivered"
rows={2}
value={milestone.deliverables}
onChange={(e) => updateMilestone(milestone.id, 'deliverables', e.target.value)}
/>
</div>
<div className="space-y-2">
<Label>Deadline</Label>
<Input
type="date"
value={milestone.deadline}
onChange={(e) => updateMilestone(milestone.id, 'deadline', e.target.value)}
/>
</div>
</div>
</div>
))}
<Button onClick={addMilestone} variant="outline" className="w-full">
<Plus className="h-4 w-4 mr-2" />
Add Milestone
</Button>
{totalMilestoneAmount !== totalBudget && totalMilestoneAmount > 0 && (
<div className="flex items-center gap-2 p-3 bg-yellow-50 dark:bg-yellow-900/20 rounded-lg text-gray-900">
<AlertCircle className="h-5 w-5 text-yellow-600" />
<span className="text-sm text-gray-900">
Milestone total (${totalMilestoneAmount.toLocaleString()}) doesn't match budget total (${totalBudget.toLocaleString()})
</span>
</div>
)}
</CardContent>
</Card>
{/* Submit Button */}
<div className="flex justify-end gap-3">
<Button variant="outline">Save Draft</Button>
<Button>Submit Proposal</Button>
</div>
</div>
);
};
@@ -0,0 +1,278 @@
import React, { useState } from 'react';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { Progress } from '@/components/ui/progress';
import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { useTranslation } from 'react-i18next';
import {
Shield,
CheckCircle,
XCircle,
Clock,
Users,
AlertTriangle,
FileText,
DollarSign
} from 'lucide-react';
interface Approval {
id: string;
proposalTitle: string;
amount: number;
category: string;
requester: string;
description: string;
requiredSignatures: number;
currentSignatures: number;
signers: Array<{
name: string;
status: 'approved' | 'rejected' | 'pending';
timestamp?: string;
comment?: string;
}>;
deadline: string;
status: 'pending' | 'approved' | 'rejected' | 'expired';
}
export const MultiSigApproval: React.FC = () => {
const { t } = useTranslation();
const [activeTab, setActiveTab] = useState('pending');
const [approvals] = useState<Approval[]>([
{
id: '1',
proposalTitle: 'Infrastructure Upgrade - Q1 2024',
amount: 45000,
category: 'Infrastructure',
requester: 'Tech Team',
description: 'Upgrade cloud infrastructure for improved performance',
requiredSignatures: 3,
currentSignatures: 1,
signers: [
{ name: 'Alice', status: 'approved', timestamp: '2024-01-08 14:30', comment: 'Looks good' },
{ name: 'Bob', status: 'pending' },
{ name: 'Charlie', status: 'pending' },
{ name: 'Diana', status: 'pending' }
],
deadline: '2024-01-20',
status: 'pending'
},
{
id: '2',
proposalTitle: 'Developer Grants Program',
amount: 100000,
category: 'Development',
requester: 'Dev Relations',
description: 'Fund developer grants for ecosystem growth',
requiredSignatures: 4,
currentSignatures: 2,
signers: [
{ name: 'Alice', status: 'approved', timestamp: '2024-01-07 10:15' },
{ name: 'Bob', status: 'approved', timestamp: '2024-01-07 11:45' },
{ name: 'Charlie', status: 'pending' },
{ name: 'Diana', status: 'pending' },
{ name: 'Eve', status: 'pending' }
],
deadline: '2024-01-25',
status: 'pending'
}
]);
const pendingApprovals = approvals.filter(a => a.status === 'pending');
const approvedApprovals = approvals.filter(a => a.status === 'approved');
const rejectedApprovals = approvals.filter(a => a.status === 'rejected');
const getStatusIcon = (status: string) => {
switch (status) {
case 'approved':
return <CheckCircle className="h-4 w-4 text-green-500" />;
case 'rejected':
return <XCircle className="h-4 w-4 text-red-500" />;
case 'pending':
return <Clock className="h-4 w-4 text-yellow-500" />;
default:
return null;
}
};
const ApprovalCard = ({ approval }: { approval: Approval }) => {
const progress = (approval.currentSignatures / approval.requiredSignatures) * 100;
return (
<Card>
<CardHeader>
<div className="flex items-start justify-between">
<div>
<CardTitle className="text-lg">{approval.proposalTitle}</CardTitle>
<CardDescription>{approval.description}</CardDescription>
</div>
<Badge variant="outline">{approval.category}</Badge>
</div>
</CardHeader>
<CardContent className="space-y-4">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<DollarSign className="h-4 w-4 text-muted-foreground" />
<span className="font-semibold">${approval.amount.toLocaleString()}</span>
</div>
<div className="flex items-center gap-2 text-sm text-muted-foreground">
<Clock className="h-4 w-4" />
<span>Deadline: {approval.deadline}</span>
</div>
</div>
<div className="space-y-2">
<div className="flex items-center justify-between text-sm">
<span>Approval Progress</span>
<span className="font-medium">
{approval.currentSignatures}/{approval.requiredSignatures} signatures
</span>
</div>
<Progress value={progress} className="h-2" />
</div>
<div className="space-y-2">
<p className="text-sm font-medium">Signers</p>
<div className="flex flex-wrap gap-2">
{approval.signers.map((signer, index) => (
<div key={index} className="flex items-center gap-2">
<Avatar className="h-8 w-8">
<AvatarFallback className="text-xs">
{signer.name[0]}
</AvatarFallback>
</Avatar>
<div className="flex items-center gap-1">
<span className="text-sm">{signer.name}</span>
{getStatusIcon(signer.status)}
</div>
</div>
))}
</div>
</div>
<div className="flex gap-2">
<Button className="flex-1" size="sm">
<CheckCircle className="h-4 w-4 mr-2" />
Approve
</Button>
<Button variant="outline" className="flex-1" size="sm">
<XCircle className="h-4 w-4 mr-2" />
Reject
</Button>
<Button variant="ghost" size="sm">
View Details
</Button>
</div>
</CardContent>
</Card>
);
};
return (
<div className="space-y-6">
{/* Stats Overview */}
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
<Card>
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-muted-foreground">Pending Approvals</p>
<p className="text-2xl font-bold">{pendingApprovals.length}</p>
</div>
<Clock className="h-8 w-8 text-yellow-500" />
</div>
</CardContent>
</Card>
<Card>
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-muted-foreground">Total Value</p>
<p className="text-2xl font-bold">
${(pendingApprovals.reduce((sum, a) => sum + a.amount, 0) / 1000).toFixed(0)}k
</p>
</div>
<DollarSign className="h-8 w-8 text-green-500" />
</div>
</CardContent>
</Card>
<Card>
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-muted-foreground">Active Signers</p>
<p className="text-2xl font-bold">5</p>
</div>
<Users className="h-8 w-8 text-blue-500" />
</div>
</CardContent>
</Card>
<Card>
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-muted-foreground">Expiring Soon</p>
<p className="text-2xl font-bold">2</p>
</div>
<AlertTriangle className="h-8 w-8 text-orange-500" />
</div>
</CardContent>
</Card>
</div>
{/* Approvals Tabs */}
<Tabs value={activeTab} onValueChange={setActiveTab}>
<TabsList className="grid w-full grid-cols-3">
<TabsTrigger value="pending">
Pending ({pendingApprovals.length})
</TabsTrigger>
<TabsTrigger value="approved">
Approved ({approvedApprovals.length})
</TabsTrigger>
<TabsTrigger value="rejected">
Rejected ({rejectedApprovals.length})
</TabsTrigger>
</TabsList>
<TabsContent value="pending" className="space-y-4">
{pendingApprovals.map(approval => (
<ApprovalCard key={approval.id} approval={approval} />
))}
</TabsContent>
<TabsContent value="approved" className="space-y-4">
{approvedApprovals.length === 0 ? (
<Card>
<CardContent className="p-6 text-center text-muted-foreground">
No approved proposals yet
</CardContent>
</Card>
) : (
approvedApprovals.map(approval => (
<ApprovalCard key={approval.id} approval={approval} />
))
)}
</TabsContent>
<TabsContent value="rejected" className="space-y-4">
{rejectedApprovals.length === 0 ? (
<Card>
<CardContent className="p-6 text-center text-muted-foreground">
No rejected proposals
</CardContent>
</Card>
) : (
rejectedApprovals.map(approval => (
<ApprovalCard key={approval.id} approval={approval} />
))
)}
</TabsContent>
</Tabs>
</div>
);
};
@@ -0,0 +1,296 @@
import React, { useState } from 'react';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
import { useTranslation } from 'react-i18next';
import {
Download,
Filter,
Search,
ArrowUpDown,
FileText,
CheckCircle,
XCircle,
Clock,
TrendingUp,
TrendingDown
} from 'lucide-react';
interface Transaction {
id: string;
date: string;
description: string;
category: string;
amount: number;
status: 'completed' | 'pending' | 'rejected';
proposalId: string;
recipient: string;
approvers: string[];
}
export const SpendingHistory: React.FC = () => {
const { t } = useTranslation();
const [searchTerm, setSearchTerm] = useState('');
const [filterCategory, setFilterCategory] = useState('all');
const [filterStatus, setFilterStatus] = useState('all');
const [sortBy, setSortBy] = useState('date');
const [transactions] = useState<Transaction[]>([
{
id: '1',
date: '2024-01-15',
description: 'Q1 Development Team Salaries',
category: 'Development',
amount: 85000,
status: 'completed',
proposalId: 'PROP-001',
recipient: 'Dev Team Multisig',
approvers: ['Alice', 'Bob', 'Charlie']
},
{
id: '2',
date: '2024-01-10',
description: 'Marketing Campaign - Social Media',
category: 'Marketing',
amount: 25000,
status: 'completed',
proposalId: 'PROP-002',
recipient: 'Marketing Agency',
approvers: ['Alice', 'Diana']
},
{
id: '3',
date: '2024-01-08',
description: 'Infrastructure Upgrade - Servers',
category: 'Infrastructure',
amount: 45000,
status: 'pending',
proposalId: 'PROP-003',
recipient: 'Cloud Provider',
approvers: ['Bob']
},
{
id: '4',
date: '2024-01-05',
description: 'Community Hackathon Prizes',
category: 'Community',
amount: 15000,
status: 'completed',
proposalId: 'PROP-004',
recipient: 'Hackathon Winners',
approvers: ['Alice', 'Bob', 'Eve']
},
{
id: '5',
date: '2024-01-03',
description: 'Research Grant - DeFi Protocol',
category: 'Research',
amount: 50000,
status: 'rejected',
proposalId: 'PROP-005',
recipient: 'Research Lab',
approvers: []
}
]);
const getStatusIcon = (status: string) => {
switch (status) {
case 'completed':
return <CheckCircle className="h-4 w-4 text-green-500" />;
case 'pending':
return <Clock className="h-4 w-4 text-yellow-500" />;
case 'rejected':
return <XCircle className="h-4 w-4 text-red-500" />;
default:
return null;
}
};
const getStatusBadge = (status: string) => {
switch (status) {
case 'completed':
return <Badge className="bg-green-100 text-green-800">Completed</Badge>;
case 'pending':
return <Badge className="bg-yellow-100 text-yellow-800">Pending</Badge>;
case 'rejected':
return <Badge className="bg-red-100 text-red-800">Rejected</Badge>;
default:
return <Badge>{status}</Badge>;
}
};
const filteredTransactions = transactions.filter(tx => {
const matchesSearch = tx.description.toLowerCase().includes(searchTerm.toLowerCase()) ||
tx.recipient.toLowerCase().includes(searchTerm.toLowerCase());
const matchesCategory = filterCategory === 'all' || tx.category === filterCategory;
const matchesStatus = filterStatus === 'all' || tx.status === filterStatus;
return matchesSearch && matchesCategory && matchesStatus;
});
const totalSpent = transactions
.filter(tx => tx.status === 'completed')
.reduce((sum, tx) => sum + tx.amount, 0);
const pendingAmount = transactions
.filter(tx => tx.status === 'pending')
.reduce((sum, tx) => sum + tx.amount, 0);
return (
<div className="space-y-6">
{/* Summary Cards */}
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
<Card>
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-muted-foreground">Total Spent (YTD)</p>
<p className="text-2xl font-bold">${(totalSpent / 1000).toFixed(0)}k</p>
</div>
<TrendingUp className="h-8 w-8 text-green-500" />
</div>
</CardContent>
</Card>
<Card>
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-muted-foreground">Pending Approvals</p>
<p className="text-2xl font-bold">${(pendingAmount / 1000).toFixed(0)}k</p>
</div>
<Clock className="h-8 w-8 text-yellow-500" />
</div>
</CardContent>
</Card>
<Card>
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-muted-foreground">Transactions</p>
<p className="text-2xl font-bold">{transactions.length}</p>
</div>
<FileText className="h-8 w-8 text-blue-500" />
</div>
</CardContent>
</Card>
</div>
{/* Filters and Search */}
<Card>
<CardHeader>
<CardTitle>Transaction History</CardTitle>
<CardDescription>View and export treasury spending records</CardDescription>
</CardHeader>
<CardContent>
<div className="flex flex-col md:flex-row gap-4 mb-6">
<div className="flex-1">
<div className="relative">
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
<Input
placeholder="Search transactions..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="pl-10"
/>
</div>
</div>
<Select value={filterCategory} onValueChange={setFilterCategory}>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="Category" />
</SelectTrigger>
<SelectContent>
<SelectItem value="all">All Categories</SelectItem>
<SelectItem value="Development">Development</SelectItem>
<SelectItem value="Marketing">Marketing</SelectItem>
<SelectItem value="Infrastructure">Infrastructure</SelectItem>
<SelectItem value="Community">Community</SelectItem>
<SelectItem value="Research">Research</SelectItem>
</SelectContent>
</Select>
<Select value={filterStatus} onValueChange={setFilterStatus}>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="Status" />
</SelectTrigger>
<SelectContent>
<SelectItem value="all">All Status</SelectItem>
<SelectItem value="completed">Completed</SelectItem>
<SelectItem value="pending">Pending</SelectItem>
<SelectItem value="rejected">Rejected</SelectItem>
</SelectContent>
</Select>
<Button variant="outline">
<Download className="h-4 w-4 mr-2" />
Export CSV
</Button>
</div>
{/* Transactions Table */}
<div className="rounded-md border">
<Table>
<TableHeader>
<TableRow>
<TableHead>Date</TableHead>
<TableHead>Description</TableHead>
<TableHead>Category</TableHead>
<TableHead>Amount</TableHead>
<TableHead>Status</TableHead>
<TableHead>Approvers</TableHead>
<TableHead>Actions</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{filteredTransactions.map((tx) => (
<TableRow key={tx.id}>
<TableCell className="font-medium">{tx.date}</TableCell>
<TableCell>
<div>
<p className="font-medium">{tx.description}</p>
<p className="text-sm text-muted-foreground">{tx.recipient}</p>
</div>
</TableCell>
<TableCell>
<Badge variant="outline">{tx.category}</Badge>
</TableCell>
<TableCell className="font-semibold">
${tx.amount.toLocaleString()}
</TableCell>
<TableCell>{getStatusBadge(tx.status)}</TableCell>
<TableCell>
<div className="flex -space-x-2">
{tx.approvers.slice(0, 3).map((approver, i) => (
<div
key={i}
className="h-8 w-8 rounded-full bg-primary/10 border-2 border-background flex items-center justify-center text-xs font-medium"
title={approver}
>
{approver[0]}
</div>
))}
{tx.approvers.length > 3 && (
<div className="h-8 w-8 rounded-full bg-muted border-2 border-background flex items-center justify-center text-xs">
+{tx.approvers.length - 3}
</div>
)}
</div>
</TableCell>
<TableCell>
<Button variant="ghost" size="sm">View</Button>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
</CardContent>
</Card>
</div>
);
};
@@ -0,0 +1,199 @@
import React, { useState, useEffect } from 'react';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Progress } from '@/components/ui/progress';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { useTranslation } from 'react-i18next';
import {
DollarSign,
TrendingUp,
TrendingDown,
PieChart,
Activity,
AlertCircle,
CheckCircle,
Clock,
ArrowUpRight,
ArrowDownRight
} from 'lucide-react';
interface TreasuryMetrics {
totalBalance: number;
monthlyIncome: number;
monthlyExpenses: number;
pendingProposals: number;
approvedBudget: number;
healthScore: number;
}
interface BudgetCategory {
id: string;
name: string;
allocated: number;
spent: number;
remaining: number;
color: string;
}
export const TreasuryOverview: React.FC = () => {
const { t } = useTranslation();
const [metrics, setMetrics] = useState<TreasuryMetrics>({
totalBalance: 2500000,
monthlyIncome: 150000,
monthlyExpenses: 120000,
pendingProposals: 8,
approvedBudget: 1800000,
healthScore: 85
});
const [categories] = useState<BudgetCategory[]>([
{ id: '1', name: 'Development', allocated: 500000, spent: 320000, remaining: 180000, color: 'bg-blue-500' },
{ id: '2', name: 'Marketing', allocated: 200000, spent: 150000, remaining: 50000, color: 'bg-purple-500' },
{ id: '3', name: 'Operations', allocated: 300000, spent: 180000, remaining: 120000, color: 'bg-green-500' },
{ id: '4', name: 'Community', allocated: 150000, spent: 80000, remaining: 70000, color: 'bg-yellow-500' },
{ id: '5', name: 'Research', allocated: 250000, spent: 100000, remaining: 150000, color: 'bg-pink-500' },
{ id: '6', name: 'Infrastructure', allocated: 400000, spent: 350000, remaining: 50000, color: 'bg-indigo-500' }
]);
const getHealthStatus = (score: number) => {
if (score >= 80) return { label: 'Excellent', color: 'text-green-500', icon: CheckCircle };
if (score >= 60) return { label: 'Good', color: 'text-blue-500', icon: Activity };
if (score >= 40) return { label: 'Fair', color: 'text-yellow-500', icon: AlertCircle };
return { label: 'Critical', color: 'text-red-500', icon: AlertCircle };
};
const healthStatus = getHealthStatus(metrics.healthScore);
const HealthIcon = healthStatus.icon;
return (
<div className="space-y-6">
{/* Treasury Health Score */}
<Card>
<CardHeader>
<CardTitle className="flex items-center justify-between">
<span>Treasury Health</span>
<HealthIcon className={`h-6 w-6 ${healthStatus.color}`} />
</CardTitle>
</CardHeader>
<CardContent>
<div className="space-y-4">
<div className="flex items-center justify-between">
<span className="text-2xl font-bold">{metrics.healthScore}%</span>
<Badge className={healthStatus.color}>{healthStatus.label}</Badge>
</div>
<Progress value={metrics.healthScore} className="h-3" />
<div className="grid grid-cols-2 gap-4 text-sm">
<div>
<p className="text-muted-foreground">Runway</p>
<p className="font-semibold">20.8 months</p>
</div>
<div>
<p className="text-muted-foreground">Burn Rate</p>
<p className="font-semibold">$120k/month</p>
</div>
</div>
</div>
</CardContent>
</Card>
{/* Key Metrics */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<Card>
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-muted-foreground">Total Balance</p>
<p className="text-2xl font-bold">${(metrics.totalBalance / 1000000).toFixed(2)}M</p>
<p className="text-xs text-green-500 flex items-center mt-1">
<ArrowUpRight className="h-3 w-3 mr-1" />
+12.5% this month
</p>
</div>
<DollarSign className="h-8 w-8 text-green-500" />
</div>
</CardContent>
</Card>
<Card>
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-muted-foreground">Monthly Income</p>
<p className="text-2xl font-bold">${(metrics.monthlyIncome / 1000).toFixed(0)}k</p>
<p className="text-xs text-green-500 flex items-center mt-1">
<TrendingUp className="h-3 w-3 mr-1" />
+8.3% vs last month
</p>
</div>
<TrendingUp className="h-8 w-8 text-blue-500" />
</div>
</CardContent>
</Card>
<Card>
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-muted-foreground">Monthly Expenses</p>
<p className="text-2xl font-bold">${(metrics.monthlyExpenses / 1000).toFixed(0)}k</p>
<p className="text-xs text-red-500 flex items-center mt-1">
<ArrowDownRight className="h-3 w-3 mr-1" />
-5.2% vs last month
</p>
</div>
<TrendingDown className="h-8 w-8 text-red-500" />
</div>
</CardContent>
</Card>
<Card>
<CardContent className="p-6">
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-muted-foreground">Pending Proposals</p>
<p className="text-2xl font-bold">{metrics.pendingProposals}</p>
<p className="text-xs text-yellow-500 flex items-center mt-1">
<Clock className="h-3 w-3 mr-1" />
$450k requested
</p>
</div>
<Clock className="h-8 w-8 text-yellow-500" />
</div>
</CardContent>
</Card>
</div>
{/* Budget Categories */}
<Card>
<CardHeader>
<CardTitle>Budget Allocation by Category</CardTitle>
<CardDescription>Current quarter budget utilization</CardDescription>
</CardHeader>
<CardContent>
<div className="space-y-4">
{categories.map((category) => {
const utilization = (category.spent / category.allocated) * 100;
return (
<div key={category.id} className="space-y-2">
<div className="flex items-center justify-between text-sm">
<span className="font-medium">{category.name}</span>
<div className="flex items-center gap-4">
<span className="text-muted-foreground">
${(category.spent / 1000).toFixed(0)}k / ${(category.allocated / 1000).toFixed(0)}k
</span>
<Badge variant={utilization > 80 ? 'destructive' : 'secondary'}>
{utilization.toFixed(0)}%
</Badge>
</div>
</div>
<Progress value={utilization} className="h-2" />
</div>
);
})}
</div>
</CardContent>
</Card>
</div>
);
};