@ikas/storefront 6.1.0-beta.153 → 6.1.0-beta.154
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/models/ui/validator/form/login.d.ts +1 -1
- package/build/models/ui/validator/form/login.js +1 -1
- package/build/models/ui/validator/form/register.d.ts +1 -1
- package/build/models/ui/validator/form/register.js +1 -1
- package/build/store/customer/index.d.ts +1 -1
- package/package.json +11 -11
|
@@ -34,7 +34,7 @@ export declare class LoginForm {
|
|
|
34
34
|
get redirect(): string | null | undefined;
|
|
35
35
|
onEmailChange: (value: string) => void;
|
|
36
36
|
onPasswordChange: (value: string) => void;
|
|
37
|
-
onSmsLoginChange: (value: boolean) => void;
|
|
37
|
+
onSmsLoginChange: (value: boolean, flowId?: string | null) => void;
|
|
38
38
|
onPhoneChange: (value: string) => void;
|
|
39
39
|
validateAll(): Promise<boolean>;
|
|
40
40
|
login(): Promise<LoginResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as r,__spreadArray as o}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as s,computed as t,observable as i,action as n}from"mobx";import{Validator as a}from"../index.js";import{IkasBaseStore as l}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{PhoneRule as u,RequiredRule as d,EmailRule as m,MinRule as p}from"../rules/index.js";var h=function(){function h(e){var r=this;this.model={email:"",password:"",isSmsLogin:!1,phone:null},this.validatorRules=function(e){return void 0===e&&(e=!1),o([new d({fieldKey:"email",valuePath:"email",message:r.message.requiredRule}),new d({fieldKey:"password",valuePath:"password",message:r.message.requiredRule}),new m({fieldKey:"email",valuePath:"email",message:r.message.emailRule}),new p({fieldKey:"password",valuePath:"password",minValue:6,message:r.message.minRule})],e?[new u({fieldKey:"phone",valuePath:"phone",message:r.message.phoneRule})]:[],!0)},this.onEmailChange=function(e){r.email=e},this.onPasswordChange=function(e){r.password=e},this.onSmsLoginChange=function(e){e?(r.validator.setRules([new d({fieldKey:"phone",valuePath:"phone",message:r.message.phoneRule}),new u({fieldKey:"phone",valuePath:"phone",message:r.message.phoneRule})]),r.model.email=void 0,r.model.password=void 0):r.validator.setRules(r.validatorRules()),r.isSmsLogin=e},this.onPhoneChange=function(e){r.phone=e},s(this,{emailErrorMessage:t,passwordErrorMessage:t,hasError:t,redirect:t,email:t,password:t,model:i,validateAll:n,login:n,phoneErrorMessage:t}),this.message=e.message,this.validator=new a(this.model,this.validatorRules())}return Object.defineProperty(h.prototype,"phone",{get:function(){return this.model.phone},set:function(e){this.model.phone=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"email",{get:function(){return this.model.email},set:function(e){this.model.email=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"password",{get:function(){return this.model.password},set:function(e){this.model.password=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"emailErrorMessage",{get:function(){var e;return null===(e=this.validator.results.email)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"passwordErrorMessage",{get:function(){var e;return null===(e=this.validator.results.password)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"phoneErrorMessage",{get:function(){var e;return null===(e=this.validator.results.phone)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isSmsLogin",{get:function(){return this.model.isSmsLogin},set:function(e){this.model.isSmsLogin=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"redirect",{get:function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("redirect")},enumerable:!1,configurable:!0}),h.prototype.validateAll=function(){return this.validator.validateAll()},h.prototype.login=function(){return e(this,void 0,void 0,(function(){var e,o;return r(this,(function(r){switch(r.label){case 0:return e={isFormError:!1,isSuccess:!1,errorCodes:[],otpSend:!1,flowId:null},[4,this.validateAll()];case 1:if(r.sent())return e.isFormError=!0,[2,e];r.label=2;case 2:return r.trys.push([2,4,,5]),[4,l.getInstance().customerStore.customerLogin(this.model.email,this.model.password,this.isSmsLogin?this.model.phone:void 0)];case 3:return o=r.sent(),e.isSuccess=o.isSuccess,e.errorCodes=o.errorCodes,e.otpSend=o.otpSend||!1,e.flowId=o.flowId||null,[2,e];case 4:return r.sent(),[2,e];case 5:return[2]}}))}))},h}();export{h as LoginForm};
|
|
1
|
+
import{__awaiter as e,__generator as r,__spreadArray as o}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as s,computed as t,observable as i,action as n}from"mobx";import{Validator as a}from"../index.js";import{IkasBaseStore as l}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{PhoneRule as u,RequiredRule as d,EmailRule as m,MinRule as p}from"../rules/index.js";var h=function(){function h(e){var r=this;this.model={email:"",password:"",isSmsLogin:!1,phone:null},this.validatorRules=function(e){return void 0===e&&(e=!1),o([new d({fieldKey:"email",valuePath:"email",message:r.message.requiredRule}),new d({fieldKey:"password",valuePath:"password",message:r.message.requiredRule}),new m({fieldKey:"email",valuePath:"email",message:r.message.emailRule}),new p({fieldKey:"password",valuePath:"password",minValue:6,message:r.message.minRule})],e?[new u({fieldKey:"phone",valuePath:"phone",message:r.message.phoneRule})]:[],!0)},this.onEmailChange=function(e){r.email=e},this.onPasswordChange=function(e){r.password=e},this.onSmsLoginChange=function(e,s){e?(r.validator.setRules(o(o([new d({fieldKey:"phone",valuePath:"phone",message:r.message.phoneRule}),new u({fieldKey:"phone",valuePath:"phone",message:r.message.phoneRule})],s?[new d({fieldKey:"email",valuePath:"email",message:r.message.requiredRule})]:[],!0),s?[new m({fieldKey:"email",valuePath:"email",message:r.message.emailRule})]:[],!0)),r.model.email=void 0,r.model.password=void 0):r.validator.setRules(r.validatorRules()),r.isSmsLogin=e},this.onPhoneChange=function(e){r.phone=e},s(this,{emailErrorMessage:t,passwordErrorMessage:t,hasError:t,redirect:t,email:t,password:t,model:i,validateAll:n,login:n,phoneErrorMessage:t}),this.message=e.message,this.validator=new a(this.model,this.validatorRules())}return Object.defineProperty(h.prototype,"phone",{get:function(){return this.model.phone},set:function(e){this.model.phone=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"email",{get:function(){return this.model.email},set:function(e){this.model.email=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"password",{get:function(){return this.model.password},set:function(e){this.model.password=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"emailErrorMessage",{get:function(){var e;return null===(e=this.validator.results.email)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"passwordErrorMessage",{get:function(){var e;return null===(e=this.validator.results.password)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"phoneErrorMessage",{get:function(){var e;return null===(e=this.validator.results.phone)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isSmsLogin",{get:function(){return this.model.isSmsLogin},set:function(e){this.model.isSmsLogin=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"redirect",{get:function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("redirect")},enumerable:!1,configurable:!0}),h.prototype.validateAll=function(){return this.validator.validateAll()},h.prototype.login=function(){return e(this,void 0,void 0,(function(){var e,o;return r(this,(function(r){switch(r.label){case 0:return e={isFormError:!1,isSuccess:!1,errorCodes:[],otpSend:!1,flowId:null},[4,this.validateAll()];case 1:if(r.sent())return e.isFormError=!0,[2,e];r.label=2;case 2:return r.trys.push([2,4,,5]),[4,l.getInstance().customerStore.customerLogin(this.model.email,this.model.password,this.isSmsLogin?this.model.phone:void 0)];case 3:return o=r.sent(),e.isSuccess=o.isSuccess,e.errorCodes=o.errorCodes,e.otpSend=o.otpSend||!1,e.flowId=o.flowId||null,[2,e];case 4:return r.sent(),[2,e];case 5:return[2]}}))}))},h}();export{h as LoginForm};
|
|
@@ -73,7 +73,7 @@ export declare class RegisterForm {
|
|
|
73
73
|
onEmailChange: (value: string) => void;
|
|
74
74
|
onPasswordChange: (value: string) => void;
|
|
75
75
|
onPhoneChange: (value: string) => void;
|
|
76
|
-
onSmsRegisterChange: (
|
|
76
|
+
onSmsRegisterChange: (isSmsRegister: boolean, flowId?: string | null) => void;
|
|
77
77
|
setCustomerAttributes: (customerAttributes: IkasCustomerAttribute[]) => void;
|
|
78
78
|
private getAttributeValue;
|
|
79
79
|
onAttributeChange: (attributeId: string, value: boolean | string | string[]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__spreadArray as r,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as o,computed as a,observable as s,action as n}from"mobx";import d from"lodash/toNumber";import{Validator as u}from"../index.js";import{IkasBaseStore as l}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{PhoneRule as m,RequiredRule as p,EmailRule as c,MinRule as f}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 b,IkasCustomerAttributeRegisterPageRequirement as h}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-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import"../../../data/customer/address/region/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/customer-form-data-input/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/region/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/order-transaction-with-prices/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/campaign-offer/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/shipping-zone/state/city/district/region/index.js";import"../../../data/state/index.js";import"../../../data/storefront-popup/storefront-popup-display-filter/index.js";import"../../../data/storefront-popup/storefront-popup-display-settings/index.js";import"../../../data/storefront-popup/storefront-popup-page-filter/index.js";import"../../../data/storefront-popup/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/component/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var g=function(){function g(e){var t=this;this.model={firstName:"",lastName:"",email:void 0,password:void 0,attributes:void 0,isMarketingAccepted:!1,phone:null,isSmsRegister:!1,flowId:null},this.isFormSubmit=!1,this._customerAttributes=void 0,this.validatorRules=function(e){return void 0===e&&(e=!1),r([new p({fieldKey:"firstName",valuePath:"firstName",message:t.message.requiredRule}),new p({fieldKey:"lastName",valuePath:"lastName",message:t.message.requiredRule}),new p({fieldKey:"email",valuePath:"email",message:t.message.requiredRule}),new p({fieldKey:"password",valuePath:"password",message:t.message.requiredRule}),new c({fieldKey:"email",valuePath:"email",message:t.message.emailRule}),new f({fieldKey:"password",valuePath:"password",minValue:6,message:t.message.minRule})],e?[new m({fieldKey:"phone",valuePath:"phone",message:t.message.phoneRule})]:[],!0)},this.onFirstNameChange=function(e){t.firstName=e},this.onLastNameChange=function(e){t.lastName=e},this.onEmailChange=function(e){t.email=e},this.onPasswordChange=function(e){t.password=e},this.onPhoneChange=function(e){t.phone=e},this.onSmsRegisterChange=function(e){e?(t.validator.setRules([new p({fieldKey:"phone",valuePath:"phone",message:t.message.phoneRule}),new m({fieldKey:"phone",valuePath:"phone",message:t.message.phoneRule})]),t.model.email=void 0,t.model.password=void 0):t.validator.setRules(t.validatorRules()),t.isSmsRegister=e},this.setCustomerAttributes=function(e){t._customerAttributes=(null==e?void 0:e.filter((function(e){return e.registerPageRequirement!==h.INVISIBLE})).map((function(e){return{attribute:e,attributeValue:{isChecked:void 0,value:void 0,selectedIdList:void 0},validator:{isRequired:e.registerPageRequirement===h.MANDATORY,hasError:!1,message:""}}})))||[]},this.onAttributeChange=function(e,r){var i;if(t._customerAttributes){var o=t._customerAttributes.find((function(t){return t.attribute.id===e}));if(o){var a=null===(i=t._customerAttributes)||void 0===i?void 0:i.findIndex((function(t){return t.attribute.id===e}));void 0!==a&&-1!==a&&(t._customerAttributes[a].attributeValue=t.getAttributeValue(o.attribute,r),t.validateCustomerAttribute())}}},o(this,{emailErrorMessage:a,passwordErrorMessage:a,firstNameErrorMessage:a,lastNameErrorMessage:a,phoneErrorMessage:a,hasError:a,redirect:a,model:s,validateAll:n,register:n,customerAttributes:a,_customerAttributes:s}),this.message=e.message,this.validator=new u(this.model,this.validatorRules())}return Object.defineProperty(g.prototype,"firstName",{get:function(){return this.model.firstName},set:function(e){this.model.firstName=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"lastName",{get:function(){return this.model.lastName},set:function(e){this.model.lastName=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"email",{get:function(){return this.model.email},set:function(e){this.model.email=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"password",{get:function(){return this.model.password},set:function(e){this.model.password=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"isMarketingAccepted",{get:function(){return this.model.isMarketingAccepted},set:function(e){this.model.isMarketingAccepted=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"flowId",{get:function(){return this.model.flowId},set:function(e){this.model.flowId=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"isSmsRegister",{get:function(){return this.model.isSmsRegister},set:function(e){this.model.isSmsRegister=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"phone",{get:function(){return this.model.phone},set:function(e){this.model.phone=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"firstNameErrorMessage",{get:function(){var e;return null===(e=this.validator.results.firstName)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"lastNameErrorMessage",{get:function(){var e;return null===(e=this.validator.results.lastName)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"emailErrorMessage",{get:function(){var e;return null===(e=this.validator.results.email)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"passwordErrorMessage",{get:function(){var e;return null===(e=this.validator.results.password)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"phoneErrorMessage",{get:function(){var e;return null===(e=this.validator.results.phone)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"attributes",{get:function(){return this.model.attributes},set:function(e){this.model.attributes=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"redirect",{get:function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("redirect")},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"customerAttributes",{get:function(){return this._customerAttributes},enumerable:!1,configurable:!0}),g.prototype.getAttributeValue=function(e,t){var r={isChecked:void 0,value:void 0,selectedIdList:void 0};return"string"!=typeof t||e.type!==b.TEXT&&e.type!==b.DATETIME&&e.type!==b.DATE&&e.type!==b.CHOICE||(r.value=t),"string"==typeof t&&e.type===b.NUMERIC&&(Number.isInteger(d(t))?r.value=t:r.value=t.slice(0,-1)),"boolean"==typeof t&&e.type===b.BOOLEAN&&(r.isChecked=t),"object"==typeof t&&e.type===b.MULTIPLE_CHOICE&&(r.selectedIdList=t),r},Object.defineProperty(g.prototype,"formattedAttributesInput",{get:function(){if(!this._customerAttributes)return null;if(!this._customerAttributes.some((function(e){return void 0!==e.attributeValue.value||void 0!==e.attributeValue.isChecked||void 0!==e.attributeValue.selectedIdList})))return null;var e=[];return this._customerAttributes.map((function(t){var r=t.attributeValue,i=r.selectedIdList,o=r.isChecked,a=r.value;void 0!==i&&b.MULTIPLE_CHOICE&&i.map((function(r){e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:r,value:null})})),t.attribute.type===b.BOOLEAN&&e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:o?o.toString():"false"}),void 0!==a&&(t.attribute.type!==b.TEXT&&t.attribute.type!==b.NUMERIC||e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:a.toString()}),t.attribute.type===b.CHOICE&&e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:a,value:null}),t.attribute.type!==b.DATETIME&&t.attribute.type!==b.DATE||e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:new Date(a).getTime().toString()}))})),e},enumerable:!1,configurable:!0}),g.prototype.validateCustomerAttribute=function(){var e,t=this;this._customerAttributes=null===(e=this._customerAttributes)||void 0===e?void 0:e.map((function(e){var r;return e.validator.isRequired&&t.isFormSubmit&&(e.attribute.type===b.BOOLEAN||e.attributeValue.value||(null===(r=e.attributeValue.selectedIdList)||void 0===r?void 0:r.length)?(e.validator.hasError=!1,e.validator.message=""):(e.validator.hasError=!0,e.validator.message="string"==typeof t.message.requiredRule?t.message.requiredRule:t.message.requiredRule(t.model))),e}))},g.prototype.validateAll=function(){var r;return e(this,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return this.validateCustomerAttribute(),[4,this.validator.validateAll()];case 1:return e=t.sent(),i=null===(r=this._customerAttributes)||void 0===r?void 0:r.some((function(e){return e.validator.hasError})),[2,e||i]}}))}))},g.prototype.register=function(){return e(this,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return this.isFormSubmit=!0,e={isFormError:!1,isSuccess:!1,errorCodes:[],otpSend:!1,flowId:null},this.email&&(this.email=this.email.trim()),[4,this.validateAll()];case 1:if(t.sent())return e.isFormError=!0,[2,e];t.label=2;case 2:return t.trys.push([2,4,,5]),[4,l.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,this.model.phone,this.flowId?this.flowId:void 0)];case 3:return r=t.sent(),[2,i(i({},e),r)];case 4:return t.sent(),[2,e];case 5:return[2]}}))}))},g}();export{g as RegisterForm};
|
|
1
|
+
import{__awaiter as e,__generator as t,__spreadArray as r,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as a,computed as o,observable as s,action as n}from"mobx";import d from"lodash/toNumber";import{Validator as u}from"../index.js";import{IkasBaseStore as l}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{PhoneRule as m,RequiredRule as p,EmailRule as c,MinRule as f}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 g,IkasCustomerAttributeRegisterPageRequirement as h}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-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import"../../../data/customer/address/region/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/customer-form-data-input/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/region/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/order-transaction-with-prices/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/campaign-offer/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/shipping-zone/state/city/district/region/index.js";import"../../../data/state/index.js";import"../../../data/storefront-popup/storefront-popup-display-filter/index.js";import"../../../data/storefront-popup/storefront-popup-display-settings/index.js";import"../../../data/storefront-popup/storefront-popup-page-filter/index.js";import"../../../data/storefront-popup/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/component/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var b=function(){function b(e){var t=this;this.model={firstName:"",lastName:"",email:void 0,password:void 0,attributes:void 0,isMarketingAccepted:!1,phone:null,isSmsRegister:!1,flowId:null},this.isFormSubmit=!1,this._customerAttributes=void 0,this.validatorRules=function(e){return void 0===e&&(e=!1),r([new p({fieldKey:"firstName",valuePath:"firstName",message:t.message.requiredRule}),new p({fieldKey:"lastName",valuePath:"lastName",message:t.message.requiredRule}),new p({fieldKey:"email",valuePath:"email",message:t.message.requiredRule}),new p({fieldKey:"password",valuePath:"password",message:t.message.requiredRule}),new c({fieldKey:"email",valuePath:"email",message:t.message.emailRule}),new f({fieldKey:"password",valuePath:"password",minValue:6,message:t.message.minRule})],e?[new m({fieldKey:"phone",valuePath:"phone",message:t.message.phoneRule})]:[],!0)},this.onFirstNameChange=function(e){t.firstName=e},this.onLastNameChange=function(e){t.lastName=e},this.onEmailChange=function(e){t.email=e},this.onPasswordChange=function(e){t.password=e},this.onPhoneChange=function(e){t.phone=e},this.onSmsRegisterChange=function(e,i){e?(t.validator.setRules(r(r(r(r([new p({fieldKey:"phone",valuePath:"phone",message:t.message.phoneRule}),new m({fieldKey:"phone",valuePath:"phone",message:t.message.phoneRule})],i?[new p({fieldKey:"firstName",valuePath:"firstName",message:t.message.requiredRule})]:[],!0),i?[new p({fieldKey:"lastName",valuePath:"lastName",message:t.message.requiredRule})]:[],!0),i?[new p({fieldKey:"email",valuePath:"email",message:t.message.requiredRule})]:[],!0),i?[new c({fieldKey:"email",valuePath:"email",message:t.message.emailRule})]:[],!0)),t.model.password=void 0):t.validator.setRules(t.validatorRules()),t.isSmsRegister=e},this.setCustomerAttributes=function(e){t._customerAttributes=(null==e?void 0:e.filter((function(e){return e.registerPageRequirement!==h.INVISIBLE})).map((function(e){return{attribute:e,attributeValue:{isChecked:void 0,value:void 0,selectedIdList:void 0},validator:{isRequired:e.registerPageRequirement===h.MANDATORY,hasError:!1,message:""}}})))||[]},this.onAttributeChange=function(e,r){var i;if(t._customerAttributes){var a=t._customerAttributes.find((function(t){return t.attribute.id===e}));if(a){var o=null===(i=t._customerAttributes)||void 0===i?void 0:i.findIndex((function(t){return t.attribute.id===e}));void 0!==o&&-1!==o&&(t._customerAttributes[o].attributeValue=t.getAttributeValue(a.attribute,r),t.validateCustomerAttribute())}}},a(this,{emailErrorMessage:o,passwordErrorMessage:o,firstNameErrorMessage:o,lastNameErrorMessage:o,phoneErrorMessage:o,hasError:o,redirect:o,model:s,validateAll:n,register:n,customerAttributes:o,_customerAttributes:s}),this.message=e.message,this.validator=new u(this.model,this.validatorRules())}return Object.defineProperty(b.prototype,"firstName",{get:function(){return this.model.firstName},set:function(e){this.model.firstName=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"lastName",{get:function(){return this.model.lastName},set:function(e){this.model.lastName=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"email",{get:function(){return this.model.email},set:function(e){this.model.email=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"password",{get:function(){return this.model.password},set:function(e){this.model.password=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isMarketingAccepted",{get:function(){return this.model.isMarketingAccepted},set:function(e){this.model.isMarketingAccepted=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"flowId",{get:function(){return this.model.flowId},set:function(e){this.model.flowId=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isSmsRegister",{get:function(){return this.model.isSmsRegister},set:function(e){this.model.isSmsRegister=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"phone",{get:function(){return this.model.phone},set:function(e){this.model.phone=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"firstNameErrorMessage",{get:function(){var e;return null===(e=this.validator.results.firstName)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"lastNameErrorMessage",{get:function(){var e;return null===(e=this.validator.results.lastName)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"emailErrorMessage",{get:function(){var e;return null===(e=this.validator.results.email)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"passwordErrorMessage",{get:function(){var e;return null===(e=this.validator.results.password)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"phoneErrorMessage",{get:function(){var e;return null===(e=this.validator.results.phone)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"attributes",{get:function(){return this.model.attributes},set:function(e){this.model.attributes=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"redirect",{get:function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("redirect")},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"customerAttributes",{get:function(){return this._customerAttributes},enumerable:!1,configurable:!0}),b.prototype.getAttributeValue=function(e,t){var r={isChecked:void 0,value:void 0,selectedIdList:void 0};return"string"!=typeof t||e.type!==g.TEXT&&e.type!==g.DATETIME&&e.type!==g.DATE&&e.type!==g.CHOICE||(r.value=t),"string"==typeof t&&e.type===g.NUMERIC&&(Number.isInteger(d(t))?r.value=t:r.value=t.slice(0,-1)),"boolean"==typeof t&&e.type===g.BOOLEAN&&(r.isChecked=t),"object"==typeof t&&e.type===g.MULTIPLE_CHOICE&&(r.selectedIdList=t),r},Object.defineProperty(b.prototype,"formattedAttributesInput",{get:function(){if(!this._customerAttributes)return null;if(!this._customerAttributes.some((function(e){return void 0!==e.attributeValue.value||void 0!==e.attributeValue.isChecked||void 0!==e.attributeValue.selectedIdList})))return null;var e=[];return this._customerAttributes.map((function(t){var r=t.attributeValue,i=r.selectedIdList,a=r.isChecked,o=r.value;void 0!==i&&g.MULTIPLE_CHOICE&&i.map((function(r){e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:r,value:null})})),t.attribute.type===g.BOOLEAN&&e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:a?a.toString():"false"}),void 0!==o&&(t.attribute.type!==g.TEXT&&t.attribute.type!==g.NUMERIC||e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:o.toString()}),t.attribute.type===g.CHOICE&&e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:o,value:null}),t.attribute.type!==g.DATETIME&&t.attribute.type!==g.DATE||e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:new Date(o).getTime().toString()}))})),e},enumerable:!1,configurable:!0}),b.prototype.validateCustomerAttribute=function(){var e,t=this;this._customerAttributes=null===(e=this._customerAttributes)||void 0===e?void 0:e.map((function(e){var r;return e.validator.isRequired&&t.isFormSubmit&&(e.attribute.type===g.BOOLEAN||e.attributeValue.value||(null===(r=e.attributeValue.selectedIdList)||void 0===r?void 0:r.length)?(e.validator.hasError=!1,e.validator.message=""):(e.validator.hasError=!0,e.validator.message="string"==typeof t.message.requiredRule?t.message.requiredRule:t.message.requiredRule(t.model))),e}))},b.prototype.validateAll=function(){var r;return e(this,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return this.validateCustomerAttribute(),[4,this.validator.validateAll()];case 1:return e=t.sent(),i=null===(r=this._customerAttributes)||void 0===r?void 0:r.some((function(e){return e.validator.hasError})),[2,e||i]}}))}))},b.prototype.register=function(){return e(this,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return this.isFormSubmit=!0,e={isFormError:!1,isSuccess:!1,errorCodes:[],otpSend:!1,flowId:null},this.email&&(this.email=this.email.trim()),[4,this.validateAll()];case 1:if(t.sent())return e.isFormError=!0,[2,e];t.label=2;case 2:return t.trys.push([2,4,,5]),[4,l.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,this.model.phone,this.flowId?this.flowId:void 0)];case 3:return r=t.sent(),[2,i(i({},e),r)];case 4:return t.sent(),[2,e];case 5:return[2]}}))}))},b}();export{b as RegisterForm};
|
|
@@ -43,7 +43,7 @@ export declare class IkasCustomerStore {
|
|
|
43
43
|
errorCodes: IkasLoginError[];
|
|
44
44
|
}>;
|
|
45
45
|
logout: () => void;
|
|
46
|
-
register: (firstName
|
|
46
|
+
register: (firstName?: string, lastName?: string, email?: string, password?: string, isMarketingAccepted?: boolean, attributes?: IkasCustomerAttributeValue[], phone?: string | null, flowId?: string | null) => Promise<{
|
|
47
47
|
isSuccess: boolean;
|
|
48
48
|
errorCodes: IkasRegisterError[];
|
|
49
49
|
flowId?: undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "6.1.0-beta.
|
|
3
|
+
"version": "6.1.0-beta.154",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"swiper": "11.0.6"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
25
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
26
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
27
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
28
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
24
|
+
"@ikas/storefront-api": "^6.1.0-beta.154",
|
|
25
|
+
"@ikas/storefront-config": "^6.1.0-beta.154",
|
|
26
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.154",
|
|
27
|
+
"@ikas/storefront-models": "^6.1.0-beta.154",
|
|
28
|
+
"@ikas/storefront-providers": "^6.1.0-beta.154",
|
|
29
29
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
30
30
|
"@adyen/adyen-web": "^5.57.0",
|
|
31
31
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
63
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
64
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
65
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
66
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
67
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
63
|
+
"@ikas/storefront-api": "^6.1.0-beta.154",
|
|
64
|
+
"@ikas/storefront-config": "^6.1.0-beta.154",
|
|
65
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.154",
|
|
66
|
+
"@ikas/storefront-models": "^6.1.0-beta.154",
|
|
67
|
+
"@ikas/storefront-providers": "^6.1.0-beta.154",
|
|
68
68
|
"mobx": "^6.1.3",
|
|
69
69
|
"mobx-react-lite": "^3.1.5",
|
|
70
70
|
"next": "12.2.0",
|