Skip to content

Commit

Permalink
Change first donation form section summary behaviour
Browse files Browse the repository at this point in the history
- When there is no payment type passed to the donation form, the summary only shows the data that is already there
- When selecting a payment type, the summary reflects that

Ticket: https://phabricator.wikimedia.org/T368527
  • Loading branch information
Sperling-0 committed Sep 13, 2024
1 parent 320f06e commit 7d699ab
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions src/components/pages/donation_form/PaymentSummary.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
<template>
<div class="payment-summary">
<div class="payment-summary-text">
<p v-html="getSummary()"/>
<p v-html="props.paymentType ? summary : summaryWithoutPaymentType"/>
</div>
<div class="payment-summary-link">
<a href="#" @click.prevent="$emit( 'previous-page' )">{{ $t('donation_form_section_back') }}</a>
</div>
</div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent( {
name: 'PaymentSummary',
props: [ 'amount', 'interval', 'paymentType' ],
methods: {
getSummary: function () {
const interval = this.$t( 'donation_form_payment_interval_' + this.$props.interval );
const formattedAmount = this.$n( this.$props.amount, { key: 'currency', currencyDisplay: 'name' } );
const paymentType = this.$t( this.$props.paymentType );
return this.$t( 'donation_form_payment_summary', { interval: interval, formattedAmount, paymentType } );
},
},
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { computed } from 'vue';
interface Props {
amount: number;
interval: string;
paymentType?: string;
}
const { t, n } = useI18n();
const props = withDefaults( defineProps<Props>(), { paymentType: '' } );
const summary = computed( () => {
const interval = t( 'donation_form_payment_interval_' + props.interval );
const formattedAmount = n( props.amount, { key: 'currency', currencyDisplay: 'name' } );
const paymentType = t( props.paymentType );
return t( 'donation_form_payment_summary', { interval, formattedAmount, paymentType } );
} );
const summaryWithoutPaymentType = computed( () => {
const interval = t( 'donation_form_payment_interval_' + props.interval );
const formattedAmount = n( props.amount, { key: 'currency', currencyDisplay: 'name' } );
return t( 'donation_form_payment_summary_payment_type_missing', { interval, formattedAmount } );
} );
</script>

<style lang="scss">
Expand Down

0 comments on commit 7d699ab

Please sign in to comment.