UNPKG

@commercelayer/react-components

Version:
2 lines 875 B
"use client"; import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import OrderContext from"../../context/OrderContext";import{manageGiftCard}from"../../utils/adyen/manageGiftCard";import BaseOrderPrice from"../utils/BaseOrderPrice";export function GiftCardAmount(props){const{managePaymentProviderGiftCards,order}=useContext(OrderContext);if(managePaymentProviderGiftCards){const giftCardData=manageGiftCard({order});if(!giftCardData)return null;const parentProps={priceCents:giftCardData.currentBalanceValue,price:`-${giftCardData?.formattedBalanceValue}`,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...props,children:`-${giftCardData?.formattedBalanceValue}`})}return _jsx(BaseOrderPrice,{base:"amount",type:"gift_card",...props})}export default GiftCardAmount;