@corva/dc-platform-shared 0.1.7-1 → 0.1.7-2
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
|
|
1
|
+
import n from"@babel/runtime/helpers/asyncToGenerator";import o from"@babel/runtime/helpers/slicedToArray";import r from"@babel/runtime/regenerator";import{memo as t,useState as e,useEffect as i}from"react";import a from"prop-types";import{styled as c,Grid as m,Button as p}from"@material-ui/core";import{showErrorNotification as s}from"@corva/ui/utils";import{initializeRecaptcha as u,GOOGLE_RECAPTCHA_KEY as l}from"@corva/ui/utils/recaptcha";import"../../../../components/Login/components/Login.js";import d from"../../../../components/Login/components/PasswordField.js";import f from"../../../../components/Login/components/Chip.js";import g from"../../../../components/Login/components/StepFooter.js";import h from"../../../../components/Login/components/StepContent.js";import v from"../../../../components/Login/components/StepHeader.js";import b from"../../../../components/Login/components/Step.js";import w from"../../../../components/Login/components/OrDivider.js";import j from"../../../../components/Login/components/HiddenEmailField.js";import"../../../../components/Login/components/EmailField.js";import{useAuth as L}from"../../../context/auth.js";import{NEED_HELP_EXTERNAL_LINK as y}from"../../../constants/index.js";import k from"./SSOButton.js";import{jsxs as S,jsx as x}from"react/jsx-runtime";var B=c(m)((function(n){var o=n.theme;return{marginTop:2*o.spacing(1),marginBottom:2*o.spacing(1),"&:first-of-type":{marginTop:0},"&:last-of-type":{marginBottom:0}}})),C=c(p)((function(n){var o=n.theme;return{width:71,padding:o.spacing(),whiteSpace:"nowrap",backgroundColor:o.status.loginButton,"&:hover":{backgroundColor:"".concat(o.status.loginButtonHovered)}}}));function F(t){var a=t.email,c=t.schemas,p=t.onBack,F=t.onFinishLogin,T=L(),q=e(""),H=o(q,2),R=H[0],E=H[1],I=e(!1),O=o(I,2),P=O[0],z=O[1],A=P?T.error:null;i((function(){u()}),[]);var D,_=(D=n(r.mark((function n(o){return r.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o.preventDefault(),window.grecaptcha){n.next=3;break}return n.abrupt("return",s("Problem with initializing recaptcha"));case 3:return n.abrupt("return",window.grecaptcha.enterprise.ready((function(){try{window.grecaptcha.enterprise.execute(l,{action:"login"}).then((function(n){T.login({email:a,password:R,recaptcha_token:n},F).then((function(){z(!0)}))})).catch((function(n){return console.error(n)}))}catch(n){console.error(n),s(n.message)}})));case 4:case"end":return n.stop()}}),n)}))),function(n){return D.apply(this,arguments)}),G=c.find((function(n){return"password"===n.provider})),M=c.filter((function(n){return"password"!==n.provider}));return S(b,{children:[x(v,{children:"Sign In"}),x(h,{children:S(m,{container:!0,direction:"column",children:[x(f,{"data-not-migrated-MuiChip":!0,label:a,onClick:p}),M.map((function(n){return x(B,{item:!0,children:x(k,{title:n.title,provider:n.provider,connection:n.connection,auth0:T.auth0})},n.title)})),G&&M.length>0&&x(m,{item:!0,children:x(w,{})}),G&&x(B,{item:!0,children:S("form",{id:"sign-in-form",onSubmit:_,children:[x(j,{email:a}),x(d,{value:R,onChange:function(n){E(n.target.value),z(!1)},disabled:T.loading,error:A})]})})]})}),x(g,{needHelpExternalLink:y,children:G&&x(C,{"data-testid":"".concat("AuthorizationPo","_signInButton"),form:"sign-in-form",type:"submit",variant:"contained",color:"primary",disabled:!R||T.loading||!!A,onClick:_,children:"Sign In"})})]})}F.propTypes={email:a.string.isRequired,schemas:a.arrayOf(a.shape({})).isRequired,onBack:a.func.isRequired,onFinishLogin:a.func.isRequired};var T=t(F);export{T as default};
|