homebox/frontend/pages/home/table.ts

24 lines
498 B
TypeScript
Raw Normal View History

2024-03-01 17:21:45 +00:00
import type { UserClient } from "~~/lib/api/user";
export function itemsTable(api: UserClient) {
const { data: items, refresh } = useAsyncData(async () => {
const { data } = await api.items.getAll({
page: 1,
pageSize: 5,
orderBy: "createdAt",
});
return data.items;
});
onServerEvent(ServerEvent.ItemMutation, () => {
console.log("item mutation");
refresh();
});
return computed(() => {
return {
items: items.value || [],
};
});
}