@ikas/storefront 0.0.46 → 0.0.48

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,12 +11736,41 @@ 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;
11740
11770
  this.pageParams = {};
11741
11771
  this.pageComponentPropValues = [];
11742
11772
  this.pageSpecificData = null;
11773
+ this.merchantSettings = null;
11743
11774
  this.theme = new IkasTheme(theme);
11744
11775
  this.pageParams = pageParams || {};
11745
11776
  this.pageType = pageType;
@@ -11764,6 +11795,9 @@ var IkasPageDataProvider = /** @class */ (function () {
11764
11795
  propValuesStr: JSON.stringify(this.pageComponentPropValues),
11765
11796
  page: toJS(this.page) || null,
11766
11797
  settingsStr: JSON.stringify(this.theme.settings || {}),
11798
+ merchantSettings: this.merchantSettings
11799
+ ? JSON.stringify(this.merchantSettings)
11800
+ : null,
11767
11801
  },
11768
11802
  };
11769
11803
  },
@@ -11781,6 +11815,24 @@ var IkasPageDataProvider = /** @class */ (function () {
11781
11815
  enumerable: false,
11782
11816
  configurable: true
11783
11817
  });
11818
+ IkasPageDataProvider.prototype.getMerchantSettings = function () {
11819
+ return __awaiter(this, void 0, void 0, function () {
11820
+ var merchantId, merchantSettingsResponse;
11821
+ return __generator(this, function (_a) {
11822
+ switch (_a.label) {
11823
+ case 0:
11824
+ merchantId = decodeBase64(IkasStorefrontConfig.config.apiKey || "");
11825
+ return [4 /*yield*/, IkasMerchantAPI.listMerchantSettings(merchantId)];
11826
+ case 1:
11827
+ merchantSettingsResponse = _a.sent();
11828
+ if (merchantSettingsResponse) {
11829
+ this.merchantSettings = merchantSettingsResponse;
11830
+ }
11831
+ return [2 /*return*/];
11832
+ }
11833
+ });
11834
+ });
11835
+ };
11784
11836
  IkasPageDataProvider.prototype.getPageData = function () {
11785
11837
  return __awaiter(this, void 0, void 0, function () {
11786
11838
  var _a;
@@ -11796,11 +11848,14 @@ var IkasPageDataProvider = /** @class */ (function () {
11796
11848
  case 2:
11797
11849
  if (!this.page)
11798
11850
  return [2 /*return*/];
11851
+ return [4 /*yield*/, this.getMerchantSettings()];
11852
+ case 3:
11853
+ _b.sent();
11799
11854
  _a = this;
11800
11855
  return [4 /*yield*/, Promise.all(this.page.components.map(function (pageComponent) {
11801
11856
  return _this.getPageComponentPropValues(pageComponent);
11802
11857
  }))];
11803
- case 3:
11858
+ case 4:
11804
11859
  _a.pageComponentPropValues = _b.sent();
11805
11860
  return [2 /*return*/];
11806
11861
  }
@@ -12262,34 +12317,6 @@ var IkasPageComponentPropValue = /** @class */ (function () {
12262
12317
  return IkasPageComponentPropValue;
12263
12318
  }());
12264
12319
 
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
12320
  var formatMoney = function (price, currency) {
12294
12321
  var locale = typeof navigator !== "undefined"
12295
12322
  ? navigator.languages
@@ -24976,18 +25003,64 @@ var PolicyModal = observer(function (_a) {
24976
25003
  });
24977
25004
 
24978
25005
  var IkasPageHead = observer(function (_a) {
24979
- var page = _a.page, pageTitle = _a.pageTitle, description = _a.description, pageSpecificDataStr = _a.pageSpecificDataStr;
24980
- var schema;
25006
+ var page = _a.page, pageTitle = _a.pageTitle, description = _a.description, pageSpecificDataStr = _a.pageSpecificDataStr, props = __rest(_a, ["page", "pageTitle", "description", "pageSpecificDataStr"]);
25007
+ var schemas = [];
25008
+ if (props.merchantSettings) {
25009
+ var merchantSettings = new IkasMerchantSettings(JSON.parse(props.merchantSettings));
25010
+ var websiteSchema = createWebsiteSchema();
25011
+ var storeSchema = createStoreSchema(merchantSettings);
25012
+ schemas.push(websiteSchema);
25013
+ schemas.push(storeSchema);
25014
+ }
24981
25015
  if (pageSpecificDataStr && (page === null || page === void 0 ? void 0 : page.type) === IkasThemePageType.PRODUCT) {
24982
- schema = createProductSchema(pageSpecificDataStr);
25016
+ var schema = createProductSchema(pageSpecificDataStr);
25017
+ if (schema)
25018
+ schemas.push(schema);
25019
+ }
25020
+ if (pageSpecificDataStr && (page === null || page === void 0 ? void 0 : page.type) === IkasThemePageType.CATEGORY) {
25021
+ var categorySchema = createCategorySchema(pageSpecificDataStr);
25022
+ if (categorySchema)
25023
+ schemas.push(categorySchema);
25024
+ // TODO
25025
+ // const categoryBreadcrumbSchema = createCategoryBreadcrumbSchema(
25026
+ // pageSpecificDataStr
25027
+ // );
25028
+ // if (categoryBreadcrumbSchema) schemas.push(categoryBreadcrumbSchema);
24983
25029
  }
24984
25030
  return (createElement(Head, null,
24985
25031
  createElement("title", null, pageTitle || ""),
24986
25032
  createElement("meta", { name: "description", content: description || "" }),
24987
- !!schema && (createElement("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
24988
- __html: JSON.stringify(schema),
24989
- } }))));
25033
+ !!schemas.length &&
25034
+ schemas.map(function (schema, index) { return (createElement("script", { key: index, type: "application/ld+json", dangerouslySetInnerHTML: {
25035
+ __html: JSON.stringify(schema),
25036
+ } })); })));
24990
25037
  });
25038
+ function createWebsiteSchema(merchantSettings) {
25039
+ var _a;
25040
+ var hostname = "";
25041
+ if (typeof window !== "undefined") {
25042
+ hostname = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.hostname;
25043
+ }
25044
+ return {
25045
+ "@context": "https://schema.org",
25046
+ "@type": "Website",
25047
+ url: "https://" + hostname,
25048
+ };
25049
+ }
25050
+ function createStoreSchema(merchantSettings) {
25051
+ var _a, _b;
25052
+ var hostname = "";
25053
+ if (typeof window !== "undefined") {
25054
+ hostname = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.hostname;
25055
+ }
25056
+ return {
25057
+ "@context": "https://schema.org",
25058
+ "@type": "Store",
25059
+ name: merchantSettings === null || merchantSettings === void 0 ? void 0 : merchantSettings.merchantName,
25060
+ logo: (_b = merchantSettings === null || merchantSettings === void 0 ? void 0 : merchantSettings.logo) === null || _b === void 0 ? void 0 : _b.src,
25061
+ url: "https://" + hostname,
25062
+ };
25063
+ }
24991
25064
  function createProductSchema(pageSpecificDataStr) {
24992
25065
  var _a;
24993
25066
  try {
@@ -25032,7 +25105,43 @@ function createProductSchema(pageSpecificDataStr) {
25032
25105
  };
25033
25106
  }
25034
25107
  catch (err) { }
25035
- }
25108
+ }
25109
+ function createCategorySchema(pageSpecificDataStr) {
25110
+ var _a, _b, _c;
25111
+ try {
25112
+ var categoryParsed = JSON.parse(pageSpecificDataStr);
25113
+ var category = new IkasCategory(categoryParsed);
25114
+ return {
25115
+ "@context": "http://schema.org",
25116
+ "@type": "CollectionPage",
25117
+ url: "https://" + window.location.hostname + category.href,
25118
+ name: (_a = category.metaData) === null || _a === void 0 ? void 0 : _a.pageTitle,
25119
+ description: (_b = category.metaData) === null || _b === void 0 ? void 0 : _b.description,
25120
+ image: (_c = category.image) === null || _c === void 0 ? void 0 : _c.src,
25121
+ };
25122
+ }
25123
+ catch (_d) { }
25124
+ }
25125
+ // TODO - Waiting for CategoryParentTree feature
25126
+ // 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
25127
+ // function createCategoryBreadcrumbSchema(pageSpecificDataStr: string) {
25128
+ // try {
25129
+ // const categoryParsed = JSON.parse(pageSpecificDataStr) as IkasCategory;
25130
+ // const category = new IkasCategory(categoryParsed);
25131
+ // return {
25132
+ // "@context": "http://schema.org",
25133
+ // "@type": "BreadcrumbList",
25134
+ // "itemListElement": [
25135
+ // {
25136
+ // "@type": "ListItem",
25137
+ // "position": 1,
25138
+ // "name": "category.name",
25139
+ // "item": "https://" + window.location.hostname + "category.href"
25140
+ // }
25141
+ // ]
25142
+ // };
25143
+ // } catch {}
25144
+ // }
25036
25145
 
