Skip to content

Commit

Permalink
chore: Show human readable error if not logged in for rec donation
Browse files Browse the repository at this point in the history
  • Loading branch information
sashko9807 committed Dec 9, 2024
1 parent e20f14e commit 0e4851a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions public/locales/bg/donation-flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
}
},
"alerts": {
"subscription-unauthorized": "За да продължите с ежемесечното дарение, моля влезте в акаунта си, или се регистрирайте, ако все още нямате такъв",
"error": "Нещо се обърка, моля опитайте пак или презаредете страницата"
},
"total": "Общо"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/en/donation-flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@
"title": "Transaction",
"description": "The transaction is only to compensate the transfer and is calculated based on your method of payment. \"Podkrepi.bg\" works with 0% commission."
},
"alerts": {
"subscription-unauthorized": "In order to continue with recurring payment, please login with your account or create new one if you havent done so",
"error": "Something went wrong, please try again or refresh the page"
},
"total": "Total",
"field": {
"anonymous": {
Expand Down
9 changes: 9 additions & 0 deletions src/components/client/donation-flow/DonationFlowForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ export function DonationFlowForm() {
return
}

if (values.mode === 'subscription' && !session?.user?.sub) {
setSubmitPaymentLoading(false)
formikRef.current?.setFieldError(
'authentication',
t('step.summary.alerts.subscription-unauthorized'),
)
return
}

// Update the setup intent with the latest calculated amount
try {
const updatedIntent = await updateSetupIntentMutation.mutateAsync({
Expand Down

0 comments on commit 0e4851a

Please sign in to comment.