Skip to content

Commit

Permalink
fix: Cannot read property 'map'
Browse files Browse the repository at this point in the history
  • Loading branch information
acasazza committed Dec 13, 2021
1 parent 8c6bd7c commit 378d77d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/components/PlaceOrderButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ const PlaceOrderButton: FunctionComponent<PlaceOrderButtonProps> = (props) => {
order,
])
useEffect(() => {
if (paymentType === 'paypal_payments' && options?.paypalPayerId) {
debugger
if (
paymentType === 'paypal_payments' &&
options?.paypalPayerId &&
order?.status &&
['draft', 'pending'].includes(order?.status)
) {
handleClick()
}
}, [options?.paypalPayerId])
Expand Down
1 change: 0 additions & 1 deletion src/reducers/PaymentMethodReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ export const setPaymentMethod: SetPaymentMethod = async ({
// const attrs: any = {
// order: sdk.orders.relationship(order.id),
// }
// debugger
// const paymentSource = await sdk[paymentResource].create(attrs)
// dispatch({
// type: 'setPaymentMethods',
Expand Down
5 changes: 0 additions & 5 deletions src/reducers/PlaceOrderReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ export const setPlaceOrder: SetPlaceOrder = async ({
window.location.href = paymentSource?.approval_url as string
return response
}
console.log(`order`, order)
console.log(`paymentSource`, paymentSource)
debugger
await sdk.paypal_payments.update({
id: paymentSource.id,
paypal_payer_id: options?.paypalPayerId,
Expand Down Expand Up @@ -188,8 +185,6 @@ export const setPlaceOrder: SetPlaceOrder = async ({
}
return response
} catch (error) {
console.log(`error`, error)
debugger
const errors = getErrors(error, 'orders')
setOrderErrors && setOrderErrors(errors)
return {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function getErrors(
error: any,
resource: ResourceErrorType
): BaseError[] {
return error.errors.map((e: any) => {
return error?.errors?.map((e: any) => {
return { ...e, resource }
})
}
Expand Down
1 change: 0 additions & 1 deletion src/utils/getPrices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export default function getPrices<P extends Price>(prices: P[]) {
})
}
// else {
// debugger
// // forEach(prices, (item) => {
// // const prices = item.prices()?.toArray()
// // obj[item.code] = prices
Expand Down

0 comments on commit 378d77d

Please sign in to comment.