feat: Migrate to Nuxt 3 framework (#5184)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend Tests (push) Waiting to run
Docker Nightly Production / Build Package (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
Release Drafter / ✏️ Draft release (push) Waiting to run

Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com>
Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
Hoa (Kyle) Trinh 2025-06-20 00:09:12 +07:00 committed by GitHub
commit c24d532608
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
403 changed files with 23959 additions and 19557 deletions

View file

@ -1,6 +1,5 @@
import { useAsync, ref } from "@nuxtjs/composition-api";
import { useUserApi } from "~/composables/api";
import { UserIn, UserOut } from "~/lib/api/types/user";
import type { UserIn, UserOut } from "~/lib/api/types/user";
/*
TODO: Potentially combine useAllUsers and useUser by delaying the get all users functionality
@ -10,38 +9,16 @@ to control whether the object is substantiated... but some of the others rely on
export const useAllUsers = function () {
const api = useUserApi();
const loading = ref(false);
function getAllUsers() {
loading.value = true;
const asyncKey = String(Date.now());
const allUsers = useAsync(async () => {
const { data } = await api.users.getAll();
if (data) {
return data.items;
} else {
return null;
}
}, asyncKey);
loading.value = false;
return allUsers;
}
async function refreshAllUsers() {
loading.value = true;
const asyncKey = String(Date.now());
const { data: users, refresh: refreshAllUsers } = useLazyAsyncData(asyncKey, async () => {
const { data } = await api.users.getAll();
if (data) {
users.value = data.items;
} else {
users.value = null;
return data.items;
}
loading.value = false;
}
const users = getAllUsers();
else {
return null;
}
});
return { users, refreshAllUsers };
};
@ -52,10 +29,10 @@ export const useUser = function (refreshFunc: CallableFunction | null = null) {
function getUser(id: string) {
loading.value = true;
const user = useAsync(async () => {
const user = useAsyncData(id, async () => {
const { data } = await api.users.getOne(id);
return data;
}, id);
});
loading.value = false;
return user;