initial commit
Some checks failed
deploy / build-and-deploy (push) Failing after 21s

This commit is contained in:
2025-05-18 13:16:20 +02:00
commit 60f3f8a096
148 changed files with 17900 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
import { actions } from 'astro:actions';
import { users } from './state.ts';
import type { User } from './types.ts';
import { actionErrorPopup } from '@util/action.ts';
export async function fetchUsers(options?: { username?: string | null }) {
const { data, error } = await actions.user.users({ username: options?.username });
if (error) {
actionErrorPopup(error);
return;
}
users.set(data.users);
}
export async function addUser(user: User) {
const { data, error } = await actions.user.addUser({
username: user.username,
firstname: user.firstname,
lastname: user.lastname,
birthday: user.birthday,
telephone: user.telephone,
uuid: user.uuid
});
if (error) {
actionErrorPopup(error);
return;
}
users.update((old) => {
old.push(Object.assign(user, { id: data.id }));
return old;
});
}
export async function editUser(user: User) {
const { error } = await actions.user.editUser({
id: user.id,
username: user.username,
firstname: user.firstname,
lastname: user.lastname,
birthday: user.birthday,
telephone: user.telephone,
uuid: user.uuid
});
if (error) {
actionErrorPopup(error);
return;
}
users.update((old) => {
const index = old.findIndex((a) => a.id == user.id);
old[index] = user;
return old;
});
}