Skip to content

Commit

Permalink
refactor code as in comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mitre10 committed Nov 20, 2024
1 parent e74459a commit 1f78bbe
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 25 deletions.
12 changes: 5 additions & 7 deletions scripts/commerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,12 @@ query($sku: String!) {

export async function commerceEndpointWithQueryParams() {
// Set Query Parameters so they can be appended to the endpoint
const queryParameters = new URLSearchParams();
queryParameters.append('Magento-Environment-Id', await getConfigValue('commerce-environment-id'));
queryParameters.append('Magento-Website-Code', await getConfigValue('commerce-website-code'));
queryParameters.append('Magento-Store-View-Code', await getConfigValue('commerce-store-view-code'));
queryParameters.append('Magento-Store-Code', await getConfigValue('commerce-store-code'));
queryParameters.append('Magento-Customer-Group', await getConfigValue('commerce-customer-group'));
const urlWithQueryParams = new URL(await getConfigValue('commerce-endpoint'));
urlWithQueryParams.search = queryParameters.toString();
urlWithQueryParams.searchParams.append('Magento-Environment-Id', await getConfigValue('commerce-environment-id'));
urlWithQueryParams.searchParams.append('Magento-Website-Code', await getConfigValue('commerce-website-code'));
urlWithQueryParams.searchParams.append('Magento-Store-View-Code', await getConfigValue('commerce-store-view-code'));
urlWithQueryParams.searchParams.append('Magento-Store-Code', await getConfigValue('commerce-store-code'));
urlWithQueryParams.searchParams.append('Magento-Customer-Group', await getConfigValue('commerce-customer-group'));
return urlWithQueryParams;
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions tools/picker/dist/index.96de328f.css

This file was deleted.

1 change: 0 additions & 1 deletion tools/picker/dist/index.96de328f.css.map

This file was deleted.

2 changes: 1 addition & 1 deletion tools/picker/dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Franklin Picker</title><link rel="stylesheet" href="index.96de328f.css"></head><body> <div id="app"></div> <script type="module" src="index.515784d0.js"></script> </body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>EDS Picker</title><link rel="stylesheet" href="index.96de328f.css"></head><body> <div id="app"></div> <script type="module" src="index.56bd2c76.js"></script> </body></html>
16 changes: 6 additions & 10 deletions tools/picker/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,12 @@ async function performCatalogServiceQuery(query, config, variables) {
};

// Set Query Parameters so they can be appended to the endpoint
const queryParameters = new URLSearchParams();
queryParameters.append('Magento-Environment-Id', config['commerce-environment-id']);
queryParameters.append('Magento-Website-Code', config['commerce-website-code']);
queryParameters.append('Magento-Store-View-Code', config['commerce-store-view-code']);
queryParameters.append('Magento-Store-Code',config['commerce-store-code']);
queryParameters.append('Magento-Customer-Group', config['commerce-customer-group']);
const urlWithQueryParams = new URL(config['commerce-endpoint']);
urlWithQueryParams.search = queryParameters.toString()

const apiCall = urlWithQueryParams;
const apiCall = new URL(config['commerce-endpoint']);
apiCall.searchParams.append("Magento-Environment-Id", config['commerce-environment-id']);
apiCall.searchParams.append("Magento-Website-Code", config['commerce-website-code']);
apiCall.searchParams.append("Magento-Store-View-Code", config['commerce-store-view-code']);
apiCall.searchParams.append("Magento-Store-Code", config['commerce-store-code']);
apiCall.searchParams.append("Magento-Customer-Group", config['commerce-customer-group']);
apiCall.searchParams.append('query', query.replace(/(?:\r\n|\r|\n|\t|[\s]{4})/g, ' ')
.replace(/\s\s+/g, ' '));
apiCall.searchParams.append('variables', variables ? JSON.stringify(variables) : null);
Expand Down

0 comments on commit 1f78bbe

Please sign in to comment.