@ikas/storefront 4.3.0-beta.3 → 4.3.0-beta.4
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as r,computed as i,observable as a,action as s}from"mobx";import{Validator as o}from"../index.js";import{IkasBaseStore as n}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{RequiredRule as u,EmailRule as d,MinRule as m}from"../rules/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import{IkasCustomerAttributeType as l,IkasCustomerAttributeRegisterPageRequirement as c}from"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import"../../../data/checkout/country-settings-model.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import"../../../data/customer/address/index.js";import"../../../data/customer/address/ikas-localized-customer-address.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";var p=function(){function p(t){var e=this;this.model={firstName:"",lastName:"",email:"",password:"",attributes:void 0,isMarketingAccepted:!1},this.isFormSubmit=!1,this._customerAttributes=void 0,this.onFirstNameChange=function(t){e.firstName=t},this.onLastNameChange=function(t){e.lastName=t},this.onEmailChange=function(t){e.email=t},this.onPasswordChange=function(t){e.password=t},this.setCustomerAttributes=function(t){e._customerAttributes=(null==t?void 0:t.filter((function(t){return t.registerPageRequirement!==c.INVISIBLE})).map((function(t){return{attribute:t,attributeValue:{isChecked:void 0,value:void 0,selectedIdList:void 0},validator:{isRequired:t.registerPageRequirement===c.MANDATORY,hasError:!1,message:""}}})))||[]},this.onAttributeChange=function(t,r){var i;if(e._customerAttributes){var a=e._customerAttributes.find((function(e){return e.attribute.id===t}));if(a){var s=null===(i=e._customerAttributes)||void 0===i?void 0:i.findIndex((function(e){return e.attribute.id===t}));void 0!==s&&-1!==s&&(e._customerAttributes[s].attributeValue=e.getAttributeValue(a.attribute,r),e.validateCustomerAttribute())}}},r(this,{emailErrorMessage:i,passwordErrorMessage:i,firstNameErrorMessage:i,lastNameErrorMessage:i,hasError:i,redirect:i,model:a,validateAll:s,register:s,customerAttributes:i,_customerAttributes:a}),this.message=t.message,this.validator=new o(this.model,[new u({fieldKey:"firstName",valuePath:"firstName",message:t.message.requiredRule}),new u({fieldKey:"lastName",valuePath:"lastName",message:t.message.requiredRule}),new u({fieldKey:"email",valuePath:"email",message:t.message.requiredRule}),new u({fieldKey:"password",valuePath:"password",message:t.message.requiredRule}),new d({fieldKey:"email",valuePath:"email",message:t.message.emailRule}),new m({fieldKey:"password",valuePath:"password",minValue:6,message:t.message.minRule})])}return Object.defineProperty(p.prototype,"firstName",{get:function(){return this.model.firstName},set:function(t){this.model.firstName=t},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"lastName",{get:function(){return this.model.lastName},set:function(t){this.model.lastName=t},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"email",{get:function(){return this.model.email},set:function(t){this.model.email=t},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"password",{get:function(){return this.model.password},set:function(t){this.model.password=t},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isMarketingAccepted",{get:function(){return this.model.isMarketingAccepted},set:function(t){this.model.isMarketingAccepted=t},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"firstNameErrorMessage",{get:function(){return this.validator.results.firstName.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"lastNameErrorMessage",{get:function(){return this.validator.results.lastName.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"emailErrorMessage",{get:function(){return this.validator.results.email.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"passwordErrorMessage",{get:function(){return this.validator.results.password.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"attributes",{get:function(){return this.model.attributes},set:function(t){this.model.attributes=t},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"redirect",{get:function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("redirect")},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"customerAttributes",{get:function(){return this._customerAttributes},enumerable:!1,configurable:!0}),p.prototype.getAttributeValue=function(t,e){var r={isChecked:void 0,value:void 0,selectedIdList:void 0};if("string"!=typeof e||t.type!==l.TEXT&&t.type!==l.DATETIME&&t.type!==l.CHOICE||(r.value=e),"string"==typeof e&&t.type===l.NUMERIC){var i=parseInt(e);isNaN(i)?r.value=r.value||"":r.value=e}return"boolean"==typeof e&&t.type===l.BOOLEAN&&(r.isChecked=e),"object"==typeof e&&t.type===l.MULTIPLE_CHOICE&&(r.selectedIdList=e),r},Object.defineProperty(p.prototype,"formattedAttributesInput",{get:function(){if(!this._customerAttributes)return null;if(!this._customerAttributes.some((function(t){return void 0!==t.attributeValue.value||void 0!==t.attributeValue.isChecked||void 0!==t.attributeValue.selectedIdList})))return null;var t=[];return this._customerAttributes.map((function(e){var r=e.attributeValue,i=r.selectedIdList,a=r.isChecked,s=r.value;void 0!==i&&l.MULTIPLE_CHOICE&&i.map((function(r){t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:r,value:null})})),e.attribute.type===l.BOOLEAN&&t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:null,value:a?a.toString():"false"}),void 0!==s&&(e.attribute.type!==l.TEXT&&e.attribute.type!==l.NUMERIC||t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:null,value:s.toString()}),e.attribute.type===l.CHOICE&&t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:s,value:null}),e.attribute.type===l.DATETIME&&t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:null,value:new Date(s).getTime().toString()}))})),t},enumerable:!1,configurable:!0}),p.prototype.validateCustomerAttribute=function(){var t,e=this;this._customerAttributes=null===(t=this._customerAttributes)||void 0===t?void 0:t.map((function(t){var r;return t.validator.isRequired&&e.isFormSubmit&&(t.attributeValue.value||(null===(r=t.attributeValue.selectedIdList)||void 0===r?void 0:r.length)?(t.validator.hasError=!1,t.validator.message=""):(t.validator.hasError=!0,t.validator.message="string"==typeof e.message.requiredRule?e.message.requiredRule:e.message.requiredRule(e.model))),t}))},p.prototype.validateAll=function(){var r;return t(this,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this.validateCustomerAttribute(),[4,this.validator.validateAll()];case 1:return t=e.sent(),i=null===(r=this._customerAttributes)||void 0===r?void 0:r.some((function(t){return t.validator.hasError})),[2,t||i]}}))}))},p.prototype.register=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isFormSubmit=!0,t={isFormError:!1,isSuccess:!1},[4,this.validateAll()];case 1:if(e.sent())return t.isFormError=!0,[2,t];e.label=2;case 2:return e.trys.push([2,4,,5]),[4,n.getInstance().customerStore.register(this.model.firstName,this.model.lastName,this.model.email,this.model.password,this.model.isMarketingAccepted,this.model.attributes||this.formattedAttributesInput||void 0)];case 3:return e.sent()&&(t.isSuccess=!0),[2,t];case 4:return e.sent(),[2,t];case 5:return[2]}}))}))},p}();export{p as RegisterForm};
|
|
1
|
+
import{__awaiter as t,__generator as e}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as r,computed as i,observable as a,action as s}from"mobx";import{Validator as o}from"../index.js";import{IkasBaseStore as n}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{RequiredRule as u,EmailRule as d,MinRule as m}from"../rules/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import{IkasCustomerAttributeType as l,IkasCustomerAttributeRegisterPageRequirement as c}from"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import"../../../data/checkout/country-settings-model.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import"../../../data/customer/address/index.js";import"../../../data/customer/address/ikas-localized-customer-address.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";var p=function(){function p(t){var e=this;this.model={firstName:"",lastName:"",email:"",password:"",attributes:void 0,isMarketingAccepted:!1},this.isFormSubmit=!1,this._customerAttributes=void 0,this.onFirstNameChange=function(t){e.firstName=t},this.onLastNameChange=function(t){e.lastName=t},this.onEmailChange=function(t){e.email=t},this.onPasswordChange=function(t){e.password=t},this.setCustomerAttributes=function(t){e._customerAttributes=(null==t?void 0:t.filter((function(t){return t.registerPageRequirement!==c.INVISIBLE})).map((function(t){return{attribute:t,attributeValue:{isChecked:void 0,value:void 0,selectedIdList:void 0},validator:{isRequired:t.registerPageRequirement===c.MANDATORY,hasError:!1,message:""}}})))||[]},this.onAttributeChange=function(t,r){var i;if(e._customerAttributes){var a=e._customerAttributes.find((function(e){return e.attribute.id===t}));if(a){var s=null===(i=e._customerAttributes)||void 0===i?void 0:i.findIndex((function(e){return e.attribute.id===t}));void 0!==s&&-1!==s&&(e._customerAttributes[s].attributeValue=e.getAttributeValue(a.attribute,r),e.validateCustomerAttribute())}}},r(this,{emailErrorMessage:i,passwordErrorMessage:i,firstNameErrorMessage:i,lastNameErrorMessage:i,hasError:i,redirect:i,model:a,validateAll:s,register:s,customerAttributes:i,_customerAttributes:a}),this.message=t.message,this.validator=new o(this.model,[new u({fieldKey:"firstName",valuePath:"firstName",message:t.message.requiredRule}),new u({fieldKey:"lastName",valuePath:"lastName",message:t.message.requiredRule}),new u({fieldKey:"email",valuePath:"email",message:t.message.requiredRule}),new u({fieldKey:"password",valuePath:"password",message:t.message.requiredRule}),new d({fieldKey:"email",valuePath:"email",message:t.message.emailRule}),new m({fieldKey:"password",valuePath:"password",minValue:6,message:t.message.minRule})])}return Object.defineProperty(p.prototype,"firstName",{get:function(){return this.model.firstName},set:function(t){this.model.firstName=t},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"lastName",{get:function(){return this.model.lastName},set:function(t){this.model.lastName=t},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"email",{get:function(){return this.model.email},set:function(t){this.model.email=t},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"password",{get:function(){return this.model.password},set:function(t){this.model.password=t},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isMarketingAccepted",{get:function(){return this.model.isMarketingAccepted},set:function(t){this.model.isMarketingAccepted=t},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"firstNameErrorMessage",{get:function(){return this.validator.results.firstName.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"lastNameErrorMessage",{get:function(){return this.validator.results.lastName.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"emailErrorMessage",{get:function(){return this.validator.results.email.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"passwordErrorMessage",{get:function(){return this.validator.results.password.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"attributes",{get:function(){return this.model.attributes},set:function(t){this.model.attributes=t},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"redirect",{get:function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("redirect")},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"customerAttributes",{get:function(){return this._customerAttributes},enumerable:!1,configurable:!0}),p.prototype.getAttributeValue=function(t,e){var r={isChecked:void 0,value:void 0,selectedIdList:void 0};if("string"!=typeof e||t.type!==l.TEXT&&t.type!==l.DATETIME&&t.type!==l.CHOICE||(r.value=e),"string"==typeof e&&t.type===l.NUMERIC){var i=parseInt(e);isNaN(i)?r.value=r.value||"":r.value=e}return"boolean"==typeof e&&t.type===l.BOOLEAN&&(r.isChecked=e),"object"==typeof e&&t.type===l.MULTIPLE_CHOICE&&(r.selectedIdList=e),r},Object.defineProperty(p.prototype,"formattedAttributesInput",{get:function(){if(!this._customerAttributes)return null;if(!this._customerAttributes.some((function(t){return void 0!==t.attributeValue.value||void 0!==t.attributeValue.isChecked||void 0!==t.attributeValue.selectedIdList})))return null;var t=[];return this._customerAttributes.map((function(e){var r=e.attributeValue,i=r.selectedIdList,a=r.isChecked,s=r.value;void 0!==i&&l.MULTIPLE_CHOICE&&i.map((function(r){t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:r,value:null})})),e.attribute.type===l.BOOLEAN&&t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:null,value:a?a.toString():"false"}),void 0!==s&&(e.attribute.type!==l.TEXT&&e.attribute.type!==l.NUMERIC||t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:null,value:s.toString()}),e.attribute.type===l.CHOICE&&t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:s,value:null}),e.attribute.type===l.DATETIME&&t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:null,value:new Date(s).getTime().toString()}))})),t},enumerable:!1,configurable:!0}),p.prototype.validateCustomerAttribute=function(){var t,e=this;this._customerAttributes=null===(t=this._customerAttributes)||void 0===t?void 0:t.map((function(t){var r;return t.validator.isRequired&&e.isFormSubmit&&(t.attribute.type===l.BOOLEAN||t.attributeValue.value||(null===(r=t.attributeValue.selectedIdList)||void 0===r?void 0:r.length)?(t.validator.hasError=!1,t.validator.message=""):(t.validator.hasError=!0,t.validator.message="string"==typeof e.message.requiredRule?e.message.requiredRule:e.message.requiredRule(e.model))),t}))},p.prototype.validateAll=function(){var r;return t(this,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this.validateCustomerAttribute(),[4,this.validator.validateAll()];case 1:return t=e.sent(),i=null===(r=this._customerAttributes)||void 0===r?void 0:r.some((function(t){return t.validator.hasError})),[2,t||i]}}))}))},p.prototype.register=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isFormSubmit=!0,t={isFormError:!1,isSuccess:!1},[4,this.validateAll()];case 1:if(e.sent())return t.isFormError=!0,[2,t];e.label=2;case 2:return e.trys.push([2,4,,5]),[4,n.getInstance().customerStore.register(this.model.firstName,this.model.lastName,this.model.email,this.model.password,this.model.isMarketingAccepted,this.model.attributes||this.formattedAttributesInput||void 0)];case 3:return e.sent()&&(t.isSuccess=!0),[2,t];case 4:return e.sent(),[2,t];case 5:return[2]}}))}))},p}();export{p as RegisterForm};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "4.3.0-beta.
|
|
3
|
+
"version": "4.3.0-beta.4",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@adyen/adyen-web": "^5.28.2",
|
|
21
|
-
"@ikas/storefront-api": "^4.3.0-beta.
|
|
22
|
-
"@ikas/storefront-config": "^4.3.0-beta.
|
|
23
|
-
"@ikas/storefront-model-functions": "^4.3.0-beta.
|
|
24
|
-
"@ikas/storefront-models": "^4.3.0-beta.
|
|
25
|
-
"@ikas/storefront-providers": "^4.3.0-beta.
|
|
21
|
+
"@ikas/storefront-api": "^4.3.0-beta.4",
|
|
22
|
+
"@ikas/storefront-config": "^4.3.0-beta.4",
|
|
23
|
+
"@ikas/storefront-model-functions": "^4.3.0-beta.4",
|
|
24
|
+
"@ikas/storefront-models": "^4.3.0-beta.4",
|
|
25
|
+
"@ikas/storefront-providers": "^4.3.0-beta.4",
|
|
26
26
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
27
27
|
"@rollup/plugin-json": "^4.1.0",
|
|
28
28
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"libphonenumber-js": "^1.10.6"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@ikas/storefront-api": "^4.3.0-beta.
|
|
56
|
-
"@ikas/storefront-config": "^4.3.0-beta.
|
|
57
|
-
"@ikas/storefront-model-functions": "^4.3.0-beta.
|
|
58
|
-
"@ikas/storefront-models": "^4.3.0-beta.
|
|
59
|
-
"@ikas/storefront-providers": "^4.3.0-beta.
|
|
55
|
+
"@ikas/storefront-api": "^4.3.0-beta.4",
|
|
56
|
+
"@ikas/storefront-config": "^4.3.0-beta.4",
|
|
57
|
+
"@ikas/storefront-model-functions": "^4.3.0-beta.4",
|
|
58
|
+
"@ikas/storefront-models": "^4.3.0-beta.4",
|
|
59
|
+
"@ikas/storefront-providers": "^4.3.0-beta.4",
|
|
60
60
|
"mobx": "^6.1.3",
|
|
61
61
|
"mobx-react-lite": "^3.1.5",
|
|
62
62
|
"next": "12.2.0",
|