Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync costco figo changes to develop #295

Merged
merged 16 commits into from
Nov 27, 2024
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions scripts/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,26 @@ function buildConfigURL(environment) {
return configURL;
}

function getValueFromData(configJSON, configParam) {
const configElements = JSON.parse(configJSON).data;
return configElements.find((c) => c.key === configParam)?.value;
}

/**
* @param {string} environment - leave empty to auto calculate the environment
* @returns - configuration (key,value) pairs of the environment as configured in configs.json
*/
export const getConfigForEnvironment = async (environment) => {
const env = (!environment) ? calcEnvironment() : environment;
let configJSON = window.sessionStorage.getItem(`config:${env}`);

if (configJSON) {
const foundPetUrl = getValueFromData(configJSON, 'found-pet-endpoint');
if (!foundPetUrl.includes('proxy')) {
configJSON = null;
}
}

if (!configJSON) {
const configURL = buildConfigURL(env);
const response = await fetch(configURL);
Expand Down
Loading