Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | 1x 1x 1x 1x 1x 1x 3x 3x 3x | import type {ReactElement} from 'react';
import {useNavigate} from 'react-router-dom';
import {Box, Button, Chip, Paper, Stack, Tooltip, Typography} from '@mui/material';
import {AttachMoney as LoanIcon, Info as InfoIcon, Schedule as ScheduleIcon} from '@mui/icons-material';
interface LendingCardProps {
lendingBalance: string;
loanInterestRatePct: number;
nextLoanPaymentDue: string | null;
pendingDisbursement: boolean;
hasActiveLoans: boolean;
}
function formatCurrency(value: string): string {
const n = Number.parseFloat(value);
Iif (Number.isNaN(n)) return value;
return new Intl.NumberFormat('en-US', {style: 'currency', currency: 'USD'}).format(n);
}
function formatDate(value: string): string {
const d = new Date(value);
Iif (Number.isNaN(d.getTime())) return value;
return d.toLocaleDateString('en-US', {year: 'numeric', month: 'short', day: 'numeric'});
}
export default function LendingCard({
lendingBalance,
loanInterestRatePct,
nextLoanPaymentDue,
pendingDisbursement,
hasActiveLoans
}: LendingCardProps): ReactElement {
const navigate = useNavigate();
const accentColor = hasActiveLoans ? 'error.main' : 'success.main';
return (
<Paper sx={{p: 3, height: '100%', position: 'relative', borderTop: 4, borderColor: accentColor}}>
<Tooltip
title="FlowState Lending — your borrowing side. Loans are secured by your Treasury balance and never reduce it."
placement="top"
arrow
>
<InfoIcon
sx={{position: 'absolute', top: 8, right: 8, fontSize: 16, color: 'text.secondary', cursor: 'help'}}
/>
</Tooltip>
<Stack spacing={1.5}>
<Box sx={{display: 'flex', alignItems: 'center', gap: 1}}>
<LoanIcon sx={{color: accentColor}}/>
<Typography
variant="overline"
sx={{
color: "text.secondary",
fontWeight: 600
}}>
Lending
</Typography>
</Box>
<Typography variant="caption" sx={{
color: "text.secondary"
}}>
Outstanding Loans
</Typography>
<Typography
variant="h4"
sx={{
fontWeight: "bold",
color: accentColor
}}>
{hasActiveLoans ? formatCurrency(lendingBalance) : '$0'}
</Typography>
{hasActiveLoans && (
<Typography variant="body2" sx={{
color: "text.secondary"
}}>
Rate: {loanInterestRatePct.toFixed(2)}%/year
</Typography>
)}
{hasActiveLoans && nextLoanPaymentDue !== null && (
<Box sx={{display: 'flex', alignItems: 'center', gap: 0.5}}>
<ScheduleIcon fontSize="small" color="action"/>
<Typography variant="body2">
Next Payment: <strong>{formatDate(nextLoanPaymentDue)}</strong>
</Typography>
</Box>
)}
{pendingDisbursement && (
<Chip
label="Disbursement in progress — funds wiring shortly"
color="info"
size="small"
variant="outlined"
/>
)}
{!hasActiveLoans && !pendingDisbursement && (
<Typography variant="body2" sx={{
color: "text.secondary"
}}>
No active loans. Borrow against your balance at any time.
</Typography>
)}
<Box sx={{mt: 1}}>
{hasActiveLoans ? (
<Button
size="small"
variant="contained"
color="primary"
onClick={() => navigate('/loans/payment')}
>
Make a Payment
</Button>
) : (
<Button
size="small"
variant="outlined"
onClick={() => navigate('/loans')}
>
Request a Loan
</Button>
)}
</Box>
</Stack>
</Paper>
);
}
|