Skip to content

Commit

Permalink
fix: Disabled the place order button
Browse files Browse the repository at this point in the history
  • Loading branch information
acasazza committed May 12, 2022
1 parent 19175d7 commit 35754d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/PlaceOrderButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ const PlaceOrderButton: FunctionComponent<PlaceOrderButtonProps> = (props) => {
paymentType,
})
if (
(isFree ||
((isFree && isPermitted) ||
currentPaymentMethodRef?.current?.onsubmit ||
card.brand) &&
isPermitted
) {
setNotPermitted(false)
}
} else if (isFree) {
} else if (isFree && isPermitted) {
setNotPermitted(false)
} else {
setNotPermitted(true)
Expand Down
10 changes: 5 additions & 5 deletions src/reducers/PlaceOrderReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ export const placeOrderPermitted: PlaceOrderPermitted = async ({
isPermitted = localStorage.getItem('privacy-terms') === 'true'
}
const billingAddress = order.billing_address
if (isEmpty(billingAddress)) isPermitted = false
const shippingAddress = order.shipping_address
const doNotShip = isDoNotShip(order.line_items)
if (isEmpty(shippingAddress) && !doNotShip) isPermitted = false
const shipments = order.shipments
const shipment = shipments && shipmentsFilled(shipments)
if (!isEmpty(shipments) && !shipment) isPermitted = false
const paymentMethod = order.payment_method
const paymentSource = order.payment_source
// @ts-ignore
if (paymentSource?.mismatched_amounts) isPermitted = false
if (order.total_amount_with_taxes_cents !== 0 && isEmpty(paymentMethod?.id))
isPermitted = false
if (isEmpty(billingAddress)) isPermitted = false
if (isEmpty(shippingAddress) && !doNotShip) isPermitted = false
if (!isEmpty(shipments) && !shipment) isPermitted = false
// @ts-ignore
if (paymentSource?.mismatched_amounts) isPermitted = false
dispatch({
type: 'setPlaceOrderPermitted',
payload: {
Expand Down

0 comments on commit 35754d8

Please sign in to comment.