mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-01-31 15:37:09 +01:00
feat: user page & $dropFetch util
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user