Skip to content

Commit

Permalink
Merge pull request #6 from TourConnect/fix/bms_link
Browse files Browse the repository at this point in the history
Set the BMS UI link - show based on the endpoint (stage or prod)
  • Loading branch information
shintre authored Jul 16, 2024
2 parents 0f170ab + 45bc1c6 commit 6babc3c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ const EQUIPMENT_FIELD_IDS = {
LARGEKIDSBIKE: 1006,
}

// const endpoint = 'https://bmsstage.bonzabiketours.com:3001/octo/v1/';

const CONCURRENCY = 3; // is this ok ?

const isNilOrEmpty = R.either(R.isNil, R.isEmpty);
Expand Down Expand Up @@ -361,6 +359,11 @@ class Plugin {
assert(R.path(['surname'], holder), 'a holder\' surname is required');
assert(R.path(['emailAddress'], holder), 'a holder\' email is required');

let uiEndPoint = "https://bms.bonzabiketours.com/";
if (endpoint.includes("bmsstage")) {
uiEndPoint = "https://bmsstage.bonzabiketours.com/";
}

const inputDataForBooking = await jwt.verify(availabilityKey, this.jwtKey);
console.log("OPTION ID: " + inputDataForBooking.optionId);

Expand Down Expand Up @@ -586,8 +589,9 @@ class Plugin {
headers,
}));

console.log("booking: " + JSON.stringify(booking));
// console.log("booking: " + JSON.stringify(booking));

// console.log("uiEndPoint: " + uiEndPoint);
// Get the booking
let newBooking = R.path(['data'], await axios({
method: 'get',
Expand All @@ -599,6 +603,7 @@ class Plugin {
booking: await translateBooking({
rootValue: {
...newBooking,
uiEndPoint
},
typeDefs: bookingTypeDefs,
query: bookingQuery,
Expand Down Expand Up @@ -696,6 +701,11 @@ class Plugin {
apiKey: apiKey,
});

let uiEndPoint = "https://bms.bonzabiketours.com/";
if (endpoint.includes("bmsstage")) {
uiEndPoint = "https://bmsstage.bonzabiketours.com/";
}

const bookingsFound = await (async () => {
if (!isNilOrEmpty(bookingId)) {
console.log("BookingID: calling search by URL");
Expand Down Expand Up @@ -767,6 +777,7 @@ class Plugin {
return translateBooking({
rootValue: {
...booking,
uiEndPoint
// product,
// option: product.options.find(o => o.optionId === booking.optionId),
},
Expand Down
2 changes: 1 addition & 1 deletion resolvers/booking.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const resolvers = {
// optionName: ({ option }) => option ? option.internalName : '',
// resellerReference: R.propOr('', 'id'),
privateUrl: root => {
return `https://bmsstage.bonzabiketours.com/purchases/edit-tour/${root.id}`
return `${root.uiEndPoint}purchases/edit-tour/${root.id}`
},
},
};
Expand Down

0 comments on commit 6babc3c

Please sign in to comment.