Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ export const LargePaymentMethodSelect = () => {
export const SmallPaymentMethodSelect = () => {
const methods = usePaymentMethods();
const {primaryColor} = useConfigContext();
const {showMorePaymentMethods, setShowMorePaymentMethods} =
useWidgetContext();

const [showMore, setShowMore] = useState(false);
if (methods.length === 1) {
return null;
}
Expand All @@ -200,19 +201,19 @@ export const SmallPaymentMethodSelect = () => {
{methods.slice(0, 4).map((method) => (
<PaymentMethodListItem key={method} small method={method} />
))}
{showMore &&
{showMorePaymentMethods &&
methods
.slice(4)
.map((method) => (
<PaymentMethodListItem key={method} small method={method} />
))}
</ul>
{!showMore && (
{!showMorePaymentMethods && (
<button
type="button"
className={showMoreButtonCss(primaryColor)}
onClick={() => {
setShowMore(true);
setShowMorePaymentMethods(true);
}}
>
More options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ interface WidgetContextProps {
selectedPaymentMethod: PaymentMethod;
setSelectedPaymentMethod: StateUpdater<PaymentMethod>;

showMorePaymentMethods: boolean;
setShowMorePaymentMethods: StateUpdater<boolean>;

stockAmount?: number;
setStockAmount: StateUpdater<number | undefined>;

Expand Down Expand Up @@ -80,6 +83,9 @@ export const WidgetContextProvider: FunctionalComponent<{hide: () => void}> = ({
}
}, [config.methods, selectedPaymentMethod]);

const [showMorePaymentMethods, setShowMorePaymentMethods] =
useState<boolean>(false);

const [stockAmount, setStockAmount] = useState<number>();
const [stockSymbol, setStockSymbol] = useState<string>();

Expand Down Expand Up @@ -107,6 +113,8 @@ export const WidgetContextProvider: FunctionalComponent<{hide: () => void}> = ({
setSubmitError,
selectedPaymentMethod,
setSelectedPaymentMethod,
showMorePaymentMethods,
setShowMorePaymentMethods,
stockAmount,
setStockAmount,
stockSymbol,
Expand Down