Files
memberApp/src/vueLib/tables/attendees/AttendeesTable.ts
Adrian Zürcher aba4bafb65
All checks were successful
Build Quasar SPA and Go Backend for memberApp / build-spa (push) Successful in 2m23s
Build Quasar SPA and Go Backend for memberApp / build-backend (amd64, .exe, windows) (push) Successful in 5m37s
Build Quasar SPA and Go Backend for memberApp / build-backend (amd64, , linux) (push) Successful in 5m49s
Build Quasar SPA and Go Backend for memberApp / build-backend (arm, 6, , linux) (push) Successful in 5m37s
Build Quasar SPA and Go Backend for memberApp / build-backend (arm64, , linux) (push) Successful in 5m34s
add new table feature for responsible person and assignment close #2
2025-11-06 17:43:20 +01:00

78 lines
1.7 KiB
TypeScript

import { appApi } from 'src/boot/axios';
import { ref, computed } from 'vue';
import type { Members } from 'src/vueLib/models/member';
import { useNotify } from 'src/vueLib/general/useNotify';
import { i18n } from 'boot/lang';
import type { Events } from 'src/vueLib/models/event';
export function useAttendeesTable() {
const attendees = ref<Members>([]);
const pagination = ref({
sortBy: 'firstName',
descending: false,
page: 1,
rowsPerPage: 20,
});
const columns = computed(() => [
{
name: 'firstName',
align: 'left' as const,
label: i18n.global.t('prename'),
field: 'firstName',
sortable: true,
},
{
name: 'lastName',
align: 'left' as const,
label: i18n.global.t('lastName'),
field: 'lastName',
sortable: true,
},
{ name: 'option', align: 'center' as const, label: '', field: 'option', icon: 'option' },
]);
const { NotifyResponse } = useNotify();
const loading = ref(false);
//updates Attendees list from database
async function updateAttendees() {
loading.value = true;
let events: Events | undefined;
await appApi
.get('events')
.then((resp) => {
if (resp.data === null) {
attendees.value = [];
return;
}
events = resp.data as Events;
})
.catch((err) => {
NotifyResponse(err, 'error');
})
.finally(() => {
loading.value = false;
});
if (!events || events.length === 0 || !events[0]?.attendees || events[0].attendees === null) {
attendees.value = [];
return;
}
attendees.value = events[0].attendees ?? [];
}
return {
attendees,
pagination,
columns,
loading,
updateAttendees,
};
}