{"version":3,"file":"PasswordSetNew.mjs","sources":["../../../../../../../../../web/src/ui/b2b/screens/PasswordSetNew.tsx"],"sourcesContent":["import { Trans } from '@lingui/react';\nimport { useLingui } from '@lingui/react/macro';\nimport { StytchEventType } from '@stytch/core/public';\nimport React from 'react';\n\nimport EmailActionLayout from '../../components/molecules/EmailActionLayout';\nimport { useConfig, useEventCallback, useGlobalReducer } from '../GlobalContextProvider';\nimport { AppScreens } from '../types/AppScreens';\nimport { usePasswordInput } from '../usePasswordInput';\n\nexport const PasswordSetNew = () => {\n  const [, dispatch] = useGlobalReducer();\n  const onEvent = useEventCallback();\n  const config = useConfig();\n  const { t } = useLingui();\n\n  const { stytch, onError, email, organization, setIsSubmitting } = usePasswordInput();\n\n  const resendResetPassword = () => {\n    if (!organization) {\n      return stytch.passwords.discovery\n        .resetByEmailStart({\n          email_address: email,\n          discovery_redirect_url: config.passwordOptions?.discoveryRedirectURL,\n          reset_password_redirect_url: config.passwordOptions?.resetPasswordRedirectURL,\n          reset_password_expiration_minutes: config.passwordOptions?.resetPasswordExpirationMinutes,\n          reset_password_template_id: config.passwordOptions?.resetPasswordTemplateId,\n          verify_email_template_id: config.passwordOptions?.verifyEmailTemplateId,\n          locale: config.passwordOptions?.locale,\n        })\n        .then((data) => {\n          setIsSubmitting(false);\n          onEvent({ type: StytchEventType.B2BPasswordDiscoveryResetStart, data });\n        });\n    } else {\n      return stytch.passwords\n        .resetByEmailStart({\n          email_address: email,\n          organization_id: organization.organization_id,\n          login_redirect_url: config.passwordOptions?.loginRedirectURL,\n          reset_password_redirect_url: config.passwordOptions?.resetPasswordRedirectURL,\n          reset_password_expiration_minutes: config.passwordOptions?.resetPasswordExpirationMinutes,\n          reset_password_template_id: config.passwordOptions?.resetPasswordTemplateId,\n          verify_email_template_id: config.passwordOptions?.verifyEmailTemplateId,\n          locale: config.passwordOptions?.locale,\n        })\n        .then((data) => {\n          setIsSubmitting(false);\n          onEvent({ type: StytchEventType.B2BPasswordResetByEmailStart, data });\n        })\n        .catch((e: Error) => {\n          onError(e);\n          throw e;\n        });\n    }\n  };\n\n  return (\n    <EmailActionLayout\n      header={t({ id: 'password.reset.emailSent.title', message: 'Check your email' })}\n      description={\n        <Trans\n          id=\"password.reset.emailSent.content\"\n          message=\"A login link was sent to you at <bold>{email}</bold>.\"\n          components={{ bold: <b /> }}\n          values={{ email }}\n        />\n      }\n      resend={resendResetPassword}\n      goBack={() => dispatch({ type: 'transition', screen: AppScreens.Main })}\n    />\n  );\n};\n"],"names":["PasswordSetNew","dispatch","useGlobalReducer","onEvent","useEventCallback","config","useConfig","useLingui","stytch","onError","email","organization","setIsSubmitting","usePasswordInput","resendResetPassword","passwords","discovery","resetByEmailStart","email_address","discovery_redirect_url","passwordOptions","discoveryRedirectURL","reset_password_redirect_url","resetPasswordRedirectURL","reset_password_expiration_minutes","resetPasswordExpirationMinutes","reset_password_template_id","resetPasswordTemplateId","verify_email_template_id","verifyEmailTemplateId","locale","then","data","type","StytchEventType","B2BPasswordDiscoveryResetStart","organization_id","login_redirect_url","loginRedirectURL","B2BPasswordResetByEmailStart","catch","e","React","EmailActionLayout","header","description","Trans","id","message","components","bold","b","values","resend","goBack","screen","AppScreens","Main"],"mappings":";;;;;;;;MAUaA,cAAAA,GAAiB,IAAA;IAC5B,MAAM,GAAGC,SAAS,GAAGC,gBAAAA,EAAAA;AACrB,IAAA,MAAMC,OAAAA,GAAUC,gBAAAA,EAAAA;AAChB,IAAA,MAAMC,MAAAA,GAASC,SAAAA,EAAAA;AACf,IAAA,MAAM,EAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,GAAA,EAAA,GAAQC,SAAAA,EAAAA;IAEd,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAEC,KAAK,EAAEC,YAAY,EAAEC,eAAe,EAAE,GAAGC,gBAAAA,EAAAA;AAElE,IAAA,MAAMC,mBAAAA,GAAsB,IAAA;AAC1B,QAAA,IAAI,CAACH,YAAAA,EAAc;AACjB,YAAA,OAAOH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