Files
Keep/keep-notes/components/delete-notebook-dialog.tsx
Sepehr Ramezani 806f4c4eeb fix(sidebar): eliminate full page reloads and fix notebook actions visibility
- Fix createNotebookOptimistic to call loadNotebooks() + triggerRefresh()
  after POST, so new notebooks appear immediately without page reload
- Remove window.location.reload() from delete-notebook-dialog (context
  already handles state refresh)
- Rewrite edit-notebook-dialog to use updateNotebook() from context
  instead of raw fetch + full page reload
- Fix NoteRefreshContext: remove refreshKey from useCallback deps to
  prevent unstable triggerRefresh callback cascade
- Fix notebook actions menu visibility: consolidate NotebookActions and
  expand button into single positioned container with proper z-index
- Add actions menu to active/selected notebook (was previously missing)
- Use proper Notebook type instead of any in sidebar components
- Increase button pr-20 to pr-24 to reserve space for actions
- Remove redundant router.refresh() from create-notebook-dialog

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-29 22:23:25 +02:00

55 lines
1.4 KiB
TypeScript

'use client'
import { Button } from '@/components/ui/button'
import { useLanguage } from '@/lib/i18n'
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog'
import { useNotebooks } from '@/context/notebooks-context'
interface DeleteNotebookDialogProps {
notebook: any
open: boolean
onOpenChange: (open: boolean) => void
}
export function DeleteNotebookDialog({ notebook, open, onOpenChange }: DeleteNotebookDialogProps) {
const { deleteNotebook } = useNotebooks()
const { t } = useLanguage()
const handleDelete = async () => {
try {
await deleteNotebook(notebook.id)
onOpenChange(false)
} catch (error) {
// Error already handled in UI
}
}
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent>
<DialogHeader>
<DialogTitle>{t('notebook.delete')}</DialogTitle>
<DialogDescription>
{t('notebook.deleteWarning', { notebookName: notebook?.name })}
</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button variant="outline" onClick={() => onOpenChange(false)}>
{t('general.cancel')}
</Button>
<Button variant="destructive" onClick={handleDelete}>
{t('notebook.deleteConfirm')}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}