implement edit bookmark dialog

This commit is contained in:
2025-05-25 15:40:16 +01:00
parent 255acfcb32
commit 6afb5dee9a
22 changed files with 630 additions and 127 deletions

View File

@@ -1,14 +1,13 @@
import { Bookmark } from "@markone/core"
import { useDeleteBookmark } from "~/bookmark/api"
import { Button } from "~/components/button"
import { Dialog, DialogTitle, DialogBody, DialogActionRow } from "~/components/dialog"
import { Dialog, DialogActionRow, DialogBody, DialogTitle } from "~/components/dialog"
import { LoadingSpinner } from "~/components/loading-spinner"
import { useMnemonics } from "~/hooks/use-mnemonics"
import { useBookmarkPageStore, ActiveDialog } from "../-store"
import { DialogKind, useBookmarkPageStore } from "../-store"
function DeleteBookmarkDialog() {
// biome-ignore lint/style/noNonNullAssertion: this cannot be null when delete bookmark dialog is visible
const bookmark = useBookmarkPageStore((state) => state.bookmarkToBeDeleted!)
const setActiveDialog = useBookmarkPageStore((state) => state.setActiveDialog)
function DeleteBookmarkDialog({ bookmark }: { bookmark: Bookmark }) {
const closeDialog = useBookmarkPageStore((state) => state.closeDialog)
const deleteBookmarkMutation = useDeleteBookmark()
useMnemonics(
@@ -22,14 +21,14 @@ function DeleteBookmarkDialog() {
async function proceed() {
try {
await deleteBookmarkMutation.mutateAsync({ bookmark })
setActiveDialog(ActiveDialog.None)
closeDialog()
} catch (error) {
console.error(error)
}
}
function cancel() {
setActiveDialog(ActiveDialog.None)
closeDialog()
}
function body() {