import { useState } from 'react'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { Plus, ArrowRight, Trash2 } from 'lucide-react'; import { inboxApi } from '../lib/api'; import { Button } from '../components/ui/Button'; import { Input } from '../components/ui/Input'; import { Card, CardContent } from '../components/ui/Card'; import { ProcessModal } from '../components/inbox/ProcessModal'; import type { InboxItemResponseDto } from '@nick-tracker/shared-types'; export function InboxPage() { const queryClient = useQueryClient(); const [newItem, setNewItem] = useState(''); const [selectedItem, setSelectedItem] = useState(null); const { data: items = [], isLoading } = useQuery({ queryKey: ['inbox'], queryFn: async () => { const response = await inboxApi.getAll(); return response.data as InboxItemResponseDto[]; }, }); const createMutation = useMutation({ mutationFn: (content: string) => inboxApi.create(content), onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['inbox'] }); setNewItem(''); }, }); const deleteMutation = useMutation({ mutationFn: (id: string) => inboxApi.delete(id), onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['inbox'] }); }, }); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (newItem.trim()) { createMutation.mutate(newItem.trim()); } }; const handleProcess = (item: InboxItemResponseDto) => { setSelectedItem(item); }; const handleCloseModal = () => { setSelectedItem(null); queryClient.invalidateQueries({ queryKey: ['inbox'] }); }; return (

Inbox

Capture everything on your mind. Process items to clarify what they mean.

setNewItem(e.target.value)} placeholder="What's on your mind?" className="flex-1" />
{isLoading ? (
Loading...
) : items.length === 0 ? (

Your inbox is empty. Add items above to capture thoughts and tasks.

) : (
{items.map((item) => (

{item.content}

{new Date(item.createdAt).toLocaleDateString()}

))}
)}
{selectedItem && ( )}
); }