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