mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-09 20:12:10 +10:00
* feat: small library tweaks + company page * feat: new store view * fix: ci merge error * feat: add genres to store page * feat: sorting * feat: lock game/version imports while their tasks are running * feat: feature games * feat: tag based filtering * fix: make tags alphabetical * refactor: move a bunch of i18n to common * feat: add localizations for everything * fix: title description on panel * fix: feature carousel text * fix: i18n footer strings * feat: add tag page * fix: develop merge * feat: offline games support (don't error out if provider throws) * feat: tag management * feat: show library next to game import + small fixes * feat: most of the company and tag managers * feat: company text field editing * fix: small fixes + tsgo experiemental * feat: upload icon and banner * feat: store infinite scrolling and bulk import mode * fix: lint * fix: add drop-base to prettier ignore
85 lines
2.1 KiB
Vue
85 lines
2.1 KiB
Vue
<template>
|
|
<ModalTemplate :model-value="!!article">
|
|
<template #default>
|
|
<div>
|
|
<DialogTitle
|
|
as="h3"
|
|
class="text-lg font-bold font-display text-zinc-100"
|
|
>
|
|
{{ $t("news.delete") }}
|
|
</DialogTitle>
|
|
<p class="mt-1 text-sm text-zinc-400">
|
|
{{ $t("common.deleteConfirm", [article?.title]) }}
|
|
</p>
|
|
<p class="mt-2 text-sm font-bold text-red-500">
|
|
{{ $t("common.cannotUndo") }}
|
|
</p>
|
|
</div>
|
|
</template>
|
|
<template #buttons>
|
|
<LoadingButton
|
|
:loading="deleteLoading"
|
|
class="bg-red-600 text-white hover:bg-red-500"
|
|
@click="() => deleteArticle()"
|
|
>
|
|
{{ $t("delete") }}
|
|
</LoadingButton>
|
|
<button
|
|
class="inline-flex items-center rounded-md bg-zinc-800 px-3 py-2 text-sm font-semibold font-display text-white hover:bg-zinc-700"
|
|
@click="() => (article = undefined)"
|
|
>
|
|
{{ $t("cancel") }}
|
|
</button>
|
|
</template>
|
|
</ModalTemplate>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { DialogTitle } from "@headlessui/vue";
|
|
|
|
interface Article {
|
|
id: string;
|
|
title: string;
|
|
}
|
|
|
|
const article = defineModel<Article | undefined>();
|
|
const deleteLoading = ref(false);
|
|
const router = useRouter();
|
|
const { t } = useI18n();
|
|
const news = useNews();
|
|
if (!news.value) {
|
|
news.value = await fetchNews();
|
|
}
|
|
|
|
async function deleteArticle() {
|
|
try {
|
|
if (!article.value || !news.value) return;
|
|
|
|
deleteLoading.value = true;
|
|
await $dropFetch(`/api/v1/admin/news/${article.value.id}`, {
|
|
method: "DELETE",
|
|
});
|
|
|
|
const index = news.value.findIndex((e) => e.id == article.value?.id);
|
|
news.value.splice(index, 1);
|
|
|
|
article.value = undefined;
|
|
router.push("/news");
|
|
} catch (e) {
|
|
createModal(
|
|
ModalType.Notification,
|
|
{
|
|
title: t("errors.news.article.delete.title"),
|
|
description: t("errors.news.article.delete.desc", [
|
|
// @ts-expect-error attempt to display statusMessage on error
|
|
e?.statusMessage ?? t("errors.unknown"),
|
|
]),
|
|
},
|
|
(_, c) => c(),
|
|
);
|
|
} finally {
|
|
deleteLoading.value = false;
|
|
}
|
|
}
|
|
</script>
|