thm-p3-configurator 0.0.204 → 0.0.205
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -101,56 +101,6 @@ class AddressLookupService {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
/**
|
|
105
|
-
* @description Mock lookup for development/demo (returns mock data for common postcodes)
|
|
106
|
-
* @param {string} postcode - The Dutch postcode
|
|
107
|
-
* @param {string|number} houseNumber - The house number
|
|
108
|
-
* @returns {Promise<{street: string, city: string} | null>} - Address information or null if not found
|
|
109
|
-
*/
|
|
110
|
-
async lookupAddressMock(postcode, houseNumber) {
|
|
111
|
-
const cleanPostcode = postcode.replace(/\s/g, '').toUpperCase();
|
|
112
|
-
const mockData = {
|
|
113
|
-
'1012JS': {
|
|
114
|
-
street: 'Dam',
|
|
115
|
-
city: 'Amsterdam'
|
|
116
|
-
},
|
|
117
|
-
'2511CS': {
|
|
118
|
-
street: 'Binnenhof',
|
|
119
|
-
city: 'Den Haag'
|
|
120
|
-
},
|
|
121
|
-
'3011AD': {
|
|
122
|
-
street: 'Coolsingel',
|
|
123
|
-
city: 'Rotterdam'
|
|
124
|
-
},
|
|
125
|
-
'3512JE': {
|
|
126
|
-
street: 'Oudegracht',
|
|
127
|
-
city: 'Utrecht'
|
|
128
|
-
},
|
|
129
|
-
'9712CP': {
|
|
130
|
-
street: 'Grote Markt',
|
|
131
|
-
city: 'Groningen'
|
|
132
|
-
},
|
|
133
|
-
'5611AG': {
|
|
134
|
-
street: 'Stratumseind',
|
|
135
|
-
city: 'Eindhoven'
|
|
136
|
-
},
|
|
137
|
-
'6511LN': {
|
|
138
|
-
street: 'Grote Markt',
|
|
139
|
-
city: 'Nijmegen'
|
|
140
|
-
},
|
|
141
|
-
'4811CE': {
|
|
142
|
-
street: 'Grote Markt',
|
|
143
|
-
city: 'Breda'
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
147
|
-
const addressInfo = mockData[cleanPostcode] || null;
|
|
148
|
-
if (addressInfo) {
|
|
149
|
-
console.log("Mock address lookup for ".concat(cleanPostcode, ": ").concat(addressInfo.street, ", ").concat(addressInfo.city));
|
|
150
|
-
}
|
|
151
|
-
return addressInfo;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
104
|
/**
|
|
155
105
|
* @description Main lookup method that tries PDOK API first, then fallback to mock data
|
|
156
106
|
* @param {string} postcode - The Dutch postcode
|
|
@@ -168,17 +118,13 @@ class AddressLookupService {
|
|
|
168
118
|
let result = null;
|
|
169
119
|
try {
|
|
170
120
|
result = await this.lookupAddressPDOK(postcode, houseNumber);
|
|
121
|
+
console.log('looking up address with PDOK');
|
|
171
122
|
if (result) {
|
|
172
123
|
return result;
|
|
173
124
|
}
|
|
174
125
|
} catch (error) {
|
|
175
126
|
console.warn('PDOK lookup failed, using mock data...');
|
|
176
127
|
}
|
|
177
|
-
try {
|
|
178
|
-
result = await this.lookupAddressMock(postcode, houseNumber);
|
|
179
|
-
} catch (error) {
|
|
180
|
-
console.warn('Mock lookup failed');
|
|
181
|
-
}
|
|
182
128
|
return result;
|
|
183
129
|
}
|
|
184
130
|
|