// screen-profile-trade.jsx — Profile and Trade Balance screens
const { useState: usePTState, useEffect: usePTEffect } = React;
function ProfileScreen({ currentUser, onEdit }) {
const Icon = window.Icon;
const u = currentUser || {};
const nameParts = (u.name || 'Heba Ali').split(' ');
const firstName = nameParts[0] || '';
const lastName = nameParts.slice(1).join(' ') || '';
const [stats, setStats] = usePTState(window.PROFILE_STATS);
usePTEffect(() => {
if (!u.id) return;
window.API.getUser(u.id).then(data => {
setStats([
{ label: 'All ideas', value: Number(data.idea_count ?? 0) },
{ label: 'Ideas under review', value: Number(data.review_count ?? 0) },
{ label: 'Published ideas', value: Number(data.published_count ?? 0) },
{ label: 'Rejected ideas', value: Number(data.rejected_count ?? 0) },
{ label: 'Ideas views', value: (data.ideas || []).reduce((s, i) => s + Number(i.views || 0), 0) },
]);
}).catch(() => {});
}, [u.id]);
return (
My profile
Manage your information and track your idea performance.
{u.name || 'Heba Ali'}
{u.role || 'UX / UI Designer'}
{['#e8930c', '#0a66ff', '#e23b56'].map(c =>
)}
Bio
{u.bio || 'Product designer focused on internal tools and innovation systems.'}
General stats
{stats.map((s, i) => (
{s.label}
{window.fmt(s.value)}
))}
Achievements
{[['#e8930c', 'Top voice'], ['#0a66ff', 'Innovator'], ['#e23b56', '50 ideas']].map(([c, t]) => (
))}
);
}
function InfoRow({ label, value, icon }) {
const Icon = window.Icon;
return (
{label}
{icon && }{value}
);
}
function TradeScreen({ balance, onRedeem, onHistory }) {
const Icon = window.Icon;
const [awards, setAwards] = usePTState(window.AWARDS);
const [txns, setTxns] = usePTState(window.TRANSACTIONS);
usePTEffect(() => {
window.API.getAwards().then(setAwards).catch(() => {});
window.API.transactions().then(setTxns).catch(() => {});
}, []);
return (
Trade your balance
Convert the points you've earned from great ideas into real rewards.
Available balance
{window.fmt(balance)} USD
List of awards
{awards.map(a => {
const can = balance >= a.cost;
return (
{a.emoji}
{a.title}
{window.fmt(a.cost)} USD
);
})}
Recent transactions
{txns.map((t, i) => (
{t.amount > 0 ? '+' : ''}{window.fmt(t.amount)} USD
))}
);
}
Object.assign(window, { ProfileScreen, TradeScreen });