Add logic/validation for cembra fields
This commit is contained in:
parent
b6e4f30b58
commit
42fd2f1377
|
|
@ -75,6 +75,13 @@ const setWithCompanyAddress = (value: boolean) => {
|
||||||
|
|
||||||
const withCembraInvoice = ref<boolean>(false);
|
const withCembraInvoice = ref<boolean>(false);
|
||||||
|
|
||||||
|
function toggleCembraInvoice() {
|
||||||
|
withCembraInvoice.value = !withCembraInvoice.value;
|
||||||
|
if (!withCembraInvoice.value) {
|
||||||
|
setWithCompanyAddress(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type FormErrors = {
|
type FormErrors = {
|
||||||
personal: string[];
|
personal: string[];
|
||||||
company: string[];
|
company: string[];
|
||||||
|
|
@ -119,6 +126,16 @@ function validateAddress() {
|
||||||
formErrors.value.personal.push(t("a.Land"));
|
formErrors.value.personal.push(t("a.Land"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (withCembraInvoice.value) {
|
||||||
|
if (!address.value.phone_number) {
|
||||||
|
formErrors.value.personal.push(t("a.Telefonnummer"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!address.value.birth_date) {
|
||||||
|
formErrors.value.personal.push(t("a.Geburtsdatum"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (withCompanyAddress.value) {
|
if (withCompanyAddress.value) {
|
||||||
if (!address.value.organisation_detail_name) {
|
if (!address.value.organisation_detail_name) {
|
||||||
formErrors.value.company.push(t("a.Name"));
|
formErrors.value.company.push(t("a.Name"));
|
||||||
|
|
@ -240,17 +257,29 @@ const executePayment = async () => {
|
||||||
</p>
|
</p>
|
||||||
<PersonalAddress v-model="address" />
|
<PersonalAddress v-model="address" />
|
||||||
|
|
||||||
|
<p v-if="formErrors.personal.length" class="mb-10 text-red-700">
|
||||||
|
{{ $t("a.Bitte folgende Felder ausfüllen") }}:
|
||||||
|
{{ formErrors.personal.join(", ") }}
|
||||||
|
</p>
|
||||||
|
|
||||||
<div class="flex flex-row items-center space-x-2 text-sm">
|
<div class="flex flex-row items-center space-x-2 text-sm">
|
||||||
<ItToggleSwitch
|
<ItToggleSwitch
|
||||||
data-cy="cembra-switch"
|
data-cy="cembra-switch"
|
||||||
:initially-switched-left="withCembraInvoice"
|
:initially-switched-left="withCembraInvoice"
|
||||||
@click="withCembraInvoice = !withCembraInvoice"
|
@click="toggleCembraInvoice()"
|
||||||
></ItToggleSwitch>
|
></ItToggleSwitch>
|
||||||
<span :class="{ 'text-gray-700': !withCembraInvoice }">
|
<span :class="{ 'text-gray-700': !withCembraInvoice }">
|
||||||
"TODO: Zahlung auf Rechnung/Cembra"
|
"TODO: Zahlung auf Rechnung/Cembra"
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<section v-if="withCembraInvoice">
|
||||||
|
<p class="mt-4">
|
||||||
|
TODO: Bei Zahlung auf Rechnung/Cembra, wird immer auf deine Privatadresse
|
||||||
|
verrechnet. Du musst zwinged deine Telefonnummer und Geburtsdatum angeben.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
<section v-else>
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
<button
|
<button
|
||||||
v-if="!withCompanyAddress"
|
v-if="!withCompanyAddress"
|
||||||
|
|
@ -298,6 +327,7 @@ const executePayment = async () => {
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
|
|
@ -313,7 +343,12 @@ const executePayment = async () => {
|
||||||
data-cy="continue-pay"
|
data-cy="continue-pay"
|
||||||
@click="executePayment"
|
@click="executePayment"
|
||||||
>
|
>
|
||||||
|
<template v-if="withCembraInvoice">
|
||||||
|
TODO: Mit Rechnung/Cembra bezahlen
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
{{ $t("a.Mit Kreditkarte bezahlen") }}
|
{{ $t("a.Mit Kreditkarte bezahlen") }}
|
||||||
|
</template>
|
||||||
<it-icon-arrow-right class="it-icon ml-2 h-6 w-6" />
|
<it-icon-arrow-right class="it-icon ml-2 h-6 w-6" />
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue