Skip to content

Commit 1b779ae

Browse files
committed
feat: upgrade SDK and react-components
1 parent 8070fd8 commit 1b779ae

29 files changed

Lines changed: 1301 additions & 1954 deletions

File tree

components/composite/OrderSummary/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ export const OrderSummary: React.FC<Props> = ({ appCtx }) => {
8080
<RecapLine>
8181
<ShippingAmount>
8282
{(props) => {
83-
console.log(props)
84-
8583
if (!appCtx.isShipmentRequired) return <></>
8684
return (
8785
<>

components/composite/StepCustomer/AddressInputGroup/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const AddressInputGroup: React.FC<Props> = ({
6868

6969
const appCtx = useContext(AppContext)
7070

71-
let shippingCountryCodeLock = ""
71+
let shippingCountryCodeLock: string | undefined = ""
7272

7373
if (appCtx) {
7474
shippingCountryCodeLock = appCtx.shippingCountryCodeLock

components/composite/StepCustomer/BillingAddressFormNew/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ export const BillingAddressFormNew: React.FC<Props> = ({
4545
/>
4646
<AddressInputGroup
4747
fieldName="billing_address_line_2"
48-
resource="billingAddress"
48+
resource="billing_address"
4949
type="text"
50-
value={billingAddress?.line2 || ""}
50+
value={billingAddress?.line_2 || ""}
5151
/>
5252
<Grid>
5353
<AddressInputGroup

components/composite/StepCustomer/CheckoutCustomerAddresses.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,23 @@ export const CheckoutCustomerAddresses: React.FC<Props> = ({
8787
}
8888
}, [shipToDifferentAddress])
8989

90+
useEffect(() => {
91+
// temp fix to resolve flag bug
92+
if (showBillingAddressForm) {
93+
localStorage.setItem(
94+
"_save_billing_address_to_customer_address_book",
95+
"false"
96+
)
97+
}
98+
if (showShippingAddressForm) {
99+
localStorage.setItem(
100+
"_save_shipping_address_to_customer_address_book",
101+
"false"
102+
)
103+
}
104+
// --
105+
}, [showBillingAddressForm, showShippingAddressForm])
106+
90107
const handleScroll = (type: AddressTypeEnum) => {
91108
const tab = document
92109
.querySelector(`h3[data-cy="${type}-address"]`)

components/composite/StepCustomer/ShippingAddressFormNew/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export const ShippingAddressFormNew: React.FC<Props> = ({
3939

4040
<AddressInputGroup
4141
fieldName="shipping_address_line_2"
42-
resource="shippingAddress"
42+
resource="shipping_address"
4343
type="text"
44-
value={shippingAddress?.line2 || ""}
44+
value={shippingAddress?.line_2 || ""}
4545
/>
4646

4747
<Grid>

components/composite/StepPayment/CheckoutCustomerPayment.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
CustomerCardsTemplate,
2+
CustomerCardsType,
33
PaymentMethod,
44
PaymentSource,
55
} from "@commercelayer/react-components"
@@ -26,10 +26,14 @@ interface Props {
2626

2727
export const CheckoutCustomerPayment: React.FC<Props> = ({ refetchOrder }) => {
2828
const { t } = useTranslation()
29+
30+
// TemplateSaveToWalletCheckbox
31+
const [checked, setChecked] = useState(false)
32+
2933
const TemplateCustomerCards = ({
3034
customerPayments,
3135
PaymentSourceProvider,
32-
}: CustomerCardsTemplate) => {
36+
}: CustomerCardsType) => {
3337
return (
3438
<>
3539
{customerPayments.map((p, k) => {
@@ -53,7 +57,6 @@ export const CheckoutCustomerPayment: React.FC<Props> = ({ refetchOrder }) => {
5357
const TemplateSaveToWalletCheckbox = ({
5458
name,
5559
}: CustomerSaveToWalletProps) => {
56-
const [checked, setChecked] = useState(false)
5760
const handleClick = (
5861
e: MouseEvent<HTMLInputElement, globalThis.MouseEvent>
5962
) => e?.stopPropagation()

components/composite/StepPayment/PaymentContainer/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ export const PaymentContainer: React.FC = ({ children }) => {
7272
},
7373
},
7474
paypalPayment: {
75-
cancelUrl: `${window.location.href}&paymentReturn=true`,
76-
returnUrl: `${window.location.href}&paymentReturn=true`,
75+
cancel_url: `${window.location.href}&paymentReturn=true`,
76+
return_url: `${window.location.href}&paymentReturn=true`,
7777
infoMessage: {
7878
text: t("stepPayment.paypalDescription"),
7979
className: "text-sm text-gray-500",

components/composite/StepPayment/PaymentDetails/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ export const PaymentDetails: React.FC<Props> = ({ hasEditButton = false }) => {
4646
</div>
4747
{isCreditCard && (
4848
<div className="pl-10 text-gray-500 lg:pl-2">
49-
{t("stepPayment.expires")} <PaymentSourceDetail type="expMonth" />
49+
{t("stepPayment.expires")} <PaymentSourceDetail type="exp_month" />
5050
/
51-
<PaymentSourceDetail type="expYear" />
51+
<PaymentSourceDetail type="exp_year" />
5252
</div>
5353
)}
5454
</div>

components/composite/StepPlaceOrder/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ const StepPlaceOrder: React.FC<Props> = ({
9696
const handlePlaceOrder = async () => {
9797
setIsPlacingOrder(true)
9898
if (gtmCtx?.firePurchase && gtmCtx?.fireAddPaymentInfo) {
99-
gtmCtx.fireAddPaymentInfo()
100-
gtmCtx.firePurchase()
99+
await gtmCtx.fireAddPaymentInfo()
100+
await gtmCtx.firePurchase()
101101
}
102102
await refetchOrder()
103103
setIsPlacingOrder(false)

components/composite/StepShipping/index.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,12 @@ export const StepShipping: React.FC<Props> = () => {
117117

118118
const handleChange = (
119119
// eslint-disable-next-line @typescript-eslint/no-explicit-any
120-
shippingMethod: ShippingMethodCollection | Record<string, any>
120+
shippingMethod: ShippingMethodCollection | Record<string, any>,
121+
shipmentId: string
121122
): void => {
122123
setShipmentsSelected((shipmentsSelected) =>
123124
shipmentsSelected?.map((shipment) => {
124-
return shipment.shipmentId === shippingMethod.id
125+
return shipment.shipmentId === shipmentId
125126
? {
126127
...shipment,
127128
shippingMethodId: shippingMethod.id,
@@ -136,7 +137,7 @@ export const StepShipping: React.FC<Props> = () => {
136137
await refetchOrder()
137138
setIsLocalLoader(false)
138139
if (gtmCtx?.fireAddShippingInfo) {
139-
gtmCtx.fireAddShippingInfo()
140+
await gtmCtx.fireAddShippingInfo()
140141
}
141142
}
142143

@@ -193,26 +194,22 @@ export const StepShipping: React.FC<Props> = () => {
193194
<ShippingMethod emptyText={t("stepShipping.notAvaible")}>
194195
<ShippingSummary>
195196
<StyledShippingMethodRadioButton
196-
className="form-radio mt-0.5 md:mt-0"
197197
data-cy="shipping-method-button"
198-
onChange={(
199-
shippingMethod:
200-
| ShippingMethodCollection
201-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
202-
| Record<string, any>
203-
) => handleChange(shippingMethod)}
198+
className="form-radio mt-0.5 md:mt-0"
199+
onChange={(shippingMethod, shipmentId) =>
200+
handleChange(shippingMethod, shipmentId)
201+
}
204202
/>
205203
<ShippingMethodName data-cy="shipping-method-name">
206204
{(props) => {
207205
const deliveryLeadTime =
208206
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
209207
// @ts-ignore
210208
props?.deliveryLeadTimeForShipment
211-
console.log(props)
212209
return (
213210
<label
214211
className="flex flex-col p-3 border rounded cursor-pointer hover:border-primary transition duration-200 ease-in"
215-
// htmlFor={`shipment-${props.shippingMethod.id}-${props.shippingMethod.id}`}
212+
htmlFor={props.htmlFor}
216213
>
217214
<ShippingLineItemTitle>
218215
{props.label}

0 commit comments

Comments
 (0)