'use client';
import { useState, useCallback } from 'react';
import { Button } from '@/components/ui/button';
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog';
import { toast } from 'sonner';
import { FileText, NotebookText, BrainCircuit } from 'lucide-react';
const TEMPLATES_KEY = 'pe_note_templates';
interface NoteTemplate {
name: string;
icon: string;
content: string;
}
const DEFAULT_TEMPLATES: NoteTemplate[] = [
{
name: 'Meeting notes',
icon: 'FileText',
content: '
Meeting: [Title]
Date: [Date]
Attendees:
Agenda
Notes
Action Items
',
},
{
name: 'Daily journal',
icon: 'NotebookText',
content: '[Date]
What I did today
What I learned
What I\'m grateful for
',
},
{
name: 'Brain dump',
icon: 'BrainCircuit',
content: 'Brain Dump — [Date]
Everything on my mind right now:
Priorities
',
},
];
function getTemplates(): NoteTemplate[] {
if (typeof window === 'undefined') return DEFAULT_TEMPLATES;
try {
const stored = localStorage.getItem(TEMPLATES_KEY);
if (stored) return JSON.parse(stored);
} catch {}
return DEFAULT_TEMPLATES;
}
interface NoteTemplatesProps {
onCreateFromTemplate: (content: string) => void;
}
export function NoteTemplates({ onCreateFromTemplate }: NoteTemplatesProps) {
const [open, setOpen] = useState(false);
const [templates, setTemplates] = useState(getTemplates);
const handleSelect = useCallback(
(template: NoteTemplate) => {
const content = template.content
.replace(/\[Date\]/g, new Date().toLocaleDateString())
.replace(/\[Title\]/g, template.name);
onCreateFromTemplate(content);
setOpen(false);
toast.success('Note created from template');
},
[onCreateFromTemplate]
);
const iconMap: Record = {
FileText: ,
NotebookText: ,
BrainCircuit: ,
};
return (
<>
>
);
}