refactor(components): create story actions component and related functions
This commit is contained in:
parent
c795e5d293
commit
8f24c9ff3d
28
components/story/atoms/actions.vue
Normal file
28
components/story/atoms/actions.vue
Normal file
@ -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>
|
6
lib/client/storyActions.ts
Normal file
6
lib/client/storyActions.ts
Normal file
@ -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");
|
||||
}
|
Loading…
Reference in New Issue
Block a user