From 3a6ee307cd89670af4bba5f791b3b74886f2f921 Mon Sep 17 00:00:00 2001 From: Jonathan Bourdon Date: Thu, 24 Apr 2025 13:55:26 -0400 Subject: [PATCH] feat: Add new payment completion and failure routes, update donation handling in DonationForm and related components --- frontend/src/router/router.js | 20 +-- frontend/src/stores/brandingStore.js | 6 +- frontend/src/views/PaymentCompleted.vue | 9 +- frontend/src/views/PaymentFailed.vue | 8 +- frontend/src/views/creators/BannerActions.vue | 4 +- frontend/src/views/creators/CreatorLayout.vue | 3 +- .../src/views/creators/DonationButton.vue | 2 +- .../src/views/creators/DonationDialog.vue | 138 +----------------- frontend/src/views/creators/DonationForm.vue | 94 +++++++++++- 9 files changed, 120 insertions(+), 164 deletions(-) diff --git a/frontend/src/router/router.js b/frontend/src/router/router.js index b4d87d6..c41c776 100644 --- a/frontend/src/router/router.js +++ b/frontend/src/router/router.js @@ -35,6 +35,16 @@ const routes = [ path: '', name: 'creator', component: CreatorHome, + }, + { + path: 'tip-completed', + name: 'PaymentCompleted', + component: PaymentCompleted, + }, + { + path: 'tip-cancelled', + name: 'PaymentFailed', + component: PaymentFailed, } ], }, @@ -85,16 +95,6 @@ const routes = [ component: LoginView, meta: { notAuthenticated: true }, }, - { - path: '/paymentcompleted/:creatorId', - name: 'PaymentCompleted', - component: PaymentCompleted, - }, - { - path: '/paymentfailed/:creatorId', - name: 'PaymentFailed', - component: PaymentFailed, - }, { path: '/profile', name: 'profile', diff --git a/frontend/src/stores/brandingStore.js b/frontend/src/stores/brandingStore.js index b240e3e..165ee95 100644 --- a/frontend/src/stores/brandingStore.js +++ b/frontend/src/stores/brandingStore.js @@ -22,7 +22,11 @@ export const useBrandingStore = defineStore( watch( () => route.params.creator, async (creator) => { - await updateBrand(creator); + console.log(`creator: ${creator}`) + // Extract just the creator name from the path (remove any additional segments) + const creatorName = creator ? creator.split('/')[0] : undefined; + console.log(`name: ${creatorName}`) + await updateBrand(creatorName); } ) diff --git a/frontend/src/views/PaymentCompleted.vue b/frontend/src/views/PaymentCompleted.vue index ebb9743..a18a5fd 100644 --- a/frontend/src/views/PaymentCompleted.vue +++ b/frontend/src/views/PaymentCompleted.vue @@ -52,12 +52,9 @@ const route = useRoute(); const { t } = useI18n(); function goBack() { - const returnUrl = route.query.returnUrl; - if (returnUrl) { - router.push(returnUrl); - } else { - router.back(); - } + // Navigate back to the creator's page + const creatorName = route.params.creator?.split('/')[0] || ''; + router.push(`/@${creatorName}`); } diff --git a/frontend/src/views/PaymentFailed.vue b/frontend/src/views/PaymentFailed.vue index 425f2c3..8cb4b3f 100644 --- a/frontend/src/views/PaymentFailed.vue +++ b/frontend/src/views/PaymentFailed.vue @@ -21,12 +21,8 @@ const route = useRoute(); const { t } = useI18n(); function goBack() { - const returnUrl = route.query.returnUrl; - if (returnUrl) { - router.push(returnUrl); - } else { - router.back(); - } + const creatorName = route.params.creator?.split('/')[0] || ''; + router.push(`/@${creatorName}`); } diff --git a/frontend/src/views/creators/BannerActions.vue b/frontend/src/views/creators/BannerActions.vue index 64bbf49..78120f0 100644 --- a/frontend/src/views/creators/BannerActions.vue +++ b/frontend/src/views/creators/BannerActions.vue @@ -42,8 +42,8 @@ const {t} = useI18n(); v-if="brandingStore.value?.acceptDonation" :creator-id="brandingStore.value?.id" :creator-name="brandingStore.value?.name" - :on-cancelled-url="baseURL + '/paymentfailed/' + brandingStore.value?.id" - :on-success-url="baseURL + '/paymentcompleted/' + brandingStore.value?.id" + :on-cancelled-url="baseURL + '/@' + brandingStore.value.slug + '/tip-cancelled'" + :on-success-url="baseURL + '/@' + brandingStore.value.slug + '/tip-completed'" /> diff --git a/frontend/src/views/creators/CreatorLayout.vue b/frontend/src/views/creators/CreatorLayout.vue index 3ad1d4f..ca434b7 100644 --- a/frontend/src/views/creators/CreatorLayout.vue +++ b/frontend/src/views/creators/CreatorLayout.vue @@ -7,10 +7,11 @@ import ActualBanner from "@/views/creators/ActualBanner.vue"; import BannerActions from "@/views/creators/BannerActions.vue"; const brandingStore = useBrandingStore(); -const creatorName = window.location.pathname.split('/@').pop(); +const creatorName = window.location.pathname.split('/@')[1]?.split('/')[0] || ''; const { t } = useI18n(); onMounted(async () => { + console.log(`creatorName: ${creatorName}`) await brandingStore.updateBrand(creatorName); }); diff --git a/frontend/src/views/creators/DonationButton.vue b/frontend/src/views/creators/DonationButton.vue index da7b34d..42d9eee 100644 --- a/frontend/src/views/creators/DonationButton.vue +++ b/frontend/src/views/creators/DonationButton.vue @@ -7,7 +7,7 @@ {{ t('creator.donation.isupport') }} - - - - - - - - - -{ - "en": { - "common": { - "cancel": "Cancel" - }, - "creator": { - "donation": { - "errors": { - "payment": "An error occurred during payment processing" - } - } - } - }, - "fr": { - "common": { - "cancel": "Annuler" - }, - "creator": { - "donation": { - "errors": { - "payment": "Une erreur s'est produite lors du traitement du paiement" - } - } - } - }, - "es": { - "common": { - "cancel": "Cancelar" - }, - "creator": { - "donation": { - "errors": { - "payment": "Ocurrió un error durante el procesamiento del pago" - } - } - } - } -} - \ No newline at end of file + \ No newline at end of file diff --git a/frontend/src/views/creators/DonationForm.vue b/frontend/src/views/creators/DonationForm.vue index 33b7d26..a01d648 100644 --- a/frontend/src/views/creators/DonationForm.vue +++ b/frontend/src/views/creators/DonationForm.vue @@ -33,6 +33,8 @@ clearable auto-grow > + +
{{ errorMessage }}
@@ -43,8 +45,10 @@
@@ -53,13 +57,27 @@ + + { "en": { @@ -89,7 +158,12 @@ function preventNonNumeric(event) { "isupport": "I Support", "amount": "Amount ($)", "message": "Message (optional)", - "send": "Send" + "send": "Send", + "processing": "Processing...", + "errors": { + "payment": "An error occurred during payment processing", + "invalidAmount": "Please enter a valid amount" + } } } }, @@ -102,7 +176,12 @@ function preventNonNumeric(event) { "isupport": "Je Soutiens", "amount": "Montant ($)", "message": "Message (optionnel)", - "send": "Envoyer" + "send": "Envoyer", + "processing": "Traitement en cours...", + "errors": { + "payment": "Une erreur s'est produite lors du traitement du paiement", + "invalidAmount": "Veuillez entrer un montant valide" + } } } }, @@ -115,7 +194,12 @@ function preventNonNumeric(event) { "isupport": "Apoyo", "amount": "Cantidad ($)", "message": "Mensaje (opcional)", - "send": "Enviar" + "send": "Enviar", + "processing": "Procesando...", + "errors": { + "payment": "Ocurrió un error durante el procesamiento del pago", + "invalidAmount": "Por favor ingrese un monto válido" + } } } }