Skip to content

Commit bc565e0

Browse files
committed
Add countries endpoint and data
1 parent 1da3545 commit bc565e0

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

pages/checkout.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
import Layout from '../src/components/layout';
2-
import { HEADER_FOOTER_ENDPOINT } from '../src/utils/constants/endpoints';
2+
import {
3+
HEADER_FOOTER_ENDPOINT,
4+
WOOCOMMERCE_COUNTRIES_ENDPOINT,
5+
} from '../src/utils/constants/endpoints';
36
import axios from 'axios';
47
import CheckoutForm from '../src/components/checkout/checkout-form';
58

6-
export default function Checkout({ headerFooter }) {
9+
export default function Checkout({ headerFooter, countries }) {
710
return (
811
<Layout headerFooter={headerFooter || {}}>
912
<h1>Checkout</h1>
10-
<CheckoutForm countriesData={null}/>
13+
<CheckoutForm countriesData={countries}/>
1114
</Layout>
1215
);
1316
}
1417

1518
export async function getStaticProps() {
1619

1720
const { data: headerFooterData } = await axios.get( HEADER_FOOTER_ENDPOINT );
18-
21+
const { data: countries } = await axios.get( WOOCOMMERCE_COUNTRIES_ENDPOINT );
22+
1923
return {
2024
props: {
2125
headerFooter: headerFooterData?.data ?? {},
26+
countries: countries || {}
2227
},
2328

2429
/**

src/components/checkout/form-elements/input-field.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import PropTypes from 'prop-types';
33
import Abbr from "./abbr";
44

55
const InputField = ({ handleOnChange, inputValue, name, type, label, errors, placeholder, required, containerClassNames, isShipping }) => {
6-
6+
77
const inputId = `${name}-${isShipping ? 'shipping' : ''}`;
8-
8+
99
console.log( 'inputValue', inputValue );
10-
10+
1111
return (
1212
<div className={containerClassNames}>
1313
<label className="leading-7 text-sm text-gray-700" htmlFor={inputId}>

src/utils/constants/endpoints.js

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ export const GET_PRODUCTS_ENDPOINT = `${process.env.NEXT_PUBLIC_SITE_URL}/api/ge
66
* @type {string}
77
*/
88
export const CART_ENDPOINT = `${process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL}/wp-json/rae/v1/cart/items/`;
9+
10+
// Countries
11+
export const WOOCOMMERCE_COUNTRIES_ENDPOINT = `${process.env.NEXT_PUBLIC_WORDPRESS_SITE_URL}/wp-json/rae/v1/wc/countries/`;

0 commit comments

Comments
 (0)