import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" interface Memory { value: string context: Record timestamp: string } interface MemoriesTableProps { memories: Record onEdit: (key: string) => void onDelete: (key: string) => void } function extractTags(memory: Memory) { const tags: string[] = [] if (memory.context) { if (memory.context.tags && Array.isArray(memory.context.tags)) { tags.push(...memory.context.tags) } if (memory.context.category) tags.push(memory.context.category) if (memory.context.type) tags.push(memory.context.type) Object.entries(memory.context).forEach(([key, value]) => { if (key.toLowerCase().includes('tag') && typeof value === 'string' && !tags.includes(value)) { tags.push(value) } }) } return tags } function tagColor(tag: string) { const colors = { education: "bg-blue-600", health: "bg-green-600", preference: "bg-purple-600", relationship: "bg-red-600", food: "bg-orange-600", work: "bg-teal-600", personal: "bg-pink-600", default: "bg-gray-600" } return colors[tag.toLowerCase() as keyof typeof colors] || colors.default } export function MemoriesTable({ memories, onEdit, onDelete }: MemoriesTableProps) { return (
Key Value Tags Timestamp Actions {Object.entries(memories).map(([key, memory]) => ( {key}
{memory.value}
{extractTags(memory).map((tag, i) => ( {tag} ))}
{new Date(memory.timestamp).toLocaleDateString()}
))}
) }