refactor(components): create story actions component and related functions

This commit is contained in:
parent c795e5d293
commit 8f24c9ff3d
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C
2 changed files with 34 additions and 0 deletions

@ -0,0 +1,28 @@
<script setup lang="ts">
import { theme } from "ant-design-vue";
import { IStory } from "@models/stories";
import { deleteStory } from "@client/storyActions";
const props = defineProps<{ story: IStory }>();
</script>
<template>
<a-popconfirm title="Are you sure you want to delete this story?" @confirm="() => deleteStory(story._id!)">
<a-tooltip title="Delete">
<a-button type="ghost">
<icon istyle="regular" name="trash" :icolor="theme.useToken().token.value.colorError" />
</a-button>
</a-tooltip>
</a-popconfirm>
<a-tooltip title="Edit">
<a-button type="ghost" @click="$router.push(`/story/${story._id}/edit`)">
<icon istyle="regular" name="pen-to-square" />
</a-button>
</a-tooltip>
<a-tooltip title="View">
<a-button type="ghost" @click="$router.push(`/story/${story._id}/${story.chapters.length}`)">
<icon istyle="regular" name="eye" />
</a-button>
</a-tooltip>
</template>
<style scoped></style>

@ -0,0 +1,6 @@
import { useApiFetch } from "#imports";
export async function deleteStory(id: number) {
await useApiFetch(`/story/${id}`, { method: "delete" });
await navigateTo("/my-stuff/stories");
}