feat(tasks): text input + Honcho persistence
Manual task input box in TaskList component. Tasks persisted to Honcho as JSON preference on every mutation. Tasks loaded from Honcho on identify (session reconnect).
This commit is contained in:
@@ -1,13 +1,23 @@
|
||||
import { useState } from 'react';
|
||||
import { Task } from '../hooks/useConversation';
|
||||
|
||||
interface Props {
|
||||
tasks: Task[];
|
||||
addTask: (text: string) => void;
|
||||
}
|
||||
|
||||
export default function TaskList({ tasks }: Props) {
|
||||
export default function TaskList({ tasks, addTask }: Props) {
|
||||
const [input, setInput] = useState('');
|
||||
const pending = tasks.filter((t) => !t.completed);
|
||||
const done = tasks.filter((t) => t.completed);
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (!input.trim()) return;
|
||||
addTask(input.trim());
|
||||
setInput('');
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="p-3">
|
||||
<h3 className="text-sm font-bold text-kira-plum mb-2 flex items-center gap-2">
|
||||
@@ -19,9 +29,25 @@ export default function TaskList({ tasks }: Props) {
|
||||
)}
|
||||
</h3>
|
||||
|
||||
<form onSubmit={handleSubmit} className="flex gap-1.5 mb-2">
|
||||
<input
|
||||
type="text"
|
||||
value={input}
|
||||
onChange={(e) => setInput(e.target.value)}
|
||||
placeholder="add a task..."
|
||||
className="flex-1 bg-white/30 border border-kira-pink/20 rounded-lg px-2 py-1 text-xs text-kira-plum placeholder:text-kira-plum/30 focus:outline-none focus:border-kira-pink/50"
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
className="bg-kira-pink/30 hover:bg-kira-pink/50 text-kira-plum text-xs px-2 py-1 rounded-lg transition-colors"
|
||||
>
|
||||
+
|
||||
</button>
|
||||
</form>
|
||||
|
||||
{tasks.length === 0 && (
|
||||
<div className="text-xs text-kira-plum/30 text-center py-4">
|
||||
tell Kira what you need to do!
|
||||
<div className="text-xs text-kira-plum/30 text-center py-2">
|
||||
tell Kira or type a task above!
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user