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

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openedx-unsupported/frontend-app-ecommerce
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d103cf0368cf085a7944efeb7c3646ee7091f4a9
Choose a base ref
..
head repository: openedx-unsupported/frontend-app-ecommerce
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7d738fce079675bd42e3ea301dc4dd30ad943121
Choose a head ref
Showing with 25 additions and 41 deletions.
  1. +1 −0 .env
  2. +2 −1 .env.development
  3. +2 −1 .env.test
  4. +14 −1 src/order-history/OrderHistoryPage.jsx
  5. +6 −38 src/order-history/service.js
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ SITE_NAME=''
MARKETING_SITE_BASE_URL=''
SUPPORT_URL=''
ORDER_HISTORY_URL=''
RECEIPT_URL=''
LOGO_URL=''
LOGO_TRADEMARK_URL=''
LOGO_WHITE_URL=''
3 changes: 2 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -17,7 +17,8 @@ LANGUAGE_PREFERENCE_COOKIE_NAME=openedx-language-preference
SITE_NAME=localhost
MARKETING_SITE_BASE_URL=http://localhost:18000
SUPPORT_URL=http://localhost:18000/support
ORDER_HISTORY_URL=http://localhost:1996/orders
ORDER_HISTORY_URL=''
RECEIPT_URL=''
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
3 changes: 2 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
@@ -17,7 +17,8 @@ LANGUAGE_PREFERENCE_COOKIE_NAME=openedx-language-preference
SITE_NAME=localhost
MARKETING_SITE_BASE_URL=http://localhost:18000
SUPPORT_URL=http://localhost:18000/support
ORDER_HISTORY_URL=https://localhost:1996/orders
ORDER_HISTORY_URL=''
RECEIPT_URL=''
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
15 changes: 14 additions & 1 deletion src/order-history/OrderHistoryPage.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { getConfig } from '@edx/frontend-platform';
import { getConfig, mergeConfig } from '@edx/frontend-platform';
import {
injectIntl,
intlShape,
@@ -19,6 +19,19 @@ import messages from './OrderHistoryPage.messages';
import { fetchOrders } from './actions';
import { pageSelector } from './selectors';

/**
* TEMPORARY
*
* Until we add the following keys in frontend-platform,
* use mergeConfig to join it with the rest of the config items
* (so we don't need to get it separately from process.env).
* After we add the keys to frontend-platform, this mergeConfig can go away
*/
mergeConfig({
ORDER_HISTORY_URL: process.env.ORDER_HISTORY_URL,
RECEIPT_URL: process.env.RECEIPT_URL,
});

class OrderHistoryPage extends React.Component {
constructor(props) {
super(props);
44 changes: 6 additions & 38 deletions src/order-history/service.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,27 @@
/* eslint-disable no-console */
// NOTE: console logs are intentionally added for REV-2577

import { getAuthenticatedHttpClient, getAuthenticatedUser } from '@edx/frontend-platform/auth';
import { getConfig } from '@edx/frontend-platform';

const { ECOMMERCE_BASE_URL } = getConfig();
const { ORDER_HISTORY_URL, RECEIPT_URL, ECOMMERCE_BASE_URL } = getConfig();

const ECOMMERCE_API_BASE_URL = `${ECOMMERCE_BASE_URL}/api/v2`;
const ECOMMERCE_RECEIPT_BASE_URL = `${ECOMMERCE_BASE_URL}/checkout/receipt/`;
const ECOMMERCE_RECEIPT_BASE_URL = RECEIPT_URL
? `${RECEIPT_URL}` : `${ECOMMERCE_BASE_URL}/checkout/receipt/`;
const ECOMMERCE_ORDERS_URL = ORDER_HISTORY_URL
? `${ORDER_HISTORY_URL}` : `${ECOMMERCE_API_BASE_URL}/orders/`;

// eslint-disable-next-line import/prefer-default-export
export async function getOrders(page = 1, pageSize = 20) {
const httpClient = getAuthenticatedHttpClient();
const { username } = getAuthenticatedUser();
const { COMMERCE_COORDINATOR_BASE_URL } = getConfig();
const orderFetchingUrl = `${COMMERCE_COORDINATOR_BASE_URL}/orders/order_history/`;

// [START] TEMPORARY CODE for rollout testing/confirmation===========
// Call ecommerce for order info including waffle flag
let { data } = await httpClient.get(`${ECOMMERCE_API_BASE_URL}/orders/`, {
const { data } = await httpClient.get(`${ECOMMERCE_ORDERS_URL}`, {
params: {
username,
page,
page_size: pageSize,
},
});

let callCC = false;
if (data.count > 0) {
callCC = data.results[0].enable_hoist_order_history;
}

if (callCC) {
// REV-2577: enable_hoist_order_history flag is on, about to call commerce-coordinator
const newData = await httpClient.get(orderFetchingUrl, {
params: {
username,
page,
page_size: pageSize,
},
});
data = newData.data;
}
// [END] TEMPORARY CODE for rollout testing/confirmation===========

// @TODO: after we've confirmed the above works in prod, we can replace with this:
// let { data } = await httpClient.get(orderFetchingUrl, {
// params: {
// username,
// page,
// page_size: pageSize,
// },
// });
// data = newData.data;

const transformedResults = data.results.map(({
total_excl_tax, // eslint-disable-line camelcase
lines,