frontend: add defaultUser, supporter

This commit is contained in:
Alex
2025-03-02 23:12:10 +01:00
parent 29f405385e
commit 1f61c9ad71
6 changed files with 186 additions and 129 deletions

View File

@@ -8,6 +8,7 @@
import { applyAction, enhance } from '$app/forms';
import { hasPrivilige, receive, send } from '$lib/utils/helpers';
import { PERMISSIONS } from '$lib/utils/constants';
import { defaultSupporter, defaultUser } from '$lib/utils/defaults';
/** @type {import('./$types').ActionData} */
export let form;
@@ -96,7 +97,7 @@
/**
* Opens the edit modal for the selected user.
* @param {App.Locals['user'] | null} user The user to edit.
* @param {App.Locals['user']} user The user to edit.
*/
const openEditUserModal = (user) => {
selectedUser = user;
@@ -213,7 +214,7 @@
</button>
</div>
<div>
<button class="btn primary" on:click={() => openEditUserModal(null)}>
<button class="btn primary" on:click={() => openEditUserModal(defaultUser())}>
<i class="fas fa-plus"></i>
{$t('add_new')}
</button>
@@ -314,7 +315,7 @@
</button>
</div>
<div>
<button class="btn primary" on:click={() => openEditUserModal(null)}>
<button class="btn primary" on:click={() => openEditUserModal(defaultSupporter())}>
<i class="fas fa-plus"></i>
{$t('add_new')}
</button>
@@ -330,21 +331,17 @@
<div class="accordion-content">
<table class="table">
<tbody>
<tr>
<th>{$t('user.id')}</th>
<td>{user.id}</td>
</tr>
<tr>
<th>{$t('name')}</th>
<td>{user.first_name} {user.last_name}</td>
</tr>
<tr>
<th>{$t('user.email')}</th>
<td>{user.email}</td>
<th>{$t('company')}</th>
<td>{user.company}</td>
</tr>
<tr>
<th>{$t('subscription.subscription')}</th>
<td>{user.membership?.subscription_model?.name}</td>
<th>{$t('user.email')}</th>
<td>{user.email}</td>
</tr>
<tr>
<th>{$t('status')}</th>
@@ -536,7 +533,7 @@
</div>
</div>
{#if showUserModal}
{#if showUserModal && selectedUser !== null}
<Modal on:close={close}>
<UserEditForm
{form}