/* Lunch & Fees — balance, add funds, auto-reload, fees, transactions */
function WalletScreen({ onNav, onBack }) {
const [balance, setBalance] = React.useState(12.40);
const [autoReload, setAutoReload] = React.useState(true);
const [sheet, setSheet] = React.useState(false);
const [amt, setAmt] = React.useState(25);
const [fees, setFees] = React.useState([
{ id:1, title:'6th Grade Field Trip', sub:'Houston Museum · Due Jun 10', amount:15.00, icon:'bus', tint:'var(--gold-100)', ic:'var(--gold-600)' },
{ id:2, title:'Art Supplies Fee', sub:'Spring semester · Due Jun 15', amount:8.50, icon:'palette', tint:'var(--danger-100)', ic:'var(--danger-500)' },
]);
const [txns, setTxns] = React.useState([
{ t:'Cafeteria — Lunch', d:'Today · 11:48 AM', a:-3.25 },
{ t:'Cafeteria — Milk', d:'Today · 11:48 AM', a:-0.75 },
{ t:'Funds added', d:'May 28 · Auto-reload', a:25.00 },
{ t:'Cafeteria — Lunch', d:'May 28 · 11:51 AM', a:-3.25 },
]);
const AMTS = [10, 25, 50, 100];
const money = (n) => (n<0?'-$':'$') + Math.abs(n).toFixed(2);
const addFunds = () => {
setBalance(b => b + amt);
setTxns(t => [{ t:'Funds added', d:'Just now · Visa ••4821', a:amt }, ...t]);
setSheet(false);
jlToast(money(amt) + ' added to lunch account', { icon:'wallet' });
};
const payFee = (f) => {
setFees(fs => fs.filter(x => x.id !== f.id));
setTxns(t => [{ t:f.title, d:'Just now · Visa ••4821', a:-f.amount }, ...t]);
jlToast(f.title + ' paid · ' + money(f.amount), { icon:'check-check' });
};
const low = balance < 10;
return (
{/* balance hero */}
LUNCH ACCOUNT · EJ HATTEN
${balance.toFixed(2)}
{low
?
Low balance
:
About 3 days of meals remaining
}
{/* auto-reload */}
Auto-reload
Add $25 when balance drops below $10
{/* outstanding fees */}
Outstanding Fees
{fees.length === 0 ? (
All fees paid — you're all caught up
) : (
{fees.map(f => (
))}
)}
{/* transactions */}
Recent Activity
{txns.map((x,i) => (
{i>0 && }
0?'var(--success-100)':'var(--gray-100)', display:'flex', alignItems:'center', justifyContent:'center', flex:'0 0 auto' }}>
0?'arrow-down-left':'utensils'} size={16} color={x.a>0?'var(--success-500)':'var(--gray-500)'} />
0?'var(--success-600)':'var(--ink)', fontFamily:'var(--font-mono)' }}>{money(x.a)}
))}
{/* add funds sheet */}
{sheet && (
setSheet(false)} style={{ position:'absolute', inset:0, zIndex:60, background:'rgba(10,20,40,.4)', display:'flex', alignItems:'flex-end' }}>
e.stopPropagation()} style={{ width:'100%', background:'#fff', borderRadius:'22px 22px 0 0', padding:'10px 18px 32px' }}>
Add Funds
To EJ's lunch account
{AMTS.map(a => {
const on = amt===a;
return (
);
})}
Visa •••• 4821
)}
);
}
Object.assign(window, { WalletScreen });