implement edit bookmark dialog
This commit is contained in:
@@ -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() {
|
||||
|
Reference in New Issue
Block a user