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