@rocket.chat/onboarding-ui
Version:
Set of components and functions for the onboarding experience on Rocket.Chat
25 lines • 2.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const fuselage_1 = require("@rocket.chat/fuselage");
const layout_1 = require("@rocket.chat/layout");
const react_hook_form_1 = require("react-hook-form");
const react_i18next_1 = require("react-i18next");
const CreateNewPassword = ({ onSubmit, validatePassword, validatePasswordConfirmation, initialValues, }) => {
const { t } = (0, react_i18next_1.useTranslation)();
const { register, handleSubmit, formState: { isValidating, isSubmitting, isValid, errors }, } = (0, react_hook_form_1.useForm)({
mode: 'onChange',
defaultValues: {
...initialValues,
},
});
return ((0, jsx_runtime_1.jsxs)(layout_1.Form, { onSubmit: handleSubmit(onSubmit), children: [(0, jsx_runtime_1.jsx)(layout_1.Form.Container, { children: (0, jsx_runtime_1.jsxs)(fuselage_1.FieldGroup, { children: [(0, jsx_runtime_1.jsxs)(fuselage_1.Field, { children: [(0, jsx_runtime_1.jsx)(fuselage_1.FieldLabel, { children: t('form.createPasswordForm.fields.password.label') }), (0, jsx_runtime_1.jsx)(fuselage_1.FieldRow, { children: (0, jsx_runtime_1.jsx)(fuselage_1.PasswordInput, { ...register('password', {
validate: validatePassword,
required: true,
}), placeholder: t('form.createPasswordForm.fields.password.placeholder') }) }), errors.password && ((0, jsx_runtime_1.jsx)(fuselage_1.FieldError, { children: errors.password.message }))] }), (0, jsx_runtime_1.jsxs)(fuselage_1.Field, { children: [(0, jsx_runtime_1.jsx)(fuselage_1.FieldLabel, { children: t('form.createPasswordForm.fields.confirmPassword.label') }), (0, jsx_runtime_1.jsx)(fuselage_1.FieldRow, { children: (0, jsx_runtime_1.jsx)(fuselage_1.PasswordInput, { ...register('passwordConfirmation', {
validate: validatePasswordConfirmation,
required: true,
}), placeholder: t('form.createPasswordForm.fields.confirmPassword.placeholder') }) }), errors.passwordConfirmation && ((0, jsx_runtime_1.jsx)(fuselage_1.FieldError, { children: errors.passwordConfirmation.message }))] })] }) }), (0, jsx_runtime_1.jsx)(layout_1.Form.Footer, { children: (0, jsx_runtime_1.jsx)(fuselage_1.ButtonGroup, { children: (0, jsx_runtime_1.jsx)(fuselage_1.Button, { type: 'submit', primary: true, loading: isValidating || isSubmitting, disabled: !isValid, children: t('form.createPasswordForm.button.text') }) }) })] }));
};
exports.default = CreateNewPassword;
//# sourceMappingURL=CreateNewPassword.js.map