import { Conversation } from "@/types"; import { IconFileImport } from "@tabler/icons-react"; import { FC } from "react"; interface Props { onImport: (conversations: Conversation[]) => void; } export const Import: FC = ({ onImport }) => { return (
{ if (!e.target.files?.length) return; const file = e.target.files[0]; const reader = new FileReader(); reader.onload = (e) => { const conversations: Conversation[] = JSON.parse(e.target?.result as string); onImport(conversations); }; reader.readAsText(file); }} />
Import conversations
); };