Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 39d0d42

Browse files
author
Diane Kaplan
committed
fix: test logic to call commerce-coordinator
1 parent 796aa7f commit 39d0d42

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ NODE_ENV='production'
22
BASE_URL=''
33
LMS_BASE_URL=''
44
CREDENTIALS_BASE_URL=''
5+
COMMERCE_COORDINATOR_BASE_URL=''
56
ECOMMERCE_BASE_URL=''
67
LOGIN_URL=''
78
LOGOUT_URL=''

.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ NODE_ENV=development
33
BASE_URL=localhost:1996
44
LMS_BASE_URL=http://localhost:18000
55
CREDENTIALS_BASE_URL=http://localhost:18150
6+
COMMERCE_COORDINATOR_BASE_URL=http://localhost:8140
67
ECOMMERCE_BASE_URL=http://localhost:18130
78
LOGIN_URL=http://localhost:18000/login
89
LOGOUT_URL=http://localhost:18000/login

.env.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ NODE_ENV=development
33
BASE_URL=localhost:1996
44
LMS_BASE_URL=http://localhost:18000
55
CREDENTIALS_BASE_URL=http://localhost:18150
6+
COMMERCE_COORDINATOR_BASE_URL=http://localhost:8140
67
ECOMMERCE_BASE_URL=http://localhost:18130
78
LOGIN_URL=http://localhost:18000/login
89
LOGOUT_URL=http://localhost:18000/login

src/order-history/service.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,50 @@
11
import { getAuthenticatedHttpClient, getAuthenticatedUser } from '@edx/frontend-platform/auth';
2-
import { getConfig } from '@edx/frontend-platform';
2+
import { getConfig, initialize, mergeConfig } from '@edx/frontend-platform';
33

44
const { ECOMMERCE_BASE_URL } = getConfig();
5+
6+
// Temporary: until we add COMMERCE_COORDINATOR_BASE_URL in frontend-platform, use mergeConfig to join it
7+
// with the rest of the config items (so we don't need to get it separately from process.env). After we add
8+
// it to frontend-platform, we'll be able to set it like ECOMMERCE_BASE_URL above, and block below can go away.
9+
initialize({
10+
handlers: {
11+
config: () => {
12+
mergeConfig({
13+
COMMERCE_COORDINATOR_BASE_URL: process.env.COMMERCE_COORDINATOR_BASE_URL || null,
14+
});
15+
},
16+
},
17+
});
18+
519
const ECOMMERCE_API_BASE_URL = `${ECOMMERCE_BASE_URL}/api/v2`;
620
const ECOMMERCE_RECEIPT_BASE_URL = `${ECOMMERCE_BASE_URL}/checkout/receipt/`;
721

822
// eslint-disable-next-line import/prefer-default-export
923
export async function getOrders(page = 1, pageSize = 20) {
1024
const httpClient = getAuthenticatedHttpClient();
1125
const { username } = getAuthenticatedUser();
26+
const { COMMERCE_COORDINATOR_BASE_URL } = getConfig();
1227

13-
const { data } = await httpClient.get(`${ECOMMERCE_API_BASE_URL}/orders/`, {
28+
// @@TODO: replace with real waffle when that's available
29+
const callEcommerce = true; // <- false makes it call commerce-coordinator
30+
let orderFetchingUrl = null;
31+
if (callEcommerce) {
32+
orderFetchingUrl = `${ECOMMERCE_API_BASE_URL}/orders/`;
33+
} else {
34+
orderFetchingUrl = `${COMMERCE_COORDINATOR_BASE_URL}/orders/ecommerce/`;
35+
}
36+
37+
const { data } = await httpClient.get(orderFetchingUrl, {
1438
params: {
1539
username,
1640
page,
1741
page_size: pageSize,
1842
},
1943
});
2044

45+
console.log('DKTEMP: orderFetchingUrl', orderFetchingUrl);
46+
console.log('DKTEMP: data service.js', data);
47+
2148
const transformedResults = data.results.map(({
2249
total_excl_tax, // eslint-disable-line camelcase
2350
lines,

0 commit comments

Comments
 (0)