Skip to content

Commit cc0b8dd

Browse files
committed
Add basic billing component
1 parent 0d85951 commit cc0b8dd

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const Billing = ({ input, handleOnChange }) => {
2+
return (
3+
<>
4+
{/* Name */}
5+
<div>Billing</div>
6+
</>
7+
);
8+
};
9+
10+
export default Billing;

components/Checkout/CheckoutForm.component.jsx

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useState, useContext, useEffect } from 'react';
22
import { useQuery, useMutation } from '@apollo/react-hooks';
33

4+
import Billing from './Billing.component';
5+
46
import { GET_CART } from 'utils/const/GQL_QUERIES';
57
import { CHECKOUT_MUTATION } from 'utils/const/GQL_MUTATIONS';
68
import { INITIAL_STATE } from 'utils/const/INITIAL_STATE';
@@ -64,6 +66,23 @@ const CheckoutForm = () => {
6466
setRequestError(null);
6567
};
6668

69+
/*
70+
* Handle onChange input.
71+
*
72+
* @param {Object} event Event Object.
73+
*
74+
* @return {void}
75+
*/
76+
const handleOnChange = (event) => {
77+
if ('createAccount' === event.target.name) {
78+
const newState = { ...input, [event.target.name]: !input.createAccount };
79+
setInput(newState);
80+
} else {
81+
const newState = { ...input, [event.target.name]: event.target.value };
82+
setInput(newState);
83+
}
84+
};
85+
6786
useEffect(() => {
6887
if (null !== orderData) {
6988
// Perform checkout mutation when the value for orderData changes.
@@ -74,9 +93,23 @@ const CheckoutForm = () => {
7493
return (
7594
<>
7695
{cart ? (
77-
<form onSubmit={handleFormSubmit} className="woo-next-checkout-form">
78-
<div className="row">Skjema kommer her</div>
79-
</form>
96+
<div className="container mx-auto">
97+
<form onSubmit={handleFormSubmit} className="">
98+
<div className="">
99+
{/*Payment Details*/}
100+
<div className="">
101+
<h2 className="">Betalingsdetaljer</h2>
102+
<Billing input={input} handleOnChange={handleOnChange} />
103+
</div>
104+
105+
{/* Checkout Loading*/}
106+
{checkoutLoading && <p>Behandler ordre ...</p>}
107+
{requestError && (
108+
<p>Feilmelding: {requestError} :( Vennligst prøv igjen.</p>
109+
)}
110+
</div>
111+
</form>
112+
</div>
80113
) : (
81114
''
82115
)}

0 commit comments

Comments
 (0)