add strike reason admin panel

This commit is contained in:
2025-05-22 00:25:22 +02:00
parent 45f984e4da
commit a21d3d283a
11 changed files with 250 additions and 5 deletions

View File

@ -0,0 +1,56 @@
<script lang="ts">
import DataTable from '@components/admin/table/DataTable.svelte';
import {
deleteStrikeReason,
editStrikeReason,
type StrikeReason,
strikeReasons
} from '@app/admin/strikeReasons/strikeReasons.ts';
import { confirmPopupState } from '@components/popup/ConfirmPopup.ts';
import CrudPopup from '@components/admin/popup/CrudPopup.svelte';
// state
let editPopupStrikeReason = $state(null);
let editPopupOpen = $derived(!!editPopupStrikeReason);
// lifecycle
$effect(() => {
if (!editPopupOpen) editPopupStrikeReason = null;
});
// callback
function onBlockedUserDelete(strikeReason: StrikeReason) {
$confirmPopupState = {
title: 'Nutzer entblockieren?',
message: 'Soll der Nutzer wirklich entblockiert werden?\nDieser kann sich danach wieder registrieren.',
onConfirm: () => deleteStrikeReason(strikeReason)
};
}
</script>
<DataTable
data={strikeReasons}
count={true}
keys={[
{ key: 'name', label: 'Name', width: 20 },
{ key: 'weight', label: 'Gewichtung', width: 70, sortable: true }
]}
onDelete={onBlockedUserDelete}
onEdit={(strikeReason) => (editPopupStrikeReason = strikeReason)}
/>
<CrudPopup
texts={{
title: 'Strikegrund bearbeiten',
submitButtonTitle: 'Speichern',
confirmPopupTitle: 'Änderungen speichern',
confirmPopupMessage: 'Sollen die Änderungen gespeichert werden?'
}}
target={editPopupStrikeReason}
keys={[
[{ key: 'name', type: 'text', label: 'Name', options: { required: true, dynamicWidth: true } }],
[{ key: 'weight', type: 'number', label: 'Gewichtung', options: { required: true, dynamicWidth: true } }]
]}
onSubmit={editStrikeReason}
bind:open={editPopupOpen}
/>