Skip to content

Commit d025200

Browse files
authored
Merge branch 'main' into feature/III-6948-event-preview-actions
2 parents 2853c8e + 0b20076 commit d025200

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/hooks/api/places.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ type GetPlacesByQueryArguments = {
235235
addressLocality?: string;
236236
addressCountry?: Country;
237237
streetAddress?: string;
238+
excludeId?: string;
238239
};
239240

240241
const getPlacesByQuery = async ({
@@ -246,6 +247,7 @@ const getPlacesByQuery = async ({
246247
addressCountry,
247248
streetAddress,
248249
searchTerm,
250+
excludeId,
249251
}: { headers: Headers } & GetPlacesByQueryArguments) => {
250252
const termsString = terms.reduce(
251253
(acc, currentTerm) => `${acc}terms.id:${currentTerm}`,
@@ -257,6 +259,7 @@ const getPlacesByQuery = async ({
257259
zip && addressCountry === 'BE' ? `address.\\*.postalCode:"${zip}"` : '',
258260
addressLocality ? `address.\\*.addressLocality:${addressLocality}` : '',
259261
streetAddress ? `address.\\*.streetAddress:"${streetAddress}"` : '',
262+
excludeId ? `NOT _id:"${excludeId}"` : '',
260263
].filter((argument) => !!argument);
261264

262265
const res = await fetchFromApi({
@@ -290,6 +293,7 @@ const useGetPlacesByQuery = (
290293
addressCountry,
291294
streetAddress,
292295
searchTerm,
296+
excludeId,
293297
}: GetPlacesByQueryArguments,
294298
configuration: ExtendQueryOptions<typeof getPlacesByQuery> = {},
295299
) =>
@@ -304,6 +308,7 @@ const useGetPlacesByQuery = (
304308
addressLocality,
305309
streetAddress,
306310
searchTerm,
311+
excludeId,
307312
},
308313
enabled: (!!name && !!streetAddress && !!zip) || !!searchTerm,
309314
...configuration,

src/utils/checkDuplicatePlace.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ export async function checkDuplicatePlace({
2020
location,
2121
name,
2222
}: Props) {
23+
const postalCode = ['NL', 'DE'].includes(location.country)
24+
? location.postalCode
25+
: location.municipality.zip;
26+
2327
const address: Address = {
2428
[i18n.language]: {
2529
streetAddress: location.streetAndNumber,
2630
addressCountry: location.country,
2731
addressLocality: location.municipality.name,
28-
postalCode: location.postalCode,
32+
postalCode,
2933
},
3034
};
3135

@@ -39,6 +43,7 @@ export async function checkDuplicatePlace({
3943
streetAddress: address[i18n.language].streetAddress,
4044
addressLocality: address[i18n.language].addressLocality,
4145
addressCountry: address[i18n.language].addressCountry,
46+
excludeId: offerId,
4247
});
4348

4449
const placeId = parseOfferId(places?.member?.[0]?.['@id'] ?? '');

0 commit comments

Comments
 (0)