generalize CMS order invoice payment panel for multi-crypto invoices.

This commit is contained in:
2026-09-06 16:07:44 +02:00
parent 35052661f8
commit 7640f5d74d
5 changed files with 23 additions and 20 deletions
@@ -8,14 +8,12 @@
</el-descriptions-item>
<el-descriptions-item label="Expected total">
<span class="mono"
>{{ invoice.expectedTotalCrypto }} {{ paymentMethodCryptoCurrency[invoice.paymentMethod] }}</span
>
<span class="mono">{{ invoice.expectedTotalCrypto }} {{ invoice.paymentLabel }}</span>
</el-descriptions-item>
<el-descriptions-item v-if="fiatPerXmrAtCreation !== undefined" :label="`Rate at ${rateLabel}`">
{{ formatFiatPrice(fiatPerXmrAtCreation, config.shopFiatCurrency) }} /
{{ paymentMethodCryptoCurrency[invoice.paymentMethod] }}
<el-descriptions-item v-if="fiatPerCryptoAtCreation !== undefined" :label="`Rate at ${rateLabel}`">
{{ formatFiatPrice(fiatPerCryptoAtCreation, config.shopFiatCurrency) }} /
{{ invoice.paymentLabel }}
</el-descriptions-item>
</el-descriptions>
@@ -37,9 +35,7 @@
<el-table-column label="Amount" width="140">
<template #default="{ row }">
<span class="mono"
>{{ row.amountCrypto }} {{ paymentMethodCryptoCurrency[invoice.paymentMethod] }}</span
>
<span class="mono">{{ row.amountCrypto }} {{ invoice.paymentLabel }}</span>
</template>
</el-table-column>
@@ -69,7 +65,7 @@
import { computed, type PropType } from 'vue';
import { config } from '@/config';
import type { InvoiceExtended } from '@/types/payment/InvoiceExtended';
import { paymentMethodCryptoCurrency } from '@/types/payment/PaymentMethod';
import { PaymentMethod } from '@/types/payment/PaymentMethod';
import { formatDate } from '@/utils/formatDate';
import { formatFiatPrice } from '@/utils/formatFiatPrice';
import { resolveInvoiceStatusTagType } from '@/utils/order/resolveInvoiceStatusTagType';
@@ -85,13 +81,25 @@ const props = defineProps({
},
emptyText: {
type: String,
default: 'No Monero payment session.'
default: 'No payment session.'
}
});
const payments = computed(() => props.invoice?.payments ?? []);
const fiatPerXmrAtCreation = computed(() => props.invoice?.moneroDetails?.fiatPerXmrAtCreation);
const fiatPerCryptoAtCreation = computed(() => {
const invoice = props.invoice;
if (!invoice) {
return undefined;
}
if (invoice.paymentMethod === PaymentMethod.Btc) {
return invoice.btcDetails?.fiatPerBtcAtCreation;
}
return invoice.moneroDetails?.fiatPerXmrAtCreation;
});
</script>
<style scoped>
@@ -53,10 +53,9 @@
</el-descriptions>
<template v-if="order.shippingInvoice">
<order-monero-payment-panel
<order-invoice-payment-panel
:invoice="order.shippingInvoice"
rate-label="quote"
empty-text="Shipping payment session not created yet."
/>
</template>
+1 -1
View File
@@ -4,7 +4,7 @@
<span>Order payment</span>
</template>
<order-monero-payment-panel
<order-invoice-payment-panel
:invoice="order.checkoutInvoice"
rate-label="checkout"
empty-text="No checkout payment session."
+1
View File
@@ -4,6 +4,7 @@ import type { InvoiceStatusLabel } from './InvoiceStatusLabel';
export type InvoiceExtended = Omit<Invoice, 'payments'> & {
statusLabel: InvoiceStatusLabel | null;
paymentLabel: string;
expectedTotalCrypto: string;
payments: InvoicePaymentExtended[];
};
-5
View File
@@ -2,8 +2,3 @@ export enum PaymentMethod {
Xmr = 'xmr',
Btc = 'btc'
}
export const paymentMethodCryptoCurrency: Record<PaymentMethod, string> = {
[PaymentMethod.Xmr]: 'XMR',
[PaymentMethod.Btc]: 'BTC'
};