Skip to content

Commit 29a377f

Browse files
committed
Add a single payment method (bank transfer)
1 parent 41ae0da commit 29a377f

File tree

5 files changed

+58
-75
lines changed

5 files changed

+58
-75
lines changed

components/Checkout/Billing.component.jsx

Lines changed: 4 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -356,80 +356,14 @@ const Billing = ({ input, handleOnChange }) => {
356356
id="address1"
357357
/>
358358
<Error errors={input.errors} fieldName={'address1'} />
359-
</div>
359+
</div>
360360

361361
<div className="w-full p-2">
362-
<button className="flex px-8 py-2 mx-auto text-lg text-white bg-indigo-500 border-0 rounded focus:outline-none hover:bg-indigo-600">
363-
Button
362+
<button className="flex px-4 py-2 mx-auto font-bold bg-white border border-gray-400 border-solid rounded hover:bg-gray-400">
363+
BESTILL
364364
</button>
365365
</div>
366-
<div className="w-full p-2 pt-8 mt-8 text-center border-t border-gray-200">
367-
<a className="text-indigo-500">[email protected]</a>
368-
<p className="my-5 leading-normal">
369-
49 Smith St.
370-
<br />
371-
Saint Cloud, MN 56301
372-
</p>
373-
<span className="inline-flex">
374-
<a className="text-gray-500">
375-
<svg
376-
fill="currentColor"
377-
stroke-linecap="round"
378-
stroke-linejoin="round"
379-
stroke-width="2"
380-
className="w-5 h-5"
381-
viewBox="0 0 24 24"
382-
>
383-
<path d="M18 2h-3a5 5 0 00-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 011-1h3z"></path>
384-
</svg>
385-
</a>
386-
<a className="ml-4 text-gray-500">
387-
<svg
388-
fill="currentColor"
389-
stroke-linecap="round"
390-
stroke-linejoin="round"
391-
stroke-width="2"
392-
className="w-5 h-5"
393-
viewBox="0 0 24 24"
394-
>
395-
<path d="M23 3a10.9 10.9 0 01-3.14 1.53 4.48 4.48 0 00-7.86 3v1A10.66 10.66 0 013 4s-4 9 5 13a11.64 11.64 0 01-7 2c9 5 20 0 20-11.5a4.5 4.5 0 00-.08-.83A7.72 7.72 0 0023 3z"></path>
396-
</svg>
397-
</a>
398-
<a className="ml-4 text-gray-500">
399-
<svg
400-
fill="none"
401-
stroke="currentColor"
402-
stroke-linecap="round"
403-
stroke-linejoin="round"
404-
stroke-width="2"
405-
className="w-5 h-5"
406-
viewBox="0 0 24 24"
407-
>
408-
<rect
409-
width="20"
410-
height="20"
411-
x="2"
412-
y="2"
413-
rx="5"
414-
ry="5"
415-
></rect>
416-
<path d="M16 11.37A4 4 0 1112.63 8 4 4 0 0116 11.37zm1.5-4.87h.01"></path>
417-
</svg>
418-
</a>
419-
<a className="ml-4 text-gray-500">
420-
<svg
421-
fill="currentColor"
422-
stroke-linecap="round"
423-
stroke-linejoin="round"
424-
stroke-width="2"
425-
className="w-5 h-5"
426-
viewBox="0 0 24 24"
427-
>
428-
<path d="M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z"></path>
429-
</svg>
430-
</a>
431-
</span>
432-
</div>
366+
433367
</div>
434368
</div>
435369
</div>

components/Checkout/CheckoutForm.component.jsx

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@ import { useState, useContext, useEffect } from 'react';
22
import { useQuery, useMutation } from '@apollo/react-hooks';
33

44
import Billing from './Billing.component';
5+
import Payment from "./Payment.component";
56

67
import { GET_CART } from 'utils/const/GQL_QUERIES';
78
import { CHECKOUT_MUTATION } from 'utils/const/GQL_MUTATIONS';
89
import { INITIAL_STATE } from 'utils/const/INITIAL_STATE';
910

1011
import { AppContext } from 'utils/context/AppContext';
1112

12-
import { getFormattedCart } from 'utils/functions/functions';
13+
import {
14+
getFormattedCart,
15+
createCheckoutData,
16+
} from 'utils/functions/functions';
17+
18+
import validateAndSanitizeCheckoutForm from 'utils/validator/checkoutValidator';
1319

1420
const CheckoutForm = () => {
1521
const [cart, setCart] = useContext(AppContext);
@@ -101,11 +107,27 @@ const CheckoutForm = () => {
101107
<Billing input={input} handleOnChange={handleOnChange} />
102108
</div>
103109

110+
{/*Payment*/}
111+
<div className="">
112+
<Payment input={ input } handleOnChange={ handleOnChange }/>
113+
</div>
114+
115+
<div>
116+
<button
117+
className="px-4 py-2 font-bold bg-white border border-gray-400 border-solid rounded hover:bg-gray-400"
118+
type="submit"
119+
>
120+
BESTILL
121+
</button>
122+
</div>
123+
104124
{/* Checkout Loading*/}
105-
{checkoutLoading && <p>Behandler ordre ...</p>}
106-
{requestError && (
107-
<p>Feilmelding: {requestError} :( Vennligst prøv igjen.)</p>
108-
)}
125+
{
126+
//checkoutLoading && <p>Behandler ordre ...</p>
127+
}
128+
{
129+
//requestError && <p>Feilmelding: {requestError} </p>
130+
}
109131
</div>
110132
</form>
111133
) : (
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const Payment = ({ input, handleOnChange }) => {
2+
return (
3+
<div className="mt-3">
4+
<label className="form-check-label">
5+
<input
6+
onChange={handleOnChange}
7+
value="bacs"
8+
className="form-check-input"
9+
name="paymentMethod"
10+
type="radio"
11+
/>
12+
<span className="woo-next-payment-content">Direkte bankoverføring</span>
13+
</label>
14+
</div>
15+
);
16+
};
17+
18+
export default Payment;

utils/functions/functions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { v4 } from 'uuid';
2+
13
/**
24
* Convert price from string to floating value and convert it to use two decimals
35
* @param {String} string

utils/validator/checkoutValidator.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const validateAndSanitizeCheckoutForm = (data) => {
2+
return {
3+
isValid: true,
4+
};
5+
};
6+
7+
export default validateAndSanitizeCheckoutForm;

0 commit comments

Comments
 (0)