var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ResetPasswordConfirm=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireDefault(require("react"));var _native=require("@react-navigation/native");var _reactNativePaper=require("react-native-paper");var _reactNative=require("react-native");var _CreatePassword=require("./CreatePassword");var _reactNativeKeyboardAwareScrollView=require("react-native-keyboard-aware-scroll-view");var _Spinner=require("../components/Spinner");var _SimpleDialog=require("../components/SimpleDialog");var _ToggleButton=require("../components/ToggleButton");var _reactAuthShared=require("@brightlayer-ui/react-auth-shared");var _CloseHeader=require("../components/CloseHeader");var _jsxFileName="/home/circleci/login-workflow/login-workflow/src/subScreens/ResetPasswordConfirm.tsx";var makeContainerStyles=function makeContainerStyles(theme){return _reactNative.StyleSheet.create({safeContainer:{flex:1,backgroundColor:theme.colors.surface},mainContainer:{flex:1},containerMargins:{marginHorizontal:16},spaceBetween:{flexGrow:1,justifyContent:'space-between'},bottomButton:{backgroundColor:theme.colors.surface,paddingTop:8}});};var makeStyles=function makeStyles(){return _reactNative.StyleSheet.create({bottomButton:{marginBottom:8}});};_reactNative.LogBox.ignoreLogs(['Non-serializable values were found in the navigation state']);var ResetPasswordConfirm=function ResetPasswordConfirm(props){var theme=(0,_reactNativePaper.useTheme)(props.theme);var _React$useState=_react.default.useState(''),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),password=_React$useState2[0],setPassword=_React$useState2[1];var _React$useState3=_react.default.useState(false),_React$useState4=(0,_slicedToArray2.default)(_React$useState3,2),hasAcknowledgedError=_React$useState4[0],setHasAcknowledgedError=_React$useState4[1];var _useLanguageLocale=(0,_reactAuthShared.useLanguageLocale)(),t=_useLanguageLocale.t;var authUIState=(0,_reactAuthShared.useAccountUIState)();var route=(0,_native.useRoute)();var navigation=(0,_native.useNavigation)();var routeParams=route.params;var containerStyles=makeContainerStyles(theme);var styles=makeStyles();var setPasswordTransit=authUIState.setPassword.setPasswordTransit;var setPasswordIsInTransit=setPasswordTransit.transitInProgress;var setPasswordHasTransitError=setPasswordTransit.transitErrorMessage!==null;var setPasswordTransitErrorMessage=setPasswordTransit.transitErrorMessage;var onResetPasswordTap=function onResetPasswordTap(){setHasAcknowledgedError(false);routeParams.onResetPasswordPress(password);};var spinner=setPasswordIsInTransit?_react.default.createElement(_Spinner.Spinner,{__source:{fileName:_jsxFileName,lineNumber:115,columnNumber:46}}):_react.default.createElement(_react.default.Fragment,null);var canProgress=function canProgress(){return password.length>0;};var errorDialog=_react.default.createElement(_SimpleDialog.SimpleDialog,{title:t('blui:MESSAGES.ERROR'),bodyText:t(setPasswordTransitErrorMessage!==null&&setPasswordTransitErrorMessage!==void 0?setPasswordTransitErrorMessage:''),visible:setPasswordHasTransitError&&!hasAcknowledgedError,onDismiss:function onDismiss(){setHasAcknowledgedError(true);},__source:{fileName:_jsxFileName,lineNumber:118,columnNumber:9}});return _react.default.createElement(_reactNative.View,{style:{height:'100%'},__source:{fileName:_jsxFileName,lineNumber:128,columnNumber:9}},spinner,errorDialog,_react.default.createElement(_CloseHeader.CloseHeader,{title:t('blui:FORMS.RESET_PASSWORD'),backAction:function backAction(){return navigation.navigate('Login');},__source:{fileName:_jsxFileName,lineNumber:131,columnNumber:13}}),_react.default.createElement(_reactNative.SafeAreaView,{style:containerStyles.safeContainer,__source:{fileName:_jsxFileName,lineNumber:136,columnNumber:13}},_react.default.createElement(_reactNativeKeyboardAwareScrollView.KeyboardAwareScrollView,{__source:{fileName:_jsxFileName,lineNumber:137,columnNumber:17}},_react.default.createElement(_CreatePassword.CreatePassword,{onPasswordChanged:setPassword,onSubmit:canProgress()?onResetPasswordTap:undefined,__source:{fileName:_jsxFileName,lineNumber:138,columnNumber:21}})),_react.default.createElement(_reactNative.View,{style:containerStyles.bottomButton,__source:{fileName:_jsxFileName,lineNumber:144,columnNumber:17}},_react.default.createElement(_reactNative.View,{style:[containerStyles.containerMargins],__source:{fileName:_jsxFileName,lineNumber:145,columnNumber:21}},_react.default.createElement(_ToggleButton.ToggleButton,{text:t('blui:FORMS.RESET_PASSWORD'),disabled:!canProgress(),style:styles.bottomButton,onPress:onResetPasswordTap,__source:{fileName:_jsxFileName,lineNumber:146,columnNumber:25}})))));};exports.ResetPasswordConfirm=ResetPasswordConfirm;
//# sourceMappingURL=ResetPasswordConfirm.js.map