Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #598 from beabee-communityrm/fix/join-form-recursion
Browse files Browse the repository at this point in the history
fix: separate payment content out
  • Loading branch information
JumpLink authored May 16, 2024
2 parents 3de2652 + 5f7ab0b commit 1935c7b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
4 changes: 3 additions & 1 deletion src/components/contribution/Contribution.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import ContributionMethod from './ContributionMethod.vue';
import { type ContributionContent } from './contribution.interface';
import { useI18n } from 'vue-i18n';
import AppChoice from '../forms/AppChoice.vue';
import type { ContentPaymentData } from '@type/content-payment-data';

const props = withDefaults(
defineProps<{
Expand All @@ -63,6 +64,7 @@ const props = withDefaults(
payFee: boolean;
paymentMethod: PaymentMethod;
content: ContributionContent;
paymentContent: ContentPaymentData;
showPeriod?: boolean;
showPaymentMethod?: boolean;
disabled?: boolean;
Expand All @@ -73,7 +75,7 @@ const props = withDefaults(
const { t } = useI18n();

const fee = computed(() =>
calcPaymentFee(props, props.content.payment.stripeCountry)
calcPaymentFee(props, props.paymentContent.stripeCountry)
);

const emit = defineEmits([
Expand Down
6 changes: 2 additions & 4 deletions src/components/contribution/contribution.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ContentJoinData, ContentPaymentData } from '@type';
import type { ContentJoinData } from '@type';

export type ContributionContent = Pick<
ContentJoinData,
Expand All @@ -8,6 +8,4 @@ export type ContributionContent = Pick<
| 'showAbsorbFee'
| 'periods'
| 'paymentMethods'
> & {
payment: ContentPaymentData;
};
>;
3 changes: 2 additions & 1 deletion src/components/pages/join/JoinForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
v-model:period="signUpData.period"
v-model:payFee="signUpData.payFee"
v-model:paymentMethod="signUpData.paymentMethod"
:content="{ ...joinContent, payment: paymentContent }"
:content="joinContent"
:payment-content="paymentContent"
:disabled="signUpData.noContribution"
>
<AppCheckbox
Expand Down
10 changes: 6 additions & 4 deletions src/components/pages/profile/contribution/UpdateContribution.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
v-model:period="newContribution.period"
v-model:paymentMethod="newContribution.paymentMethod"
:content="content"
:payment-content="paymentContent"
:show-period="showChangePeriod"
:show-payment-method="!isAutoActiveMember"
/>
Expand Down Expand Up @@ -65,10 +66,10 @@
</AppButton>

<p
v-if="content.payment.taxRateEnabled"
v-if="paymentContent.taxRateEnabled"
class="-mt-2 mb-4 text-center text-sm"
>
{{ t('join.tax.included', { taxRate: content.payment.taxRate }) }}
{{ t('join.tax.included', { taxRate: paymentContent.taxRate }) }}
</p>
</form>

Expand All @@ -83,7 +84,7 @@
</AppHeading>
<StripePayment
:client-secret="stripeClientSecret"
:public-key="content.payment.stripePublicKey"
:public-key="paymentContent.stripePublicKey"
:email="email"
:return-url="startContributionCompleteUrl"
@loaded="onStripeLoaded"
Expand Down Expand Up @@ -124,7 +125,7 @@ import { isRequestError } from '@utils/api';
import { addNotification } from '@store/notifications';
import type { ContributionInfo } from '@type';
import type { ContentPaymentData, ContributionInfo } from '@type';
const validation = useVuelidate();
Expand All @@ -134,6 +135,7 @@ const emit = defineEmits(['update:modelValue']);
const props = defineProps<{
modelValue: ContributionInfo;
content: ContributionContent;
paymentContent: ContentPaymentData;
}>();
const newContribution = reactive({
Expand Down
27 changes: 13 additions & 14 deletions src/pages/profile/contribution/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ meta:
<UpdateContribution
v-model="contribution"
:content="content"
:payment-content="paymentContent"
class="mb-7 md:mb-9"
/>

Expand All @@ -47,7 +48,7 @@ meta:
class="mb-7 md:mb-9"
:email="email"
:payment-source="contribution.paymentSource"
:stripe-public-key="content.payment.stripePublicKey"
:stripe-public-key="paymentContent.stripePublicKey"
/>
<ContactCancelContribution
id="me"
Expand Down Expand Up @@ -88,7 +89,7 @@ import AppNotification from '@components/AppNotification.vue';
import { currentUser } from '@store';
import type { ContributionInfo } from '@type';
import { type ContentPaymentData, type ContributionInfo } from '@type';
const { t } = useI18n();
const route = useRoute();
Expand All @@ -106,12 +107,13 @@ const content = ref<ContributionContent>({
periods: [],
showAbsorbFee: true,
paymentMethods: [PaymentMethod.StripeCard],
payment: {
stripePublicKey: '',
stripeCountry: 'eu',
taxRate: 0,
taxRateEnabled: false,
},
});
const paymentContent = ref<ContentPaymentData>({
stripePublicKey: '',
stripeCountry: 'eu',
taxRate: 0,
taxRateEnabled: false,
});
const email = computed(() =>
Expand All @@ -126,13 +128,10 @@ const contribution = ref<ContributionInfo>({
onBeforeMount(async () => {
isIniting.value = true;
const joinContent = await fetchContent('join');
const paymentContent = await fetchContent('payment');
content.value = {
...joinContent,
payment: paymentContent,
};
content.value = await fetchContent('join');
paymentContent.value = await fetchContent('payment');
contribution.value = await fetchContribution();
isIniting.value = false;
});
Expand Down

0 comments on commit 1935c7b

Please sign in to comment.