first commit

This commit is contained in:
Adrian Zürcher
2025-10-12 14:56:18 +02:00
parent a9f2e11fe6
commit a908db4f38
92 changed files with 13273 additions and 0 deletions

View File

@@ -0,0 +1,149 @@
import { appApi } from 'src/boot/axios';
import { ref, computed } from 'vue';
import { useNotify } from 'src/vueLib/general/useNotify';
import { i18n } from 'boot/lang';
import type { Users } from 'src/vueLib/models/users';
export function useUserTable() {
const users = ref<Users>([]);
const pagination = ref({
sortBy: 'firstName',
descending: false,
page: 1,
rowsPerPage: 10,
});
const columns = computed(() => [
{ name: 'cake', align: 'center' as const, label: '', field: 'cake', icon: 'cake' },
{
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: 'birthday',
align: 'left' as const,
label: i18n.global.t('birthday'),
field: 'birthday',
sortable: true,
},
{
name: 'age',
align: 'left' as const,
label: i18n.global.t('age'),
field: 'age',
sortable: true,
},
{
name: 'address',
align: 'left' as const,
label: i18n.global.t('address'),
field: 'address',
sortable: true,
},
{
name: 'town',
align: 'left' as const,
label: i18n.global.t('town'),
field: 'town',
sortable: true,
},
{
name: 'zip',
align: 'left' as const,
label: i18n.global.t('zipCode'),
field: 'zip',
sortable: true,
},
{
name: 'phone',
align: 'left' as const,
label: i18n.global.t('phone'),
field: 'phone',
sortable: true,
},
{
name: 'email',
align: 'left' as const,
label: i18n.global.t('email'),
field: 'email',
sortable: true,
},
{
name: 'group',
align: 'left' as const,
label: i18n.global.t('group'),
field: 'group',
sortable: true,
},
{
name: 'responsiblePerson',
align: 'left' as const,
label: i18n.global.t('responsible'),
field: 'responsiblePerson',
sortable: true,
},
{
name: 'firstVisit',
align: 'left' as const,
label: i18n.global.t('firstVisit'),
field: 'firstVisit',
sortable: true,
},
{
name: 'lastVisit',
align: 'left' as const,
label: i18n.global.t('lastVisit'),
field: 'lastVisit',
sortable: true,
},
{ name: 'option', align: 'center' as const, label: '', field: 'option', icon: 'option' },
]);
const { NotifyResponse } = useNotify();
const loading = ref(false);
//updates user list from database
function updateUsers() {
loading.value = true;
appApi
.get('users')
.then((resp) => {
if (resp.data === null) {
users.value = [];
return;
}
users.value = resp.data as Users;
if (users.value === null) {
users.value = [];
return;
}
})
.catch((err) => {
NotifyResponse(err, 'error');
})
.finally(() => {
loading.value = false;
});
}
return {
users,
pagination,
columns,
loading,
updateUsers,
};
}