Skip to content

Commit

Permalink
Merge branch 'podkrepi-bg:master' into fix/typo-in-homepage-section-h…
Browse files Browse the repository at this point in the history
…eading
  • Loading branch information
spudoodle authored Dec 6, 2024
2 parents 8a53851 + f4384d8 commit 21f4b80
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ jobs:
name: playwright-report
path: ./frontend/e2e/test-results/
retention-days: 14
overwrite: true

- uses: actions/upload-artifact@v4
if: always()
Expand Down
2 changes: 1 addition & 1 deletion e2e/pages/web-pages/donation/donation.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class DonationPage extends CampaignsPage {
bgLocalizationValidation['informed-agree-with'] + ' ' + bgLocalizationValidation.gdpr
private readonly enPrivacyCheckboxText =
enLocalizationValidation['informed-agree-with'] + ' ' + enLocalizationValidation.gdpr
private readonly bgStripeErrorNoBalanceText = 'Картата Ви не разполага с достатъчно средства.'
private readonly bgStripeErrorNoBalanceText = 'В картата ви няма достатъчно средства. Опитайте с друга.'

async checkPageUrlByRegExp(urlRegExpAsString?: string, timeoutParam = 10000): Promise<void> {
await this.page.waitForTimeout(1000)
Expand Down
28 changes: 15 additions & 13 deletions src/components/client/donation-flow/DonationFlowForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ export const validationSchema: yup.SchemaOf<DonationFormData> = yup
export function DonationFlowForm() {
const formikRef = useRef<FormikProps<DonationFormData> | null>(null)
const { t } = useTranslation('donation-flow')
const { campaign, setupIntent, paymentError, setPaymentError, idempotencyKey } = useDonationFlow()
const stripe = useStripe()
const elements = useElements()
const router = useRouter()
const updateSetupIntentMutation = useUpdateSetupIntent()
const cancelSetupIntentMutation = useCancelSetupIntent()
const paymentMethodSectionRef = React.useRef<HTMLDivElement>(null)
const authenticationSectionRef = React.useRef<HTMLDivElement>(null)
const stripeChargeRef = React.useRef<string>(idempotencyKey)
const [showCancelDialog, setShowCancelDialog] = React.useState(false)
const [submitPaymentLoading, setSubmitPaymentLoading] = React.useState(false)
const { data: { user: person } = { user: null } } = useCurrentPerson()
const { data: session } = useSession({
required: false,
onUnauthenticated: () => {
Expand All @@ -117,17 +129,6 @@ export function DonationFlowForm() {
formikRef.current?.setFieldValue('email', '')
formikRef.current?.setFieldValue('isAnonymous', true, false)
}, [session])
const { campaign, setupIntent, paymentError, setPaymentError, idempotencyKey } = useDonationFlow()
const stripe = useStripe()
const elements = useElements()
const router = useRouter()
const updateSetupIntentMutation = useUpdateSetupIntent()
const cancelSetupIntentMutation = useCancelSetupIntent()
const paymentMethodSectionRef = React.useRef<HTMLDivElement>(null)
const authenticationSectionRef = React.useRef<HTMLDivElement>(null)
const [showCancelDialog, setShowCancelDialog] = React.useState(false)
const [submitPaymentLoading, setSubmitPaymentLoading] = React.useState(false)
const { data: { user: person } = { user: null } } = useCurrentPerson()

return (
<Formik
Expand Down Expand Up @@ -186,6 +187,7 @@ export function DonationFlowForm() {
return_url: `${window.location.origin}/${routes.campaigns.donationStatus(
campaign.slug,
)}`,
personId: !values.isAnonymous && session?.user && person?.id ? person.id : null,
},
},
})
Expand All @@ -197,7 +199,7 @@ export function DonationFlowForm() {
campaign,
values,
session,
idempotencyKey,
stripeChargeRef.current,
)
router.push(
`${window.location.origin}${routes.campaigns.donationStatus(campaign.slug)}?p_status=${
Expand All @@ -210,7 +212,7 @@ export function DonationFlowForm() {
type: 'invalid_request_error',
message: (error as StripeError).message ?? t('step.summary.alerts.error'),
})

stripeChargeRef.current = crypto.randomUUID()
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function AlertsColumn({
<>
{updatedRefArray.map((ref, index) => {
const alert = alerts[ref.current?.id as keyof typeof alerts]
if (!alert) return null
return <AnchoredAlert key={index} sectionRef={ref} {...alert} />
})}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type DonationContext = {
paymentError: StripeError | null
setPaymentError: React.Dispatch<React.SetStateAction<StripeError | null>>
campaign: CampaignResponse
stripe: StripeType | null
stripe: Promise<StripeType | null>
idempotencyKey: string
}

Expand Down
2 changes: 1 addition & 1 deletion src/service/stripeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const {
publicRuntimeConfig: { STRIPE_PUBLISHABLE_KEY },
} = getConfig()

export const stripe = await loadStripe(STRIPE_PUBLISHABLE_KEY)
export const stripe = loadStripe(STRIPE_PUBLISHABLE_KEY)

0 comments on commit 21f4b80

Please sign in to comment.