Skip to content

Commit 9934171

Browse files
Fix Stripe modal on short viewports (#20251)
* Fix Stripe modal on short viewports * Update components/dashboard/src/components/billing/AddPaymentMethodModal.tsx Co-authored-by: Aminur Rahman <[email protected]> --------- Co-authored-by: Aminur Rahman <[email protected]>
1 parent 538e66f commit 9934171

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

components/dashboard/src/components/Modal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,11 @@ export const ModalHeader: FC<ModalHeaderProps> = ({ children }) => {
182182

183183
type ModalBodyProps = {
184184
children: ReactNode;
185+
className?: string;
185186
hideDivider?: boolean;
186187
};
187188

188-
export const ModalBody: FC<ModalBodyProps> = ({ children, hideDivider = false }) => {
189+
export const ModalBody: FC<ModalBodyProps> = ({ children, hideDivider = false, className }) => {
189190
return (
190191
// Allows the first tabbable element in the body to receive focus on mount
191192
<AutoFocusInside
@@ -194,6 +195,7 @@ export const ModalBody: FC<ModalBodyProps> = ({ children, hideDivider = false })
194195
{
195196
"border-t border-b mt-2 py-4": !hideDivider,
196197
},
198+
className,
197199
)}
198200
>
199201
{children}

components/dashboard/src/components/billing/AddPaymentMethodModal.tsx

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import { useStripePromise } from "./use-stripe-promise";
1313
import { LoadingButton } from "@podkit/buttons/LoadingButton";
1414
import { useMutation } from "@tanstack/react-query";
1515
import { useStripeAppearance } from "./use-stripe-appearance";
16-
import DropDown from "../DropDown";
17-
import { useCurrency } from "../../payment-context";
16+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@podkit/select/Select";
17+
import { Currency, useCurrency } from "../../payment-context";
1818
import Alert from "../Alert";
1919

2020
type Props = {
@@ -58,6 +58,8 @@ function AddPaymentMethodForm({ attributionId }: { attributionId: string }) {
5858
const elements = useElements();
5959
const { currency, setCurrency } = useCurrency();
6060

61+
const currencySymbol = currency === "EUR" ? "€" : "$";
62+
6163
const confirmPayment = useMutation(async () => {
6264
const attrId = AttributionId.parse(attributionId);
6365
if (!stripe || !elements || !attrId) {
@@ -80,7 +82,7 @@ function AddPaymentMethodForm({ attributionId }: { attributionId: string }) {
8082
}
8183
} catch (error) {
8284
console.error("Unable to confirm payment method.", error);
83-
let message = error?.message || String(error) || "Unable to confirm your payment method.";
85+
const message = error?.message || String(error) || "Unable to confirm your payment method.";
8486
throw new Error(message);
8587
}
8688
});
@@ -94,11 +96,14 @@ function AddPaymentMethodForm({ attributionId }: { attributionId: string }) {
9496
);
9597

9698
return (
97-
<form onSubmit={handleSubmit}>
99+
<form
100+
onSubmit={handleSubmit}
101+
className="flex flex-col max-h-[calc(100dvh-3rem)] min-[576px]:max-h-[calc(100dvh-6rem)] overflow-hidden"
102+
>
98103
<ModalBody>
99104
<Alert type="message" className="mb-4">
100-
This card will be used for future charges. We'll be placing a 1.00 hold on it that we'll immediately
101-
release in order to verify your payment method.
105+
This card will be used for future charges. We'll be placing a {currencySymbol}1.00 hold on it that
106+
we'll immediately release in order to verify your payment method.
102107
</Alert>
103108
<PaymentElement id="payment-element" />
104109
<AddressElement id="address-element" options={{ mode: "billing", display: { name: "organization" } }} />
@@ -115,21 +120,20 @@ function AddPaymentMethodForm({ attributionId }: { attributionId: string }) {
115120
>
116121
<div className="flex items-center space-x-1">
117122
<span>Currency:</span>
118-
<DropDown
119-
customClasses="w-32"
120-
renderAsLink={true}
121-
activeEntry={currency}
122-
entries={[
123-
{
124-
title: "EUR",
125-
onClick: () => setCurrency("EUR"),
126-
},
127-
{
128-
title: "USD",
129-
onClick: () => setCurrency("USD"),
130-
},
131-
]}
132-
/>
123+
<Select
124+
value={currency}
125+
onValueChange={(currency) => {
126+
setCurrency(currency as Currency);
127+
}}
128+
>
129+
<SelectTrigger className="w-24">
130+
<SelectValue placeholder="Currency" />
131+
</SelectTrigger>
132+
<SelectContent>
133+
<SelectItem value="EUR">EUR</SelectItem>
134+
<SelectItem value="USD">USD</SelectItem>
135+
</SelectContent>
136+
</Select>
133137
</div>
134138
<LoadingButton type="submit" disabled={!stripe} loading={confirmPayment.isLoading}>
135139
Confirm

0 commit comments

Comments
 (0)