Skip to content

Commit

Permalink
Further code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mislam987 committed Sep 17, 2024
1 parent db0e251 commit 7967a12
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ coverage
build/Release
node_modules
.emails
.vscode
4 changes: 2 additions & 2 deletions components/postcode-lookup/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module.exports = {
TOWN_OR_CITY_LABEL: 'Town or city',
POSTCODE_MANUAL_LABEL: 'Postcode',
POSTCODE_ERROR: {
'not-found': 'Sorry – we couldn’t find any addresses for that postcode, enter your address manually',
'cant-connect': 'Sorry – we couldn’t connect to the postcode lookup service at this time, enter your address manually'
'error-heading': 'Sorry, there is a problem with the postcode search',
'lookup-problem-title': 'Address lookup problem - GOV.UK'
},
NO_ADDRESS_HEADING: 'No address found',
ENTER_MANUALLY: 'Enter address manually',
Expand Down
12 changes: 2 additions & 10 deletions components/postcode-lookup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ module.exports = config => {
req.query.step = req.query.step || 'postcode';
const subSteps = getConfig(addressFieldNamePrefix);
const step = subSteps[req.query.step];
// console.log("REQ.TRANSLATE: " + req.translate);
_.merge(req.form.options, {
subSteps,
addressKey: addressFieldNamePrefix,
Expand Down Expand Up @@ -253,7 +252,7 @@ module.exports = config => {
manualAddressParagraph: conditionalTranslate('pages.address-lookup.manual-address-paragraph', req.translate) ||
defaults.MANUAL_ADDRESS_PARAGRAPH,
searchErrorHeading: conditionalTranslate('pages.postcode-search-problem.searchErrorHeading', req.translate) ||
defaults.SEARCH_ERROR_HEADING,
defaults.POSTCODE_ERROR['error-heading'],
postcodeEntered: sessionPostcode,
addressesExist: (req.sessionModel.get(`${addressFieldNamePrefix}-addresses`) !== undefined &&
req.sessionModel.get(`${addressFieldNamePrefix}-addresses`).length > 0) ? true : false,
Expand All @@ -267,7 +266,7 @@ module.exports = config => {
addressDetailsTitle: conditionalTranslate('pages.address-details.title', req.translate) ||
defaults.ADDRESS_DETAILS_TITLE,
lookupProblemTitle: conditionalTranslate('pages.address-lookup-problem.title', req.translate) ||
defaults.ADDRESS_LOOKUP_PROBLEM_TITLE,
defaults.POSTCODE_ERROR['lookup-problem-title'],
route: this.options.route,
editLink,
cantFind,
Expand All @@ -276,19 +275,12 @@ module.exports = config => {
});
}

// getAddresses(enteredPostcode, apiURL, apiKey) {
// return axios.get(apiURL + "?postcode=" + enteredPostcode + '&key=' + apiKey);
// }

async postcode(req, res, callback) {
// Clear the value stored in the addresses radio button group
req.sessionModel.set(`${addressFieldNamePrefix}-select`, '');
// Call OS Places API to return list of addresses by postcode
const enteredPostcode = req.form.values[`${addressFieldNamePrefix}-postcode`];

// axios.get(apiURL + '?postcode=' + enteredPostcode + '&key=' + apiKey)
// this.getAddresses(enteredPostcode, apiURL, apiKey)

await PostcodeLookup(enteredPostcode, apiURL, apiKey)
.then(function (response) {
if(response.data) {
Expand Down
1 change: 0 additions & 1 deletion config/hof-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const defaults = {
return convertPage(page);
}
},
deIndexForm: process.env.DEINDEX_FORM || 'false',
gaCrossDomainTrackingTagId: process.env.GDS_CROSS_DOMAIN_GA_TAG,
loglevel: process.env.LOG_LEVEL || 'info',
ignoreMiddlewareLogs: ['/healthz'],
Expand Down
2 changes: 0 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const router = require('./lib/router');
const health = require('./lib/health');
const serveStatic = require('./lib/serve-static');
const gaTagSetup = require('./lib/ga-tag');
const deIndexer = require('./lib/deindex');
const sessionStore = require('./lib/sessions');
const settings = require('./lib/settings');
const defaults = require('./config/hof-defaults');
Expand Down Expand Up @@ -199,7 +198,6 @@ function bootstrap(options) {
serveStatic(app, config);
settings(app, config);
gaTagSetup(app, config);
deIndexer(app, config);

const sessions = sessionStore(app, config);
app.use('/healthz', health(sessions));
Expand Down

0 comments on commit 7967a12

Please sign in to comment.