Basic implementation of payment methods

This commit is contained in:
2026-07-28 15:50:58 +02:00
parent afc91545a9
commit 6c9281516e
39 changed files with 749 additions and 24 deletions
@@ -0,0 +1,212 @@
<script setup>
import { ref } from 'vue';
import FullScreenModal from "../../../../Views/Components/FullScreenModal.vue";
import { useAjax } from "../../../../../resources/js/components/ajaxHandler.js";
import { toast } from "vue3-toastify";
const props = defineProps({
data: {
type: Object,
default: () => ({})
},
})
const { request } = useAjax()
const paymentMethods = ref(props.data.paymentMethods ?? [])
const editing = ref(null)
const form = ref({ name: '', description: '', active: true })
function edit(paymentMethod) {
editing.value = paymentMethod
form.value = {
name: paymentMethod.name,
description: paymentMethod.description ?? '',
active: paymentMethod.active,
}
}
function close() {
editing.value = null
}
async function save() {
const response = await request('/api/v1/admin/tenant/payment-methods/' + editing.value.id, {
method: 'POST',
body: form.value,
})
if (response && response.status === 'success') {
toast.success(response.message)
Object.assign(editing.value, form.value)
close()
} else {
toast.error(response?.message ?? 'Fehler beim Speichern')
}
}
</script>
<template>
<table class="payment-method-table">
<thead>
<tr>
<th>Name</th>
<th>Slug</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="paymentMethod in paymentMethods" :key="paymentMethod.id">
<td>{{ paymentMethod.name }}</td>
<td>{{ paymentMethod.slug }}</td>
<td>
<span :class="paymentMethod.active ? 'badge-active' : 'badge-inactive'">
{{ paymentMethod.active ? 'Aktiv' : 'Inaktiv' }}
</span>
</td>
<td>
<button class="btn-edit" @click="edit(paymentMethod)">Bearbeiten</button>
</td>
</tr>
</tbody>
</table>
<FullScreenModal :show="editing !== null" @close="close">
<template v-if="editing">
<h2>Zahlungsweg bearbeiten</h2>
<table class="data-table">
<tr><th>Name:</th><td><input type="text" v-model="form.name" class="form-input" /></td></tr>
<tr><th>Slug:</th><td>{{ editing.slug }}</td></tr>
<tr><th>Beschreibung:</th><td><textarea v-model="form.description" class="form-input"></textarea></td></tr>
<tr><th>Aktiv:</th><td><input type="checkbox" v-model="form.active" /></td></tr>
</table>
<div class="btn-group">
<button class="btn-save" @click="save">Speichern</button>
<button class="btn-cancel" @click="close">Abbrechen</button>
</div>
</template>
</FullScreenModal>
</template>
<style scoped>
.payment-method-table {
width: 100%;
border-collapse: collapse;
border: 1px solid #d1d5db;
border-radius: 8px;
overflow: hidden;
}
.payment-method-table thead th {
text-align: left;
padding: 10px 16px;
background-color: #f9fafb;
color: #374151;
font-weight: bold;
border-bottom: 2px solid #d1d5db;
}
.payment-method-table tbody td {
padding: 10px 16px;
border-bottom: 1px solid #e5e7eb;
}
.badge-active {
display: inline-block;
padding: 3px 12px;
border-radius: 12px;
font-size: 0.85rem;
font-weight: bold;
color: #166534;
background-color: #dcfce7;
border: 1px solid #22c55e;
}
.badge-inactive {
display: inline-block;
padding: 3px 12px;
border-radius: 12px;
font-size: 0.85rem;
font-weight: bold;
color: #991b1b;
background-color: #fee2e2;
border: 1px solid #ef4444;
}
.btn-edit {
padding: 6px 16px;
border: none;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
font-size: 0.9rem;
background-color: #1d4899;
color: #ffffff;
}
.btn-edit:hover {
background-color: #163a7a;
}
.data-table {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
}
.data-table th {
text-align: left;
padding: 8px 12px;
width: 200px;
color: #374151;
border-bottom: 1px solid #e5e7eb;
}
.data-table td {
padding: 8px 12px;
border-bottom: 1px solid #e5e7eb;
}
.form-input {
width: 100%;
padding: 6px 10px;
border: 1px solid #d1d5db;
border-radius: 6px;
font-size: 0.95rem;
box-sizing: border-box;
}
.btn-group {
display: flex;
gap: 10px;
margin-top: 15px;
}
.btn-save, .btn-cancel {
padding: 8px 20px;
border: none;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
font-size: 0.9rem;
}
.btn-save {
background-color: #16a34a;
color: #ffffff;
}
.btn-save:hover {
background-color: #15803d;
}
.btn-cancel {
background-color: #e5e7eb;
color: #374151;
}
.btn-cancel:hover {
background-color: #d1d5db;
}
</style>
+6
View File
@@ -6,6 +6,7 @@ import TenantContact from "./Partials/TenantContact.vue";
import TenantPayment from "./Partials/TenantPayment.vue";
import TenantImpress from "./Partials/TenantImpress.vue";
import TenantGdpr from "./Partials/TenantGdpr.vue";
import TenantPaymentMethods from "./Partials/TenantPaymentMethods.vue";
const props = defineProps({
tenant: Object,
@@ -22,6 +23,11 @@ const tabs = [
component: TenantPayment,
endpoint: '/api/v1/admin/tenant/payment',
},
{
title: 'Zahlungswege',
component: TenantPaymentMethods,
endpoint: '/api/v1/admin/tenant/payment-methods',
},
{
title: 'Impressum',
component: TenantImpress,