feat: user page & $dropFetch util

This commit is contained in:
DecDuck
2025-03-14 12:22:08 +11:00
parent 3225f536ce
commit bd1cb67cd0
39 changed files with 416 additions and 166 deletions

View File

@@ -115,7 +115,7 @@ const inCollections = computed(() =>
async function toggleLibrary() {
isLibraryLoading.value = true;
try {
await $fetch("/api/v1/collection/default/entry", {
await $dropFetch("/api/v1/collection/default/entry", {
method: inLibrary.value ? "DELETE" : "POST",
body: {
id: props.gameId,
@@ -142,7 +142,7 @@ async function toggleCollection(id: string) {
if (!collection) return;
const index = collection.entries.findIndex((e) => e.gameId == props.gameId);
await $fetch(`/api/v1/collection/${id}/entry`, {
await $dropFetch(`/api/v1/collection/${id}/entry`, {
method: index == -1 ? "POST" : "DELETE",
body: {
id: props.gameId,

View File

@@ -72,14 +72,14 @@ async function createCollection() {
createCollectionLoading.value = true;
// Create the collection
const response = await $fetch("/api/v1/collection", {
const response = await $dropFetch("/api/v1/collection", {
method: "POST",
body: { name: collectionName.value },
});
// Add the game if provided
if (props.gameId) {
const entry = await $fetch<
const entry = await $dropFetch<
CollectionEntry & { game: SerializeObject<Game> }
>(`/api/v1/collection/${response.id}/entry`, {
method: "POST",

View File

@@ -48,7 +48,7 @@ async function deleteCollection() {
if (!collection.value) return;
deleteLoading.value = true;
await $fetch(`/api/v1/collection/${collection.value.id}`, {
await $dropFetch(`/api/v1/collection/${collection.value.id}`, {
// @ts-ignore
method: "DELETE",
});

View File

@@ -348,7 +348,7 @@ async function createArticle() {
formData.append("content", newArticle.value.content);
formData.append("tags", JSON.stringify(newArticle.value.tags));
await $fetch("/api/v1/admin/news", {
await $dropFetch("/api/v1/admin/news", {
method: "POST",
body: formData,
});

View File

@@ -48,7 +48,7 @@ import type { Notification } from "@prisma/client";
const props = defineProps<{ notification: Notification }>();
async function deleteMe() {
await $fetch(`/api/v1/notifications/${props.notification.id}`, {
await $dropFetch(`/api/v1/notifications/${props.notification.id}`, {
method: "DELETE",
});
const notifications = useNotifications();

View File

@@ -146,7 +146,7 @@ async function uploadFile() {
}
}
const result = await $fetch(props.endpoint, { method: "POST", body: form });
const result = await $dropFetch(props.endpoint, { method: "POST", body: form });
open.value = false;
file.value = undefined;
emit("upload", result);