@localazy/strapi-plugin 0.1.16 → 0.1.18

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localazy/strapi-plugin",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "The official Strapi Plugin by Localazy.",
5
5
  "strapi": {
6
6
  "name": "localazy",
@@ -41,6 +41,14 @@ describe("parsed-localazy-entry-to-update-entry.js", () => {
41
41
  const expected = {
42
42
  id: 24,
43
43
  title: "Pro každý den v roce",
44
+ used_in_restaurants: [
45
+ {
46
+ id: 1,
47
+ },
48
+ {
49
+ id: 3,
50
+ },
51
+ ],
44
52
  author_name: "David V.",
45
53
  pages: 365,
46
54
  recipes: [
@@ -159,6 +159,9 @@ describe("populate-create-update-entry-with-base-entry.js", () => {
159
159
  cuisine: "Thai",
160
160
  capacity: 68,
161
161
  our_story: "Za nami jest więcej**! Sprawdź naszą historię na [Localazy] (https://localazy.com).\n\n! [Logo_sq-01.png] (/uploads/Logo_sq_01_08b9bb6be1.png)",
162
+ used_cookbooks: {
163
+ id: 1,
164
+ },
162
165
  menu: [
163
166
  {
164
167
  id: 40,
@@ -321,6 +324,17 @@ describe("populate-create-update-entry-with-base-entry.js", () => {
321
324
  cuisine: "Italian",
322
325
  capacity: 16,
323
326
  our_story: "Długa tradycja, mądrość przekazywana z pokolenia na pokolenie... Od 1822 roku.",
327
+ supported_restaurants: [
328
+ {
329
+ id: 2,
330
+ },
331
+ {
332
+ id: 1,
333
+ },
334
+ ],
335
+ used_cookbooks: {
336
+ id: 1,
337
+ },
324
338
  menu: [
325
339
  ],
326
340
  featured_image: null,
@@ -366,6 +380,14 @@ describe("populate-create-update-entry-with-base-entry.js", () => {
366
380
  const expected = {
367
381
  id: 24,
368
382
  title: "Pro každý den v roce",
383
+ used_in_restaurants: [
384
+ {
385
+ id: 1,
386
+ },
387
+ {
388
+ id: 3,
389
+ },
390
+ ],
369
391
  author_name: "David V.",
370
392
  pages: 365,
371
393
  recipes: [
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const isDynamicZoneKey = (key) => {
4
- const matches = key.match(/\[\d+;\w+\./g);
4
+ const matches = key.match(/\[\d+;[\w-]+\./g);
5
5
  return matches !== null;
6
6
  };
7
7
 
@@ -20,7 +20,7 @@ const pickEntries = (flatten, pickPaths) => {
20
20
  let filteredKey = key;
21
21
  filteredKey = filteredKey.replace(/\[\d+\]/g, "");
22
22
  if (isDynamicZoneKey(key)) {
23
- filteredKey = filteredKey.replace(/\[\d+;\w+\./g, `[`);
23
+ filteredKey = filteredKey.replace(/\[\d+;[\w-]+\./g, `[`);
24
24
  }
25
25
  if (mappedPickPaths.includes(filteredKey)) {
26
26
  pickedEntries[key] = flatten[key];
@@ -194,7 +194,6 @@ const populateCreateUpdateEntryWithBaseEntry = async (
194
194
  // }
195
195
  } else if (isRelation(attribute)) {
196
196
  const newPrefix = getNewPrefix(objectKey, prefix);
197
- const populatedLocalizedEntryVal = get(populatedLocalizedEntry, newPrefix);
198
197
 
199
198
  const isArray = Array.isArray(value);
200
199
  let arraiedValue = value;
@@ -209,13 +208,12 @@ const populateCreateUpdateEntryWithBaseEntry = async (
209
208
  populate: ['localizations'],
210
209
  });
211
210
 
212
- const localizedEntry = entryWithLocalizations.localizations.find((item) => item.locale === locale);
213
- if (!!localizedEntry && localizedEntry.id) {
214
- if (!isArray) {
215
- set(populatedEntry, newPrefix, { id: localizedEntry.id });
216
- } else {
217
- set(populatedEntry, `${newPrefix}.${index}`, { id: localizedEntry.id });
218
- }
211
+ const localizedEntry = entryWithLocalizations.localizations?.find((item) => item.locale === locale);
212
+ const idToAssign = localizedEntry?.id || entityId;
213
+ if (!isArray) {
214
+ set(populatedEntry, newPrefix, { id: idToAssign });
215
+ } else {
216
+ set(populatedEntry, `${newPrefix}.${index}`, { id: idToAssign });
219
217
  }
220
218
  }
221
219
  }