From dd01a90bed6f3be8d949c34bcf72fc15250eb770 Mon Sep 17 00:00:00 2001 From: BFlorian91 Date: Sat, 16 Dec 2023 02:58:22 +0100 Subject: [PATCH] Feat: add remove instant from the dom without fetch, and authorId in editview --- src/components/CardSnippet.vue | 11 ++++++++++- src/views/EditSnippetView.vue | 3 ++- src/views/HomeView.vue | 7 +++++++ src/views/ShowSnippetView.vue | 7 ++++--- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/components/CardSnippet.vue b/src/components/CardSnippet.vue index 0f866ad..4b1c04e 100644 --- a/src/components/CardSnippet.vue +++ b/src/components/CardSnippet.vue @@ -43,6 +43,10 @@ const props = defineProps({ type: String, default: "", }, + onDelete: { + type: Function, + default: () => {}, + }, }); const authorId = "Florian"; @@ -62,6 +66,11 @@ const handleEdit = (id: string) => { const { elapsedTime } = useElapsedTime(props.updatedAt); +const handleDelete = async () => { + await deleteSnippet(props.id); + props.onDelete(props.id); +}; + onMounted(async () => { await nextTick(); Prism.highlightAll(); @@ -204,7 +213,7 @@ watch(readMore, async (newValue) => {

Updated {{ elapsedTime }}

-
diff --git a/src/views/ShowSnippetView.vue b/src/views/ShowSnippetView.vue index f161912..a0c4c78 100644 --- a/src/views/ShowSnippetView.vue +++ b/src/views/ShowSnippetView.vue @@ -1,7 +1,7 @@