Add the new prop in PaymentMethodOptions comp: Code Block |
---|
| function PaymentMethodOptions({
// .. rest of the file
setIsPaycometNewMethodSelected
}: PaymentMethodOptionProps) {
const enableNewMethod = useFlag(LaunchDarklyFlag.ENABLE_CREDIT_CARD_AT_HOME_PAYCOMET); // new line
}); |
Add new condition in handleUnselectedMethodClick , handleAddNewCardOptionClick , handleAddNewGiftCardOptionClick , handlePaypalOptionClick and handleAdyenIdealOptionClick to clear our new state: Code Block |
---|
| if (setIsPaycometSodexoOptionSelected) {
setIsPaycometNewMethodSelected('');
} |
Add a new handle for our new method (using useCallback) where we’ll clear the other methods and set your: Code Block |
---|
| const handleNewMethodOptionClick = useCallback(
(e: React.FormEvent<HTMLButtonElement>, newMethodType: string) => {
e.preventDefault();
setIsAddNewCardOptionSelected(false);
setIsAddNewGiftCardOptionSelected(false);
if (setIsPaycometPaypalOptionSelected) {
setIsPaycometPaypalOptionSelected(false);
}
if (setIsAdyenIdealOptionSelected) {
setIsAdyenIdealOptionSelected(false);
}
if (setIsAdyenBlikOptionSelected) {
setIsAdyenBlikOptionSelected(false);
}
if (setIsPaycometSodexoOptionSelected) {
setIsPaycometSodexoOptionSelected('');
}
if (setIsPaycometSodexoOptionSelected) {
setIsPaycometSodexoOptionSelected('');
}
// our new method here
if (setIsPaycometNewMethodSelected) {
setIsPaycometNewMethodSelected(newMethodType);
if (newMethodType === 'card') {
setIsAddNewCardOptionSelected(true);
}
}
handleSelect();
setCollapsed(true);
},
[
// callback dependencies here
]
); |
Add in the enableSortPaymentMethods && unSelectedMethods.map a new block for our new method: Code Block |
---|
| const isDelivery = serverOrder?.delivery;
{method?.newMethod && method?.transient && isDelivery && (
<StyledOption>
<PaymentMethodOptionItemDivider />
<PaymentMethodAddNewItemOption
data-testid="add-new-method-payment"
text={formatMessage({ id: newMethodLabel(isGuestOrder) })}
Icon={<StyledNewMethodCardIcon />}
onClick={e => handleNewMethodOptionClick(e, 'card')}
isLoading={isLoadingPopup}
/>
</StyledOption>
)} |
Add a new block for for the case where we not have the enableSortPaymentMethods as true: Code Block |
---|
| {!enableSortPaymentMethods && enableNewMethod && (
<StyledOption>
<PaymentMethodOptionItemDivider />
<PaymentMethodAddNewItemOption
data-testid=add-new-method-payment"
text={formatMessage({ id: newMethodLabel(isGuestOrder) })}
Icon={<StyledNewMethodCardIcon />}
onClick={e => handleNewMethodOptionClick(e, 'card')}
isLoading={isLoadingPopup}
/>
</StyledOption>
)} |
Add the new payment method in |