// Ideas / Backlog. Three input methods at top + chronological list + filter chips.
const { useState: useStateId, useEffect: useEffectId, useRef: useRefId } = React;
function Ideas({ data, setData, onUseForGen }) {
const { Button, IconButton, Card, Pill, Textarea, TextInput, SectionHead, EmptyState } = window.UI;
const I = window.Icons;
const [text, setText] = useStateId('');
const [link, setLink] = useStateId('');
const [recording, setRecording] = useStateId(false);
const [recTime, setRecTime] = useStateId(0);
const [filter, setFilter] = useStateId('all');
useEffectId(() => {
if (!recording) return;
const t = setInterval(() => setRecTime(v => v + 1), 1000);
return () => clearInterval(t);
}, [recording]);
const addIdea = (idea) => {
setData({ ...data, ideas: [{ ...idea, id: 'i' + Date.now(), when: 'только что' }, ...data.ideas] });
};
const list = filter === 'all' ? data.ideas : data.ideas.filter(i => i.type === filter);
const TYPE_ICONS = { text: I.Text, link: I.Link, voice: I.Mic };
const TYPE_LABELS = { text: 'Текст', link: 'Ссылка', voice: 'Голос' };
return (
{/* Three input methods */}
{/* Text */}
{/* Link */}
Ссылка
} className="mb-2"/>
Мы вытащим заголовок и описание.
{/* Voice */}
Голосовое
{recording ? (
<>
{Array.from({ length: 22 }).map((_, i) => (
))}
{Math.floor(recTime/60)}:{String(recTime%60).padStart(2,'0')} · идёт запись
>
) : (
<>
Нажмите, чтобы записать
До 5 минут. Расшифруем автоматом.
>
)}
{/* Filter chips */}
{[
{ v: 'all', label: 'Все', count: data.ideas.length },
{ v: 'text', label: 'Текст', count: data.ideas.filter(i => i.type === 'text').length },
{ v: 'link', label: 'Ссылки', count: data.ideas.filter(i => i.type === 'link').length },
{ v: 'voice', label: 'Голос', count: data.ideas.filter(i => i.type === 'voice').length },
].map((f) => (
setFilter(f.v)}>
{f.label} {f.count}
))}
{/* List */}
{list.length === 0 ? (
}
title="Пока пусто"
sub="Закиньте первую идею выше — текстом, ссылкой или голосом."
/>
) : (
{list.map((idea, i) => {
const Icon = TYPE_ICONS[idea.type];
return (
0 ? 'border-t border-ink-200' : '')}>
{idea.preview}
{TYPE_LABELS[idea.type]} · {idea.when}
setData({ ...data, ideas: data.ideas.filter(x => x.id !== idea.id) })}>
);
})}
)}
);
}
window.Screens = window.Screens || {};
window.Screens.Ideas = Ideas;