@ikas/storefront 0.0.46 → 0.0.47

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.
@@ -5,6 +5,7 @@ declare type Props = {
5
5
  pageTitle?: string | null;
6
6
  description?: string | null;
7
7
  pageSpecificDataStr?: string;
8
+ merchantSettings?: string;
8
9
  };
9
10
  export declare const IkasPageHead: React.FC<Props>;
10
11
  export {};
@@ -6,6 +6,7 @@ declare type Props = {
6
6
  page?: IkasThemePage;
7
7
  pageSpecificDataStr?: string;
8
8
  settingsStr: string;
9
+ merchantSettings?: string;
9
10
  };
10
11
  export declare const IkasPage: React.FC<Props>;
11
12
  export {};
package/build/index.es.js CHANGED
@@ -11055,6 +11055,8 @@ var IkasBrandPropValueProvider = /** @class */ (function () {
11055
11055
  _a.label = 1;
11056
11056
  case 1:
11057
11057
  _a.trys.push([1, 3, , 4]);
11058
+ if (!this.brandPropValue.brandId)
11059
+ return [2 /*return*/, new IkasBrand({})];
11058
11060
  return [4 /*yield*/, IkasBrandAPI.listBrands({
11059
11061
  idList: [this.brandPropValue.brandId],
11060
11062
  })];
@@ -11734,6 +11736,34 @@ var IkasCustomPropValueProvider = /** @class */ (function () {
11734
11736
  return IkasCustomPropValueProvider;
11735
11737
  }());
11736
11738
 
11739
+ var stringToSlug = function (str) {
11740
+ str = str.replace(/^\s+|\s+$/g, ""); // trim
11741
+ str = str.toLocaleLowerCase("tr-TR");
11742
+ // remove accents, swap ñ for n, etc
11743
+ var from = "àáäâèéëêìíïîıòóöôùúüûñçşğ·/_,:;";
11744
+ var to = "aaaaeeeeiiiiioooouuuuncsg------";
11745
+ for (var i = 0, l = from.length; i < l; i++) {
11746
+ str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i));
11747
+ }
11748
+ str = str
11749
+ .replace(/[^a-z0-9 -]/g, "") // remove invalid chars
11750
+ .replace(/\s+/g, "-") // collapse whitespace and replace by -
11751
+ .replace(/-+/g, "-"); // collapse dashes
11752
+ return str;
11753
+ };
11754
+ var validatePhoneNumber = function (str) {
11755
+ var regex = /^\+?\d+$/;
11756
+ return regex.test(str);
11757
+ };
11758
+ var pascalCase = function (str) {
11759
+ var lower = str.toLocaleLowerCase("tr-TR");
11760
+ return lower.charAt(0).toLocaleUpperCase("tr-TR") + lower.slice(1);
11761
+ };
11762
+ var decodeBase64 = function (base64) {
11763
+ var buffer = Buffer.from(base64, "base64");
11764
+ return buffer.toString("ascii");
11765
+ };
11766
+
11737
11767
  var IkasPageDataProvider = /** @class */ (function () {
11738
11768
  function IkasPageDataProvider(theme, pageParams, pageType) {
11739
11769
  this.pageType = null;
@@ -11764,6 +11794,7 @@ var IkasPageDataProvider = /** @class */ (function () {
11764
11794
  propValuesStr: JSON.stringify(this.pageComponentPropValues),
11765
11795
  page: toJS(this.page) || null,
11766
11796
  settingsStr: JSON.stringify(this.theme.settings || {}),
11797
+ merchantSettings: JSON.stringify(this.merchantSettings),
11767
11798
  },
11768
11799
  };
11769
11800
  },
@@ -11783,7 +11814,7 @@ var IkasPageDataProvider = /** @class */ (function () {
11783
11814
  });
11784
11815
  IkasPageDataProvider.prototype.getPageData = function () {
11785
11816
  return __awaiter(this, void 0, void 0, function () {
11786
- var _a;
11817
+ var merchantId, merchantSettingsResponse, _a;
11787
11818
  var _this = this;
11788
11819
  return __generator(this, function (_b) {
11789
11820
  switch (_b.label) {
@@ -11796,11 +11827,18 @@ var IkasPageDataProvider = /** @class */ (function () {
11796
11827
  case 2:
11797
11828
  if (!this.page)
11798
11829
  return [2 /*return*/];
11830
+ merchantId = decodeBase64(IkasStorefrontConfig.config.apiKey || "");
11831
+ return [4 /*yield*/, IkasMerchantAPI.listMerchantSettings(merchantId)];
11832
+ case 3:
11833
+ merchantSettingsResponse = _b.sent();
11834
+ if (merchantSettingsResponse) {
11835
+ this.merchantSettings = merchantSettingsResponse;
11836
+ }
11799
11837
  _a = this;
11800
11838
  return [4 /*yield*/, Promise.all(this.page.components.map(function (pageComponent) {
11801
11839
  return _this.getPageComponentPropValues(pageComponent);
11802
11840
  }))];
11803
- case 3:
11841
+ case 4:
11804
11842
  _a.pageComponentPropValues = _b.sent();
11805
11843
  return [2 /*return*/];
11806
11844
  }
@@ -12262,34 +12300,6 @@ var IkasPageComponentPropValue = /** @class */ (function () {
12262
12300
  return IkasPageComponentPropValue;
12263
12301
  }());
12264
12302
 
12265
- var stringToSlug = function (str) {
12266
- str = str.replace(/^\s+|\s+$/g, ""); // trim
12267
- str = str.toLocaleLowerCase("tr-TR");
12268
- // remove accents, swap ñ for n, etc
12269
- var from = "àáäâèéëêìíïîıòóöôùúüûñçşğ·/_,:;";
12270
- var to = "aaaaeeeeiiiiioooouuuuncsg------";
12271
- for (var i = 0, l = from.length; i < l; i++) {
12272
- str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i));
12273
- }
12274
- str = str
12275
- .replace(/[^a-z0-9 -]/g, "") // remove invalid chars
12276
- .replace(/\s+/g, "-") // collapse whitespace and replace by -
12277
- .replace(/-+/g, "-"); // collapse dashes
12278
- return str;
12279
- };
12280
- var validatePhoneNumber = function (str) {
12281
- var regex = /^\+?\d+$/;
12282
- return regex.test(str);
12283
- };
12284
- var pascalCase = function (str) {
12285
- var lower = str.toLocaleLowerCase("tr-TR");
12286
- return lower.charAt(0).toLocaleUpperCase("tr-TR") + lower.slice(1);
12287
- };
12288
- var decodeBase64 = function (base64) {
12289
- var buffer = Buffer.from(base64, "base64");
12290
- return buffer.toString("ascii");
12291
- };
12292
-
12293
12303
  var formatMoney = function (price, currency) {
12294
12304
  var locale = typeof navigator !== "undefined"
12295
12305
  ? navigator.languages
@@ -24976,18 +24986,64 @@ var PolicyModal = observer(function (_a) {
24976
24986
  });
24977
24987
 
24978
24988
  var IkasPageHead = observer(function (_a) {
24979
- var page = _a.page, pageTitle = _a.pageTitle, description = _a.description, pageSpecificDataStr = _a.pageSpecificDataStr;
24980
- var schema;
24989
+ var page = _a.page, pageTitle = _a.pageTitle, description = _a.description, pageSpecificDataStr = _a.pageSpecificDataStr, props = __rest(_a, ["page", "pageTitle", "description", "pageSpecificDataStr"]);
24990
+ var schemas = [];
24991
+ if (props.merchantSettings) {
24992
+ var merchantSettings = new IkasMerchantSettings(JSON.parse(props.merchantSettings));
24993
+ var websiteSchema = createWebsiteSchema();
24994
+ var storeSchema = createStoreSchema(merchantSettings);
24995
+ schemas.push(websiteSchema);
24996
+ schemas.push(storeSchema);
24997
+ }
24981
24998
  if (pageSpecificDataStr && (page === null || page === void 0 ? void 0 : page.type) === IkasThemePageType.PRODUCT) {
24982
- schema = createProductSchema(pageSpecificDataStr);
24999
+ var schema = createProductSchema(pageSpecificDataStr);
25000
+ if (schema)
25001
+ schemas.push(schema);
25002
+ }
25003
+ if (pageSpecificDataStr && (page === null || page === void 0 ? void 0 : page.type) === IkasThemePageType.CATEGORY) {
25004
+ var categorySchema = createCategorySchema(pageSpecificDataStr);
25005
+ if (categorySchema)
25006
+ schemas.push(categorySchema);
25007
+ // TODO
25008
+ // const categoryBreadcrumbSchema = createCategoryBreadcrumbSchema(
25009
+ // pageSpecificDataStr
25010
+ // );
25011
+ // if (categoryBreadcrumbSchema) schemas.push(categoryBreadcrumbSchema);
24983
25012
  }
24984
25013
  return (createElement(Head, null,
24985
25014
  createElement("title", null, pageTitle || ""),
24986
25015
  createElement("meta", { name: "description", content: description || "" }),
24987
- !!schema && (createElement("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
24988
- __html: JSON.stringify(schema),
24989
- } }))));
25016
+ !!schemas.length &&
25017
+ schemas.map(function (schema, index) { return (createElement("script", { key: index, type: "application/ld+json", dangerouslySetInnerHTML: {
25018
+ __html: JSON.stringify(schema),
25019
+ } })); })));
24990
25020
  });
25021
+ function createWebsiteSchema(merchantSettings) {
25022
+ var _a;
25023
+ var hostname = "";
25024
+ if (typeof window !== "undefined") {
25025
+ hostname = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.hostname;
25026
+ }
25027
+ return {
25028
+ "@context": "https://schema.org",
25029
+ "@type": "Website",
25030
+ url: "https://" + hostname,
25031
+ };
25032
+ }
25033
+ function createStoreSchema(merchantSettings) {
25034
+ var _a, _b;
25035
+ var hostname = "";
25036
+ if (typeof window !== "undefined") {
25037
+ hostname = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.hostname;
25038
+ }
25039
+ return {
25040
+ "@context": "https://schema.org",
25041
+ "@type": "Store",
25042
+ name: merchantSettings === null || merchantSettings === void 0 ? void 0 : merchantSettings.merchantName,
25043
+ logo: (_b = merchantSettings === null || merchantSettings === void 0 ? void 0 : merchantSettings.logo) === null || _b === void 0 ? void 0 : _b.src,
25044
+ url: "https://" + hostname,
25045
+ };
25046
+ }
24991
25047
  function createProductSchema(pageSpecificDataStr) {
24992
25048
  var _a;
24993
25049
  try {
@@ -25032,7 +25088,43 @@ function createProductSchema(pageSpecificDataStr) {
25032
25088
  };
25033
25089
  }
25034
25090
  catch (err) { }
25035
- }
25091
+ }
25092
+ function createCategorySchema(pageSpecificDataStr) {
25093
+ var _a, _b, _c;
25094
+ try {
25095
+ var categoryParsed = JSON.parse(pageSpecificDataStr);
25096
+ var category = new IkasCategory(categoryParsed);
25097
+ return {
25098
+ "@context": "http://schema.org",
25099
+ "@type": "CollectionPage",
25100
+ url: "https://" + window.location.hostname + category.href,
25101
+ name: (_a = category.metaData) === null || _a === void 0 ? void 0 : _a.pageTitle,
25102
+ description: (_b = category.metaData) === null || _b === void 0 ? void 0 : _b.description,
25103
+ image: (_c = category.image) === null || _c === void 0 ? void 0 : _c.src,
25104
+ };
25105
+ }
25106
+ catch (_d) { }
25107
+ }
25108
+ // TODO - Waiting for CategoryParentTree feature
25109
+ // https://app.clubhouse.io/ikas/story/256/schema-org-json-lar%C4%B1n%C4%B1n-t%C3%BCm-kategori-sayfalar%C4%B1na-yerle%C5%9Ftirilmesini-istiyorum
25110
+ // function createCategoryBreadcrumbSchema(pageSpecificDataStr: string) {
25111
+ // try {
25112
+ // const categoryParsed = JSON.parse(pageSpecificDataStr) as IkasCategory;
25113
+ // const category = new IkasCategory(categoryParsed);
25114
+ // return {
25115
+ // "@context": "http://schema.org",
25116
+ // "@type": "BreadcrumbList",
25117
+ // "itemListElement": [
25118
+ // {
25119
+ // "@type": "ListItem",
25120
+ // "position": 1,
25121
+ // "name": "category.name",
25122
+ // "item": "https://" + window.location.hostname + "category.href"
25123
+ // }
25124
+ // ]
25125
+ // };
25126
+ // } catch {}
25127
+ // }
25036
25128
 
25037
25129
  var IkasCheckoutPage = observer(function (_a) {
25038
25130
  var _b, _c, _d;
@@ -25198,7 +25290,7 @@ var ThemeComponent = observer(function (_a) {
25198
25290
 
25199
25291
  var IkasPage = observer(function (_a) {
25200
25292
  var _b, _c;
25201
- var propValues = _a.propValues, page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, settingsStr = _a.settingsStr;
25293
+ var propValues = _a.propValues, page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
25202
25294
  var renderComponent = function (pageComponent, index) {
25203
25295
  var pageComponentPropValue = propValues.find(function (pv) { return pv.pageComponent.id === pageComponent.id; });
25204
25296
  return (createElement(ThemeComponent, { key: pageComponent.id, index: index, pageComponentPropValue: pageComponentPropValue, pageComponent: pageComponent, settingsStr: settingsStr }));
@@ -25211,7 +25303,7 @@ var IkasPage = observer(function (_a) {
25211
25303
  if (!page)
25212
25304
  return null;
25213
25305
  return (createElement(Fragment, null,
25214
- createElement(IkasPageHead, { page: page, pageTitle: page.pageTitle, description: page.description, pageSpecificDataStr: pageSpecificDataStr }),
25306
+ createElement(IkasPageHead, { page: page, pageTitle: page.pageTitle, description: page.description, pageSpecificDataStr: pageSpecificDataStr, merchantSettings: merchantSettings }),
25215
25307
  createElement("div", { style: pageStyle },
25216
25308
  createElement("div", null,
25217
25309
  headerComponent && renderComponent(headerComponent, -1),
@@ -25697,10 +25789,10 @@ var index = /*#__PURE__*/Object.freeze({
25697
25789
  });
25698
25790
 
25699
25791
  var Page = function (_a) {
25700
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
25792
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
25701
25793
  var router = useRouter();
25702
25794
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router);
25703
- return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
25795
+ return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
25704
25796
  };
25705
25797
  var getStaticProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
25706
25798
  var theme, provider;
@@ -25725,7 +25817,7 @@ var home = /*#__PURE__*/Object.freeze({
25725
25817
  });
25726
25818
 
25727
25819
  var Page$1 = function (_a) {
25728
- var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
25820
+ var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
25729
25821
  var router = useRouter();
25730
25822
  var _b = useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
25731
25823
  var _c = useState(IkasPageDataProvider.initPropValues(propValuesStr, router)), propValues = _c[0], setPropValues = _c[1];
@@ -25736,7 +25828,7 @@ var Page$1 = function (_a) {
25736
25828
  setPropValues(IkasPageDataProvider.initPropValues(propValuesStr, router, isBrowser));
25737
25829
  }, [isBrowser, propValuesStr]);
25738
25830
  handleGTM(page, pageSpecificDataStr);
25739
- return (createElement(IkasPage, { page: page, propValues: propValues, pageSpecificDataStr: pageSpecificDataStr, settingsStr: settingsStr }));
25831
+ return (createElement(IkasPage, { page: page, propValues: propValues, pageSpecificDataStr: pageSpecificDataStr, settingsStr: settingsStr, merchantSettings: merchantSettings }));
25740
25832
  };
25741
25833
  var index$1 = observer(Page$1);
25742
25834
  var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void 0, function () {
@@ -26052,10 +26144,10 @@ var _id_$2 = /*#__PURE__*/Object.freeze({
26052
26144
  });
26053
26145
 
26054
26146
  var Page$7 = function (_a) {
26055
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26147
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26056
26148
  var router = useRouter();
26057
26149
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router);
26058
- return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26150
+ return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26059
26151
  };
26060
26152
  var getStaticProps$6 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26061
26153
  var theme, provider;
@@ -26080,10 +26172,10 @@ var login = /*#__PURE__*/Object.freeze({
26080
26172
  });
26081
26173
 
26082
26174
  var Page$8 = function (_a) {
26083
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26175
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26084
26176
  var router = useRouter();
26085
26177
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router);
26086
- return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26178
+ return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26087
26179
  };
26088
26180
  var getStaticProps$7 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26089
26181
  var theme, provider;
@@ -26108,10 +26200,10 @@ var register = /*#__PURE__*/Object.freeze({
26108
26200
  });
26109
26201
 
26110
26202
  var Page$9 = function (_a) {
26111
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26203
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26112
26204
  var router = useRouter();
26113
26205
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router);
26114
- return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26206
+ return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26115
26207
  };
26116
26208
  var getStaticProps$8 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26117
26209
  var theme, provider;
@@ -26136,10 +26228,10 @@ var forgotPassword = /*#__PURE__*/Object.freeze({
26136
26228
  });
26137
26229
 
26138
26230
  var Page$a = function (_a) {
26139
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26231
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26140
26232
  var router = useRouter();
26141
26233
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router);
26142
- return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26234
+ return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26143
26235
  };
26144
26236
  var getStaticProps$9 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26145
26237
  var theme, provider;
package/build/index.js CHANGED
@@ -11067,6 +11067,8 @@ var IkasBrandPropValueProvider = /** @class */ (function () {
11067
11067
  _a.label = 1;
11068
11068
  case 1:
11069
11069
  _a.trys.push([1, 3, , 4]);
11070
+ if (!this.brandPropValue.brandId)
11071
+ return [2 /*return*/, new IkasBrand({})];
11070
11072
  return [4 /*yield*/, IkasBrandAPI.listBrands({
11071
11073
  idList: [this.brandPropValue.brandId],
11072
11074
  })];
@@ -11746,6 +11748,34 @@ var IkasCustomPropValueProvider = /** @class */ (function () {
11746
11748
  return IkasCustomPropValueProvider;
11747
11749
  }());
11748
11750
 
11751
+ var stringToSlug = function (str) {
11752
+ str = str.replace(/^\s+|\s+$/g, ""); // trim
11753
+ str = str.toLocaleLowerCase("tr-TR");
11754
+ // remove accents, swap ñ for n, etc
11755
+ var from = "àáäâèéëêìíïîıòóöôùúüûñçşğ·/_,:;";
11756
+ var to = "aaaaeeeeiiiiioooouuuuncsg------";
11757
+ for (var i = 0, l = from.length; i < l; i++) {
11758
+ str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i));
11759
+ }
11760
+ str = str
11761
+ .replace(/[^a-z0-9 -]/g, "") // remove invalid chars
11762
+ .replace(/\s+/g, "-") // collapse whitespace and replace by -
11763
+ .replace(/-+/g, "-"); // collapse dashes
11764
+ return str;
11765
+ };
11766
+ var validatePhoneNumber = function (str) {
11767
+ var regex = /^\+?\d+$/;
11768
+ return regex.test(str);
11769
+ };
11770
+ var pascalCase = function (str) {
11771
+ var lower = str.toLocaleLowerCase("tr-TR");
11772
+ return lower.charAt(0).toLocaleUpperCase("tr-TR") + lower.slice(1);
11773
+ };
11774
+ var decodeBase64 = function (base64) {
11775
+ var buffer = Buffer.from(base64, "base64");
11776
+ return buffer.toString("ascii");
11777
+ };
11778
+
11749
11779
  var IkasPageDataProvider = /** @class */ (function () {
11750
11780
  function IkasPageDataProvider(theme, pageParams, pageType) {
11751
11781
  this.pageType = null;
@@ -11776,6 +11806,7 @@ var IkasPageDataProvider = /** @class */ (function () {
11776
11806
  propValuesStr: JSON.stringify(this.pageComponentPropValues),
11777
11807
  page: mobx.toJS(this.page) || null,
11778
11808
  settingsStr: JSON.stringify(this.theme.settings || {}),
11809
+ merchantSettings: JSON.stringify(this.merchantSettings),
11779
11810
  },
11780
11811
  };
11781
11812
  },
@@ -11795,7 +11826,7 @@ var IkasPageDataProvider = /** @class */ (function () {
11795
11826
  });
11796
11827
  IkasPageDataProvider.prototype.getPageData = function () {
11797
11828
  return __awaiter(this, void 0, void 0, function () {
11798
- var _a;
11829
+ var merchantId, merchantSettingsResponse, _a;
11799
11830
  var _this = this;
11800
11831
  return __generator(this, function (_b) {
11801
11832
  switch (_b.label) {
@@ -11808,11 +11839,18 @@ var IkasPageDataProvider = /** @class */ (function () {
11808
11839
  case 2:
11809
11840
  if (!this.page)
11810
11841
  return [2 /*return*/];
11842
+ merchantId = decodeBase64(IkasStorefrontConfig.config.apiKey || "");
11843
+ return [4 /*yield*/, IkasMerchantAPI.listMerchantSettings(merchantId)];
11844
+ case 3:
11845
+ merchantSettingsResponse = _b.sent();
11846
+ if (merchantSettingsResponse) {
11847
+ this.merchantSettings = merchantSettingsResponse;
11848
+ }
11811
11849
  _a = this;
11812
11850
  return [4 /*yield*/, Promise.all(this.page.components.map(function (pageComponent) {
11813
11851
  return _this.getPageComponentPropValues(pageComponent);
11814
11852
  }))];
11815
- case 3:
11853
+ case 4:
11816
11854
  _a.pageComponentPropValues = _b.sent();
11817
11855
  return [2 /*return*/];
11818
11856
  }
@@ -12274,34 +12312,6 @@ var IkasPageComponentPropValue = /** @class */ (function () {
12274
12312
  return IkasPageComponentPropValue;
12275
12313
  }());
12276
12314
 
12277
- var stringToSlug = function (str) {
12278
- str = str.replace(/^\s+|\s+$/g, ""); // trim
12279
- str = str.toLocaleLowerCase("tr-TR");
12280
- // remove accents, swap ñ for n, etc
12281
- var from = "àáäâèéëêìíïîıòóöôùúüûñçşğ·/_,:;";
12282
- var to = "aaaaeeeeiiiiioooouuuuncsg------";
12283
- for (var i = 0, l = from.length; i < l; i++) {
12284
- str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i));
12285
- }
12286
- str = str
12287
- .replace(/[^a-z0-9 -]/g, "") // remove invalid chars
12288
- .replace(/\s+/g, "-") // collapse whitespace and replace by -
12289
- .replace(/-+/g, "-"); // collapse dashes
12290
- return str;
12291
- };
12292
- var validatePhoneNumber = function (str) {
12293
- var regex = /^\+?\d+$/;
12294
- return regex.test(str);
12295
- };
12296
- var pascalCase = function (str) {
12297
- var lower = str.toLocaleLowerCase("tr-TR");
12298
- return lower.charAt(0).toLocaleUpperCase("tr-TR") + lower.slice(1);
12299
- };
12300
- var decodeBase64 = function (base64) {
12301
- var buffer = Buffer.from(base64, "base64");
12302
- return buffer.toString("ascii");
12303
- };
12304
-
12305
12315
  var formatMoney = function (price, currency) {
12306
12316
  var locale = typeof navigator !== "undefined"
12307
12317
  ? navigator.languages
@@ -24957,18 +24967,64 @@ var PolicyModal = mobxReactLite.observer(function (_a) {
24957
24967
  });
24958
24968
 
24959
24969
  var IkasPageHead = mobxReactLite.observer(function (_a) {
24960
- var page = _a.page, pageTitle = _a.pageTitle, description = _a.description, pageSpecificDataStr = _a.pageSpecificDataStr;
24961
- var schema;
24970
+ var page = _a.page, pageTitle = _a.pageTitle, description = _a.description, pageSpecificDataStr = _a.pageSpecificDataStr, props = __rest(_a, ["page", "pageTitle", "description", "pageSpecificDataStr"]);
24971
+ var schemas = [];
24972
+ if (props.merchantSettings) {
24973
+ var merchantSettings = new IkasMerchantSettings(JSON.parse(props.merchantSettings));
24974
+ var websiteSchema = createWebsiteSchema();
24975
+ var storeSchema = createStoreSchema(merchantSettings);
24976
+ schemas.push(websiteSchema);
24977
+ schemas.push(storeSchema);
24978
+ }
24962
24979
  if (pageSpecificDataStr && (page === null || page === void 0 ? void 0 : page.type) === exports.IkasThemePageType.PRODUCT) {
24963
- schema = createProductSchema(pageSpecificDataStr);
24980
+ var schema = createProductSchema(pageSpecificDataStr);
24981
+ if (schema)
24982
+ schemas.push(schema);
24983
+ }
24984
+ if (pageSpecificDataStr && (page === null || page === void 0 ? void 0 : page.type) === exports.IkasThemePageType.CATEGORY) {
24985
+ var categorySchema = createCategorySchema(pageSpecificDataStr);
24986
+ if (categorySchema)
24987
+ schemas.push(categorySchema);
24988
+ // TODO
24989
+ // const categoryBreadcrumbSchema = createCategoryBreadcrumbSchema(
24990
+ // pageSpecificDataStr
24991
+ // );
24992
+ // if (categoryBreadcrumbSchema) schemas.push(categoryBreadcrumbSchema);
24964
24993
  }
24965
24994
  return (React.createElement(Head__default['default'], null,
24966
24995
  React.createElement("title", null, pageTitle || ""),
24967
24996
  React.createElement("meta", { name: "description", content: description || "" }),
24968
- !!schema && (React.createElement("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
24969
- __html: JSON.stringify(schema),
24970
- } }))));
24997
+ !!schemas.length &&
24998
+ schemas.map(function (schema, index) { return (React.createElement("script", { key: index, type: "application/ld+json", dangerouslySetInnerHTML: {
24999
+ __html: JSON.stringify(schema),
25000
+ } })); })));
24971
25001
  });
25002
+ function createWebsiteSchema(merchantSettings) {
25003
+ var _a;
25004
+ var hostname = "";
25005
+ if (typeof window !== "undefined") {
25006
+ hostname = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.hostname;
25007
+ }
25008
+ return {
25009
+ "@context": "https://schema.org",
25010
+ "@type": "Website",
25011
+ url: "https://" + hostname,
25012
+ };
25013
+ }
25014
+ function createStoreSchema(merchantSettings) {
25015
+ var _a, _b;
25016
+ var hostname = "";
25017
+ if (typeof window !== "undefined") {
25018
+ hostname = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.hostname;
25019
+ }
25020
+ return {
25021
+ "@context": "https://schema.org",
25022
+ "@type": "Store",
25023
+ name: merchantSettings === null || merchantSettings === void 0 ? void 0 : merchantSettings.merchantName,
25024
+ logo: (_b = merchantSettings === null || merchantSettings === void 0 ? void 0 : merchantSettings.logo) === null || _b === void 0 ? void 0 : _b.src,
25025
+ url: "https://" + hostname,
25026
+ };
25027
+ }
24972
25028
  function createProductSchema(pageSpecificDataStr) {
24973
25029
  var _a;
24974
25030
  try {
@@ -25013,7 +25069,43 @@ function createProductSchema(pageSpecificDataStr) {
25013
25069
  };
25014
25070
  }
25015
25071
  catch (err) { }
25016
- }
25072
+ }
25073
+ function createCategorySchema(pageSpecificDataStr) {
25074
+ var _a, _b, _c;
25075
+ try {
25076
+ var categoryParsed = JSON.parse(pageSpecificDataStr);
25077
+ var category = new IkasCategory(categoryParsed);
25078
+ return {
25079
+ "@context": "http://schema.org",
25080
+ "@type": "CollectionPage",
25081
+ url: "https://" + window.location.hostname + category.href,
25082
+ name: (_a = category.metaData) === null || _a === void 0 ? void 0 : _a.pageTitle,
25083
+ description: (_b = category.metaData) === null || _b === void 0 ? void 0 : _b.description,
25084
+ image: (_c = category.image) === null || _c === void 0 ? void 0 : _c.src,
25085
+ };
25086
+ }
25087
+ catch (_d) { }
25088
+ }
25089
+ // TODO - Waiting for CategoryParentTree feature
25090
+ // https://app.clubhouse.io/ikas/story/256/schema-org-json-lar%C4%B1n%C4%B1n-t%C3%BCm-kategori-sayfalar%C4%B1na-yerle%C5%9Ftirilmesini-istiyorum
25091
+ // function createCategoryBreadcrumbSchema(pageSpecificDataStr: string) {
25092
+ // try {
25093
+ // const categoryParsed = JSON.parse(pageSpecificDataStr) as IkasCategory;
25094
+ // const category = new IkasCategory(categoryParsed);
25095
+ // return {
25096
+ // "@context": "http://schema.org",
25097
+ // "@type": "BreadcrumbList",
25098
+ // "itemListElement": [
25099
+ // {
25100
+ // "@type": "ListItem",
25101
+ // "position": 1,
25102
+ // "name": "category.name",
25103
+ // "item": "https://" + window.location.hostname + "category.href"
25104
+ // }
25105
+ // ]
25106
+ // };
25107
+ // } catch {}
25108
+ // }
25017
25109
 
25018
25110
  var IkasCheckoutPage = mobxReactLite.observer(function (_a) {
25019
25111
  var _b, _c, _d;
@@ -25179,7 +25271,7 @@ var ThemeComponent = mobxReactLite.observer(function (_a) {
25179
25271
 
25180
25272
  var IkasPage = mobxReactLite.observer(function (_a) {
25181
25273
  var _b, _c;
25182
- var propValues = _a.propValues, page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, settingsStr = _a.settingsStr;
25274
+ var propValues = _a.propValues, page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
25183
25275
  var renderComponent = function (pageComponent, index) {
25184
25276
  var pageComponentPropValue = propValues.find(function (pv) { return pv.pageComponent.id === pageComponent.id; });
25185
25277
  return (React.createElement(ThemeComponent, { key: pageComponent.id, index: index, pageComponentPropValue: pageComponentPropValue, pageComponent: pageComponent, settingsStr: settingsStr }));
@@ -25192,7 +25284,7 @@ var IkasPage = mobxReactLite.observer(function (_a) {
25192
25284
  if (!page)
25193
25285
  return null;
25194
25286
  return (React.createElement(React.Fragment, null,
25195
- React.createElement(IkasPageHead, { page: page, pageTitle: page.pageTitle, description: page.description, pageSpecificDataStr: pageSpecificDataStr }),
25287
+ React.createElement(IkasPageHead, { page: page, pageTitle: page.pageTitle, description: page.description, pageSpecificDataStr: pageSpecificDataStr, merchantSettings: merchantSettings }),
25196
25288
  React.createElement("div", { style: pageStyle },
25197
25289
  React.createElement("div", null,
25198
25290
  headerComponent && renderComponent(headerComponent, -1),
@@ -25678,10 +25770,10 @@ var index = /*#__PURE__*/Object.freeze({
25678
25770
  });
25679
25771
 
25680
25772
  var Page = function (_a) {
25681
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
25773
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
25682
25774
  var router$1 = router.useRouter();
25683
25775
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router$1);
25684
- return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
25776
+ return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
25685
25777
  };
25686
25778
  var getStaticProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
25687
25779
  var theme, provider;
@@ -25706,7 +25798,7 @@ var home = /*#__PURE__*/Object.freeze({
25706
25798
  });
25707
25799
 
25708
25800
  var Page$1 = function (_a) {
25709
- var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
25801
+ var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
25710
25802
  var router$1 = router.useRouter();
25711
25803
  var _b = React.useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
25712
25804
  var _c = React.useState(IkasPageDataProvider.initPropValues(propValuesStr, router$1)), propValues = _c[0], setPropValues = _c[1];
@@ -25717,7 +25809,7 @@ var Page$1 = function (_a) {
25717
25809
  setPropValues(IkasPageDataProvider.initPropValues(propValuesStr, router$1, isBrowser));
25718
25810
  }, [isBrowser, propValuesStr]);
25719
25811
  handleGTM(page, pageSpecificDataStr);
25720
- return (React.createElement(IkasPage, { page: page, propValues: propValues, pageSpecificDataStr: pageSpecificDataStr, settingsStr: settingsStr }));
25812
+ return (React.createElement(IkasPage, { page: page, propValues: propValues, pageSpecificDataStr: pageSpecificDataStr, settingsStr: settingsStr, merchantSettings: merchantSettings }));
25721
25813
  };
25722
25814
  var index$1 = mobxReactLite.observer(Page$1);
25723
25815
  var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void 0, function () {
@@ -26033,10 +26125,10 @@ var _id_$2 = /*#__PURE__*/Object.freeze({
26033
26125
  });
26034
26126
 
26035
26127
  var Page$7 = function (_a) {
26036
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26128
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26037
26129
  var router$1 = router.useRouter();
26038
26130
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router$1);
26039
- return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26131
+ return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26040
26132
  };
26041
26133
  var getStaticProps$6 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26042
26134
  var theme, provider;
@@ -26061,10 +26153,10 @@ var login = /*#__PURE__*/Object.freeze({
26061
26153
  });
26062
26154
 
26063
26155
  var Page$8 = function (_a) {
26064
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26156
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26065
26157
  var router$1 = router.useRouter();
26066
26158
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router$1);
26067
- return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26159
+ return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26068
26160
  };
26069
26161
  var getStaticProps$7 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26070
26162
  var theme, provider;
@@ -26089,10 +26181,10 @@ var register = /*#__PURE__*/Object.freeze({
26089
26181
  });
26090
26182
 
26091
26183
  var Page$9 = function (_a) {
26092
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26184
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26093
26185
  var router$1 = router.useRouter();
26094
26186
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router$1);
26095
- return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26187
+ return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26096
26188
  };
26097
26189
  var getStaticProps$8 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26098
26190
  var theme, provider;
@@ -26117,10 +26209,10 @@ var forgotPassword = /*#__PURE__*/Object.freeze({
26117
26209
  });
26118
26210
 
26119
26211
  var Page$a = function (_a) {
26120
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26212
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26121
26213
  var router$1 = router.useRouter();
26122
26214
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router$1);
26123
- return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26215
+ return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26124
26216
  };
26125
26217
  var getStaticProps$9 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26126
26218
  var theme, provider;
@@ -9,6 +9,7 @@ declare type Props = {
9
9
  page: IkasThemePage;
10
10
  queryParams?: ParsedUrlQuery;
11
11
  settingsStr: string;
12
+ merchantSettings: string;
12
13
  };
13
14
  declare const _default: React.FunctionComponent<Props>;
14
15
  export default _default;
@@ -5,6 +5,7 @@ declare type Props = {
5
5
  propValuesStr: string;
6
6
  page: IkasThemePage;
7
7
  settingsStr: string;
8
+ merchantSettings: string;
8
9
  };
9
10
  declare const Page: React.FC<Props>;
10
11
  export default Page;
@@ -5,6 +5,7 @@ declare type Props = {
5
5
  propValuesStr: string;
6
6
  page: IkasThemePage;
7
7
  settingsStr: string;
8
+ merchantSettings: string;
8
9
  };
9
10
  declare const Page: React.FC<Props>;
10
11
  export default Page;
@@ -5,6 +5,7 @@ declare type Props = {
5
5
  propValuesStr: string;
6
6
  page: IkasThemePage;
7
7
  settingsStr: string;
8
+ merchantSettings: string;
8
9
  };
9
10
  declare const Page: React.FC<Props>;
10
11
  export default Page;
@@ -5,6 +5,7 @@ declare type Props = {
5
5
  propValuesStr: string;
6
6
  page: IkasThemePage;
7
7
  settingsStr: string;
8
+ merchantSettings: string;
8
9
  };
9
10
  declare const Page: React.FC<Props>;
10
11
  export default Page;
@@ -5,6 +5,7 @@ declare type Props = {
5
5
  propValuesStr: string;
6
6
  page: IkasThemePage;
7
7
  settingsStr: string;
8
+ merchantSettings: string;
8
9
  };
9
10
  declare const Page: React.FC<Props>;
10
11
  export default Page;
@@ -1,5 +1,5 @@
1
1
  import { NextRouter } from "next/router";
2
- import { IkasTheme, IkasThemePageType, IkasThemePageComponent, IkasProductDetail, IkasThemeComponentProp, IkasThemeComponent, IkasProductList, IkasBrandList, IkasBrandListParams, IkasThemePage, IkasImage, IkasCategoryList, IkasBrand, IkasCategory, IkasThemeCustomData } from "../../models/index";
2
+ import { IkasTheme, IkasThemePageType, IkasThemePageComponent, IkasProductDetail, IkasThemeComponentProp, IkasThemeComponent, IkasProductList, IkasBrandList, IkasBrandListParams, IkasThemePage, IkasImage, IkasCategoryList, IkasBrand, IkasCategory, IkasThemeCustomData, IkasMerchantSettings } from "../../models/index";
3
3
  import { IkasProductListParams } from "../../models/ui/product-list/index";
4
4
  import { IkasNavigationLink } from "../../models/ui/navigation-link/index";
5
5
  import { IkasCategoryListParams } from "../../models/ui/category-list/index";
@@ -10,6 +10,7 @@ export declare class IkasPageDataProvider {
10
10
  pageParams: Record<string, any>;
11
11
  pageComponentPropValues: IkasPageComponentPropValue[];
12
12
  pageSpecificData?: any | null;
13
+ merchantSettings?: IkasMerchantSettings;
13
14
  constructor(theme: IkasTheme, pageParams?: Record<string, any>, pageType?: IkasThemePageType);
14
15
  get page(): IkasThemePage | undefined;
15
16
  get nextPageData(): {
@@ -17,6 +18,7 @@ export declare class IkasPageDataProvider {
17
18
  propValuesStr: string;
18
19
  page: IkasThemePage | null;
19
20
  settingsStr: string;
21
+ merchantSettings: string;
20
22
  };
21
23
  };
22
24
  get isStaticPage(): boolean | null | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.46",
3
+ "version": "0.0.47",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",