Skip to content

Commit

Permalink
Updated orders-row and payment-form
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhish-nayak committed Aug 5, 2023
1 parent 47cea1e commit 5d32b67
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/components/orders-row/orders-row.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const OrderRow: React.FC<OrderRowType> = ({ order, index, method, status }) => {
))}
</td>
<td>{calculateTotalPrice(order)}</td>
<td>{method.toUpperCase()}</td>
<td className={status === "successful" ? "successful" : "failed"}>
{status.toUpperCase()}
</td>
Expand Down
16 changes: 5 additions & 11 deletions src/components/payment-form/payment-form.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const PaymentForm = () => {
dispatch(setOrder(cartItems));
};

const setUserPayment = (method: string, status: string) => {
dispatch(setPaymentDetails({ method, status }));
const setUserPayment = (status: string) => {
dispatch(setPaymentDetails({ status }));
};

const paymentHandler = async (event: React.MouseEvent<HTMLButtonElement>) => {
Expand Down Expand Up @@ -61,19 +61,13 @@ const PaymentForm = () => {
},
});

console.log(payment);
const myPaymentStatus = payment.data.items[0]?.status;
if (myPaymentStatus) {
const myPaymentStatus = payment.status;
if (myPaymentStatus === 200) {
setUserOrder();
setUserPayment("successful");
} else {
console.log("PAYMENT FAILED");
}

const { method, status } = payment.data.items[0];
setUserPayment(
method,
status === "captured" ? "successful" : "failed"
);
},

prefill: {
Expand Down
1 change: 0 additions & 1 deletion src/store/orders/orders.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export type OrdersType = {
}[];

export type PaymentDetailsType = {
method: string;
status: string;
};

Expand Down

0 comments on commit 5d32b67

Please sign in to comment.