// screen-secondary.jsx — Edit profile, Public profile, Balance & transactions
const { useState: useSecState, useEffect: useSecEffect } = React;
/* ----------------------------------------------------------------
Edit profile
----------------------------------------------------------------- */
function EditProfileScreen({ currentUser, goBack, onSave }) {
const Icon = window.Icon;
const u = currentUser || {};
const nameParts = (u.name || 'Heba Ali').split(' ');
const [form, setForm] = useSecState({
first: nameParts[0] || 'Heba',
last: nameParts.slice(1).join(' ') || 'Ali',
role: u.role || 'UX / UI Designer',
email: u.email || '',
phone: u.phone || '',
bio: u.bio || 'Product designer focused on internal tools and innovation systems.',
});
const [saving, setSaving] = useSecState(false);
const set = (k) => (e) => setForm(f => ({ ...f, [k]: e.target.value }));
const handleSave = async () => {
setSaving(true);
try {
const updated = await window.API.updateMe({ name: `${form.first} ${form.last}`, role: form.role, bio: form.bio, phone: form.phone });
onSave(updated);
} catch (e) {
onSave(null);
} finally {
setSaving(false);
}
};
return (
Edit profile
Update your details and how you appear across IdeaMint.
Profile photo
PNG or JPG, at least 400×400px.
);
}
function EditField({ label, value, onChange, type }) {
return (
);
}
/* ----------------------------------------------------------------
Public profile (another user)
----------------------------------------------------------------- */
function PublicProfileScreen({ user, goBack, openIdea, votes, onVote }) {
const Icon = window.Icon;
const [following, setFollowing] = useSecState(false);
const u = user || window.NAMES[0];
const ideas = window.IDEAS.filter((_, i) => i % 2 === 0).slice(0, 4).map(x => ({ ...x, author: u.name, avatar: u.av }));
return (
{/* banner */}
{/* stat strip */}
{[['Published ideas', '30', 'checkCircle', '#15a564'], ['Total upvotes', '4.2k', 'thumbUp', '#0a66ff'], ['Idea views', '12.8k', 'eye', '#6d5cf0'], ['Rank', '#3', 'award', '#e8930c']].map(([l, v, ic, c]) => (
))}
{u.name.split(' ')[0]}'s ideas
{ideas.map(i => (
openIdea(i)}>
{i.title}
{i.desc}
onVote(i.id, d)} />
))}
);
}
/* ----------------------------------------------------------------
Balance & transactions detail
----------------------------------------------------------------- */
const ALL_TX = [
{ id: 1, label: 'Idea published — "Carbon-neutral delivery"', date: 'May 14, 2025', amount: +150, kind: 'earn' },
{ id: 2, label: 'Redeemed — Free flight ticket to Cairo', date: 'May 10, 2025', amount: -250, kind: 'spend' },
{ id: 3, label: 'Upvotes milestone bonus (500 upvotes)', date: 'May 7, 2025', amount: +80, kind: 'earn' },
{ id: 4, label: 'Idea published — "Smart meeting summaries"', date: 'May 2, 2025', amount: +150, kind: 'earn' },
{ id: 5, label: 'Redeemed — A full day off from work', date: 'Apr 28, 2025', amount: -50, kind: 'spend' },
{ id: 6, label: 'Idea of the month award', date: 'Apr 22, 2025', amount: +200, kind: 'earn' },
{ id: 7, label: 'Idea published — "Mentorship matching"', date: 'Apr 15, 2025', amount: +150, kind: 'earn' },
{ id: 8, label: 'Comment milestone bonus', date: 'Apr 9, 2025', amount: +40, kind: 'earn' },
{ id: 9, label: 'Redeemed — Premium standing desk', date: 'Apr 1, 2025', amount: -600, kind: 'spend' },
];
function BalanceDetailScreen({ balance, goBack }) {
const Icon = window.Icon;
const [filter, setFilter] = useSecState('All');
const [allTx, setAllTx] = useSecState(ALL_TX);
useSecEffect(() => {
window.API.transactions().then(setAllTx).catch(() => {});
}, []);
const earned = allTx.filter(t => t.kind === 'earn').reduce((s, t) => s + Math.abs(t.amount), 0);
const spent = allTx.filter(t => t.kind === 'spend').reduce((s, t) => s + Math.abs(t.amount), 0);
const rows = filter === 'All' ? allTx : allTx.filter(t => filter === 'Earned' ? t.kind === 'earn' : t.kind === 'spend');
return (
Balance & transactions
A complete history of points you've earned and redeemed.
Current balance
{window.fmt(balance)} USD
+{window.fmt(earned)}
Total earned
−{window.fmt(spent)}
Total redeemed
Transaction history
{['All', 'Earned', 'Redeemed'].map(f => )}
{rows.map((t, i) => (
{t.amount > 0 ? '+' : ''}{window.fmt(t.amount)} USD
))}
);
}
Object.assign(window, { EditProfileScreen, PublicProfileScreen, BalanceDetailScreen });