25037
25146
  var IkasCheckoutPage = observer(function (_a) {
25038
25147
  var _b, _c, _d;
@@ -25198,7 +25307,7 @@ var ThemeComponent = observer(function (_a) {
25198
25307
 
25199
25308
  var IkasPage = observer(function (_a) {
25200
25309
  var _b, _c;
25201
- var propValues = _a.propValues, page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, settingsStr = _a.settingsStr;
25310
+ var propValues = _a.propValues, page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
25202
25311
  var renderComponent = function (pageComponent, index) {
25203
25312
  var pageComponentPropValue = propValues.find(function (pv) { return pv.pageComponent.id === pageComponent.id; });
25204
25313
  return (createElement(ThemeComponent, { key: pageComponent.id, index: index, pageComponentPropValue: pageComponentPropValue, pageComponent: pageComponent, settingsStr: settingsStr }));
@@ -25211,7 +25320,7 @@ var IkasPage = observer(function (_a) {
25211
25320
  if (!page)
25212
25321
  return null;
25213
25322
  return (createElement(Fragment, null,
25214
- createElement(IkasPageHead, { page: page, pageTitle: page.pageTitle, description: page.description, pageSpecificDataStr: pageSpecificDataStr }),
25323
+ createElement(IkasPageHead, { page: page, pageTitle: page.pageTitle, description: page.description, pageSpecificDataStr: pageSpecificDataStr, merchantSettings: merchantSettings }),
25215
25324
  createElement("div", { style: pageStyle },
25216
25325
  createElement("div", null,
25217
25326
  headerComponent && renderComponent(headerComponent, -1),
@@ -25697,10 +25806,10 @@ var index = /*#__PURE__*/Object.freeze({
25697
25806
  });
25698
25807
 
25699
25808
  var Page = function (_a) {
25700
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
25809
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
25701
25810
  var router = useRouter();
25702
25811
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router);
25703
- return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
25812
+ return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
25704
25813
  };
25705
25814
  var getStaticProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
25706
25815
  var theme, provider;
@@ -25725,7 +25834,7 @@ var home = /*#__PURE__*/Object.freeze({
25725
25834
  });
25726
25835
 
25727
25836
  var Page$1 = function (_a) {
25728
- var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
25837
+ var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
25729
25838
  var router = useRouter();
25730
25839
  var _b = useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
25731
25840
  var _c = useState(IkasPageDataProvider.initPropValues(propValuesStr, router)), propValues = _c[0], setPropValues = _c[1];
@@ -25736,7 +25845,7 @@ var Page$1 = function (_a) {
25736
25845
  setPropValues(IkasPageDataProvider.initPropValues(propValuesStr, router, isBrowser));
25737
25846
  }, [isBrowser, propValuesStr]);
25738
25847
  handleGTM(page, pageSpecificDataStr);
25739
- return (createElement(IkasPage, { page: page, propValues: propValues, pageSpecificDataStr: pageSpecificDataStr, settingsStr: settingsStr }));
25848
+ return (createElement(IkasPage, { page: page, propValues: propValues, pageSpecificDataStr: pageSpecificDataStr, settingsStr: settingsStr, merchantSettings: merchantSettings }));
25740
25849
  };
25741
25850
  var index$1 = observer(Page$1);
25742
25851
  var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void 0, function () {
@@ -26052,10 +26161,10 @@ var _id_$2 = /*#__PURE__*/Object.freeze({
26052
26161
  });
26053
26162
 
26054
26163
  var Page$7 = function (_a) {
26055
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26164
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26056
26165
  var router = useRouter();
26057
26166
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router);
26058
- return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26167
+ return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26059
26168
  };
26060
26169
  var getStaticProps$6 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26061
26170
  var theme, provider;
@@ -26080,10 +26189,10 @@ var login = /*#__PURE__*/Object.freeze({
26080
26189
  });
26081
26190
 
26082
26191
  var Page$8 = function (_a) {
26083
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26192
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26084
26193
  var router = useRouter();
26085
26194
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router);
26086
- return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26195
+ return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26087
26196
  };
26088
26197
  var getStaticProps$7 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26089
26198
  var theme, provider;
@@ -26108,10 +26217,10 @@ var register = /*#__PURE__*/Object.freeze({
26108
26217
  });
26109
26218
 
26110
26219
  var Page$9 = function (_a) {
26111
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26220
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26112
26221
  var router = useRouter();
26113
26222
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router);
26114
- return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26223
+ return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26115
26224
  };
26116
26225
  var getStaticProps$8 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26117
26226
  var theme, provider;
@@ -26136,10 +26245,10 @@ var forgotPassword = /*#__PURE__*/Object.freeze({
26136
26245
  });
26137
26246
 
26138
26247
  var Page$a = function (_a) {
26139
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26248
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26140
26249
  var router = useRouter();
26141
26250
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router);
26142
- return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26251
+ return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26143
26252
  };
26144
26253
  var getStaticProps$9 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26145
26254
  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,12 +11748,41 @@ 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;
11752
11782
  this.pageParams = {};
11753
11783
  this.pageComponentPropValues = [];
11754
11784
  this.pageSpecificData = null;
11785
+ this.merchantSettings = null;
11755
11786
  this.theme = new IkasTheme(theme);
11756
11787
  this.pageParams = pageParams || {};
11757
11788
  this.pageType = pageType;
@@ -11776,6 +11807,9 @@ var IkasPageDataProvider = /** @class */ (function () {
11776
11807
  propValuesStr: JSON.stringify(this.pageComponentPropValues),
11777
11808
  page: mobx.toJS(this.page) || null,
11778
11809
  settingsStr: JSON.stringify(this.theme.settings || {}),
11810
+ merchantSettings: this.merchantSettings
11811
+ ? JSON.stringify(this.merchantSettings)
11812
+ : null,
11779
11813
  },
11780
11814
  };
11781
11815
  },
@@ -11793,6 +11827,24 @@ var IkasPageDataProvider = /** @class */ (function () {
11793
11827
  enumerable: false,
11794
11828
  configurable: true
11795
11829
  });
11830
+ IkasPageDataProvider.prototype.getMerchantSettings = function () {
11831
+ return __awaiter(this, void 0, void 0, function () {
11832
+ var merchantId, merchantSettingsResponse;
11833
+ return __generator(this, function (_a) {
11834
+ switch (_a.label) {
11835
+ case 0:
11836
+ merchantId = decodeBase64(IkasStorefrontConfig.config.apiKey || "");
11837
+ return [4 /*yield*/, IkasMerchantAPI.listMerchantSettings(merchantId)];
11838
+ case 1:
11839
+ merchantSettingsResponse = _a.sent();
11840
+ if (merchantSettingsResponse) {
11841
+ this.merchantSettings = merchantSettingsResponse;
11842
+ }
11843
+ return [2 /*return*/];
11844
+ }
11845
+ });
11846
+ });
11847
+ };
11796
11848
  IkasPageDataProvider.prototype.getPageData = function () {
11797
11849
  return __awaiter(this, void 0, void 0, function () {
11798
11850
  var _a;
@@ -11808,11 +11860,14 @@ var IkasPageDataProvider = /** @class */ (function () {
11808
11860
  case 2:
11809
11861
  if (!this.page)
11810
11862
  return [2 /*return*/];
11863
+ return [4 /*yield*/, this.getMerchantSettings()];
11864
+ case 3:
11865
+ _b.sent();
11811
11866
  _a = this;
11812
11867
  return [4 /*yield*/, Promise.all(this.page.components.map(function (pageComponent) {
11813
11868
  return _this.getPageComponentPropValues(pageComponent);
11814
11869
  }))];
11815
- case 3:
11870
+ case 4:
11816
11871
  _a.pageComponentPropValues = _b.sent();
11817
11872
  return [2 /*return*/];
11818
11873
  }
@@ -12274,34 +12329,6 @@ var IkasPageComponentPropValue = /** @class */ (function () {
12274
12329
  return IkasPageComponentPropValue;
12275
12330
  }());
12276
12331
 
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
12332
  var formatMoney = function (price, currency) {
12306
12333
  var locale = typeof navigator !== "undefined"
12307
12334
  ? navigator.languages
@@ -24957,18 +24984,64 @@ var PolicyModal = mobxReactLite.observer(function (_a) {
24957
24984
  });
24958
24985
 
24959
24986
  var IkasPageHead = mobxReactLite.observer(function (_a) {
24960
- var page = _a.page, pageTitle = _a.pageTitle, description = _a.description, pageSpecificDataStr = _a.pageSpecificDataStr;
24961
- var schema;
24987
+ var page = _a.page, pageTitle = _a.pageTitle, description = _a.description, pageSpecificDataStr = _a.pageSpecificDataStr, props = __rest(_a, ["page", "pageTitle", "description", "pageSpecificDataStr"]);
24988
+ var schemas = [];
24989
+ if (props.merchantSettings) {
24990
+ var merchantSettings = new IkasMerchantSettings(JSON.parse(props.merchantSettings));
24991
+ var websiteSchema = createWebsiteSchema();
24992
+ var storeSchema = createStoreSchema(merchantSettings);
24993
+ schemas.push(websiteSchema);
24994
+ schemas.push(storeSchema);
24995
+ }
24962
24996
  if (pageSpecificDataStr && (page === null || page === void 0 ? void 0 : page.type) === exports.IkasThemePageType.PRODUCT) {
24963
- schema = createProductSchema(pageSpecificDataStr);
24997
+ var schema = createProductSchema(pageSpecificDataStr);
24998
+ if (schema)
24999
+ schemas.push(schema);
25000
+ }
25001
+ if (pageSpecificDataStr && (page === null || page === void 0 ? void 0 : page.type) === exports.IkasThemePageType.CATEGORY) {
25002
+ var categorySchema = createCategorySchema(pageSpecificDataStr);
25003
+ if (categorySchema)
25004
+ schemas.push(categorySchema);
25005
+ // TODO
25006
+ // const categoryBreadcrumbSchema = createCategoryBreadcrumbSchema(
25007
+ // pageSpecificDataStr
25008
+ // );
25009
+ // if (categoryBreadcrumbSchema) schemas.push(categoryBreadcrumbSchema);
24964
25010
  }
24965
25011
  return (React.createElement(Head__default['default'], null,
24966
25012
  React.createElement("title", null, pageTitle || ""),
24967
25013
  React.createElement("meta", { name: "description", content: description || "" }),
24968
- !!schema && (React.createElement("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
24969
- __html: JSON.stringify(schema),
24970
- } }))));
25014
+ !!schemas.length &&
25015
+ schemas.map(function (schema, index) { return (React.createElement("script", { key: index, type: "application/ld+json", dangerouslySetInnerHTML: {
25016
+ __html: JSON.stringify(schema),
25017
+ } })); })));
24971
25018
  });
25019
+ function createWebsiteSchema(merchantSettings) {
25020
+ var _a;
25021
+ var hostname = "";
25022
+ if (typeof window !== "undefined") {
25023
+ hostname = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.hostname;
25024
+ }
25025
+ return {
25026
+ "@context": "https://schema.org",
25027
+ "@type": "Website",
25028
+ url: "https://" + hostname,
25029
+ };
25030
+ }
25031
+ function createStoreSchema(merchantSettings) {
25032
+ var _a, _b;
25033
+ var hostname = "";
25034
+ if (typeof window !== "undefined") {
25035
+ hostname = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.hostname;
25036
+ }
25037
+ return {
25038
+ "@context": "https://schema.org",
25039
+ "@type": "Store",
25040
+ name: merchantSettings === null || merchantSettings === void 0 ? void 0 : merchantSettings.merchantName,
25041
+ logo: (_b = merchantSettings === null || merchantSettings === void 0 ? void 0 : merchantSettings.logo) === null || _b === void 0 ? void 0 : _b.src,
25042
+ url: "https://" + hostname,
25043
+ };
25044
+ }
24972
25045
  function createProductSchema(pageSpecificDataStr) {
24973
25046
  var _a;
24974
25047
  try {
@@ -25013,7 +25086,43 @@ function createProductSchema(pageSpecificDataStr) {
25013
25086
  };
25014
25087
  }
25015
25088
  catch (err) { }
25016
- }
25089
+ }
25090
+ function createCategorySchema(pageSpecificDataStr) {
25091
+ var _a, _b, _c;
25092
+ try {
25093
+ var categoryParsed = JSON.parse(pageSpecificDataStr);
25094
+ var category = new IkasCategory(categoryParsed);
25095
+ return {
25096
+ "@context": "http://schema.org",
25097
+ "@type": "CollectionPage",
25098
+ url: "https://" + window.location.hostname + category.href,
25099
+ name: (_a = category.metaData) === null || _a === void 0 ? void 0 : _a.pageTitle,
25100
+ description: (_b = category.metaData) === null || _b === void 0 ? void 0 : _b.description,
25101
+ image: (_c = category.image) === null || _c === void 0 ? void 0 : _c.src,
25102
+ };
25103
+ }
25104
+ catch (_d) { }
25105
+ }
25106
+ // TODO - Waiting for CategoryParentTree feature
25107
+ // 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
25108
+ // function createCategoryBreadcrumbSchema(pageSpecificDataStr: string) {
25109
+ // try {
25110
+ // const categoryParsed = JSON.parse(pageSpecificDataStr) as IkasCategory;
25111
+ // const category = new IkasCategory(categoryParsed);
25112
+ // return {
25113
+ // "@context": "http://schema.org",
25114
+ // "@type": "BreadcrumbList",
25115
+ // "itemListElement": [
25116
+ // {
25117
+ // "@type": "ListItem",
25118
+ // "position": 1,
25119
+ // "name": "category.name",
25120
+ // "item": "https://" + window.location.hostname + "category.href"
25121
+ // }
25122
+ // ]
25123
+ // };
25124
+ // } catch {}
25125
+ // }
25017
25126
 
25018
25127
  var IkasCheckoutPage = mobxReactLite.observer(function (_a) {
25019
25128
  var _b, _c, _d;
@@ -25179,7 +25288,7 @@ var ThemeComponent = mobxReactLite.observer(function (_a) {
25179
25288
 
25180
25289
  var IkasPage = mobxReactLite.observer(function (_a) {
25181
25290
  var _b, _c;
25182
- var propValues = _a.propValues, page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, settingsStr = _a.settingsStr;
25291
+ var propValues = _a.propValues, page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
25183
25292
  var renderComponent = function (pageComponent, index) {
25184
25293
  var pageComponentPropValue = propValues.find(function (pv) { return pv.pageComponent.id === pageComponent.id; });
25185
25294
  return (React.createElement(ThemeComponent, { key: pageComponent.id, index: index, pageComponentPropValue: pageComponentPropValue, pageComponent: pageComponent, settingsStr: settingsStr }));
@@ -25192,7 +25301,7 @@ var IkasPage = mobxReactLite.observer(function (_a) {
25192
25301
  if (!page)
25193
25302
  return null;
25194
25303
  return (React.createElement(React.Fragment, null,
25195
- React.createElement(IkasPageHead, { page: page, pageTitle: page.pageTitle, description: page.description, pageSpecificDataStr: pageSpecificDataStr }),
25304
+ React.createElement(IkasPageHead, { page: page, pageTitle: page.pageTitle, description: page.description, pageSpecificDataStr: pageSpecificDataStr, merchantSettings: merchantSettings }),
25196
25305
  React.createElement("div", { style: pageStyle },
25197
25306
  React.createElement("div", null,
25198
25307
  headerComponent && renderComponent(headerComponent, -1),
@@ -25678,10 +25787,10 @@ var index = /*#__PURE__*/Object.freeze({
25678
25787
  });
25679
25788
 
25680
25789
  var Page = function (_a) {
25681
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
25790
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
25682
25791
  var router$1 = router.useRouter();
25683
25792
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router$1);
25684
- return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
25793
+ return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
25685
25794
  };
25686
25795
  var getStaticProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
25687
25796
  var theme, provider;
@@ -25706,7 +25815,7 @@ var home = /*#__PURE__*/Object.freeze({
25706
25815
  });
25707
25816
 
25708
25817
  var Page$1 = function (_a) {
25709
- var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
25818
+ var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
25710
25819
  var router$1 = router.useRouter();
25711
25820
  var _b = React.useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
25712
25821
  var _c = React.useState(IkasPageDataProvider.initPropValues(propValuesStr, router$1)), propValues = _c[0], setPropValues = _c[1];
@@ -25717,7 +25826,7 @@ var Page$1 = function (_a) {
25717
25826
  setPropValues(IkasPageDataProvider.initPropValues(propValuesStr, router$1, isBrowser));
25718
25827
  }, [isBrowser, propValuesStr]);
25719
25828
  handleGTM(page, pageSpecificDataStr);
25720
- return (React.createElement(IkasPage, { page: page, propValues: propValues, pageSpecificDataStr: pageSpecificDataStr, settingsStr: settingsStr }));
25829
+ return (React.createElement(IkasPage, { page: page, propValues: propValues, pageSpecificDataStr: pageSpecificDataStr, settingsStr: settingsStr, merchantSettings: merchantSettings }));
25721
25830
  };
25722
25831
  var index$1 = mobxReactLite.observer(Page$1);
25723
25832
  var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void 0, function () {
@@ -26033,10 +26142,10 @@ var _id_$2 = /*#__PURE__*/Object.freeze({
26033
26142
  });
26034
26143
 
26035
26144
  var Page$7 = function (_a) {
26036
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26145
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26037
26146
  var router$1 = router.useRouter();
26038
26147
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router$1);
26039
- return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26148
+ return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26040
26149
  };
26041
26150
  var getStaticProps$6 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26042
26151
  var theme, provider;
@@ -26061,10 +26170,10 @@ var login = /*#__PURE__*/Object.freeze({
26061
26170
  });
26062
26171
 
26063
26172
  var Page$8 = function (_a) {
26064
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26173
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26065
26174
  var router$1 = router.useRouter();
26066
26175
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router$1);
26067
- return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26176
+ return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26068
26177
  };
26069
26178
  var getStaticProps$7 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26070
26179
  var theme, provider;
@@ -26089,10 +26198,10 @@ var register = /*#__PURE__*/Object.freeze({
26089
26198
  });
26090
26199
 
26091
26200
  var Page$9 = function (_a) {
26092
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26201
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26093
26202
  var router$1 = router.useRouter();
26094
26203
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router$1);
26095
- return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26204
+ return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26096
26205
  };
26097
26206
  var getStaticProps$8 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26098
26207
  var theme, provider;
@@ -26117,10 +26226,10 @@ var forgotPassword = /*#__PURE__*/Object.freeze({
26117
26226
  });
26118
26227
 
26119
26228
  var Page$a = function (_a) {
26120
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
26229
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
26121
26230
  var router$1 = router.useRouter();
26122
26231
  var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router$1);
26123
- return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
26232
+ return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
26124
26233
  };
26125
26234
  var getStaticProps$9 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
26126
26235
  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 | null;
13
14
  constructor(theme: IkasTheme, pageParams?: Record<string, any>, pageType?: IkasThemePageType);
14
15
  get page(): IkasThemePage | undefined;
15
16
  get nextPageData(): {
@@ -17,9 +18,11 @@ export declare class IkasPageDataProvider {
17
18
  propValuesStr: string;
18
19
  page: IkasThemePage | null;
19
20
  settingsStr: string;
21
+ merchantSettings: string | null;
20
22
  };
21
23
  };
22
24
  get isStaticPage(): boolean | null | undefined;
25
+ getMerchantSettings(): Promise<void>;
23
26
  getPageData(): Promise<void>;
24
27
  getPageSpecificData(): Promise<void>;
25
28
  getPageSpecificProduct(): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",