diff --git a/package.json b/package.json
index 5683ff3d6..92aff8533 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,7 @@
"connected-react-router": "^6.9.2",
"counterpart": "^0.18.6",
"emoji-picker-element": "^1.10.1",
- "formik": "https://gitpkg.now.sh/golos-blockchain/formik/packages/formik?b697b6ef3f13c795bb862b35589fffde442ab465",
+ "formik": "https://gitpkg.now.sh/golos-blockchain/formik/packages/formik?3b21166c33ade760d562091e1fa0b71d172a7aaf",
"git-rev-sync": "^3.0.2",
"golos-lib-js": "^0.9.69",
"history": "4.10.1",
diff --git a/src/components/elements/messages/StartPanel/StartPanel.scss b/src/components/elements/messages/StartPanel/StartPanel.scss
index 63dac7e5a..3e991bd09 100644
--- a/src/components/elements/messages/StartPanel/StartPanel.scss
+++ b/src/components/elements/messages/StartPanel/StartPanel.scss
@@ -1,5 +1,6 @@
.msgs-start-panel {
.button {
display: block;
+ width: 100%;
}
}
diff --git a/src/components/elements/messages/Stepper/Stepper.scss b/src/components/elements/messages/Stepper/Stepper.scss
index fef8b68a6..ea322122e 100644
--- a/src/components/elements/messages/Stepper/Stepper.scss
+++ b/src/components/elements/messages/Stepper/Stepper.scss
@@ -17,6 +17,10 @@
.bar {
background-color: #0078C4;
}
+ cursor: pointer;
+ &:hover {
+ color: #0078C4;
+ }
}
&.current {
color: #0078C4;
diff --git a/src/components/elements/messages/Stepper/index.jsx b/src/components/elements/messages/Stepper/index.jsx
index 39186556f..eced88131 100644
--- a/src/components/elements/messages/Stepper/index.jsx
+++ b/src/components/elements/messages/Stepper/index.jsx
@@ -12,6 +12,17 @@ class Stepper extends React.Component {
}
}
+ _goToStep = (step) => { // TODO: private, if make public - check step exists
+ this.setState({
+ currentStep: step
+ }, () => {
+ const { onStep } = this.props
+ if (onStep) {
+ onStep({ step })
+ }
+ })
+ }
+
nextStep = () => {
const { steps } = this.props
const entr = Object.entries(steps)
@@ -19,9 +30,7 @@ class Stepper extends React.Component {
let found
for (const [key, content] of entr) {
if (found) {
- this.setState({
- currentStep: key
- })
+ this._goToStep(key)
return key
}
found = key === currentStep
@@ -42,7 +51,14 @@ class Stepper extends React.Component {
const isCurrent = key === currentStep
foundCurrent = foundCurrent || isCurrent
const cn = foundCurrent ? (isCurrent ? 'current' : '') : 'left'
- stepObjs.push(
+ let onClick
+ if (!foundCurrent) {
+ onClick = (e) => {
+ e.preventDefault()
+ this._goToStep(key)
+ }
+ }
+ stepObjs.push(
)
diff --git a/src/components/modules/CreateGroup.jsx b/src/components/modules/CreateGroup.jsx
index 16c33654c..b995a6b24 100644
--- a/src/components/modules/CreateGroup.jsx
+++ b/src/components/modules/CreateGroup.jsx
@@ -15,13 +15,15 @@ import LoadingIndicator from 'app/components/elements/LoadingIndicator'
import FormikAgent from 'app/components/elements/donate/FormikUtils'
import Stepper from 'app/components/elements/messages/Stepper'
import GroupName, { validateNameStep } from 'app/components/modules/groups/GroupName'
-import GroupLogo from 'app/components/modules/groups/GroupLogo'
+import GroupLogo, { validateLogoStep } from 'app/components/modules/groups/GroupLogo'
+import GroupAdmin, { validateAdminStep } from 'app/components/modules/groups/GroupAdmin'
+import GroupFinal from 'app/components/modules/groups/GroupFinal'
const STEPS = () => { return {
name: tt('create_group_jsx.step_name'),
logo: tt('create_group_jsx.step_logo'),
admin: tt('create_group_jsx.step_admin'),
- create: tt('create_group_jsx.step_create')
+ final: tt('create_group_jsx.step_create')
} }
class CreateGroup extends React.Component {
@@ -29,6 +31,7 @@ class CreateGroup extends React.Component {
super(props)
this.state = {
step: 'name',
+ validators: 0,
initialValues: {
title: '',
name: '',
@@ -36,6 +39,8 @@ class CreateGroup extends React.Component {
privacy: 'public_group',
logo: '',
+
+ admin: '',
}
}
this.stepperRef = React.createRef()
@@ -81,12 +86,24 @@ class CreateGroup extends React.Component {
}
}
+ setValidating = (validating) => {
+ this.setState({
+ validators: this.state.validators + (validating ? 1 : -1),
+ })
+ }
+
validate = async (values) => {
const errors = {}
const { step } = this.state
+ this.setValidating(true)
if (step === 'name') {
- await validateNameStep(values, errors, (validating) => this.setState({ validating }))
+ await validateNameStep(values, errors)
+ } else if (step === 'logo') {
+ await validateLogoStep(values, errors)
+ } else if (step === 'admin') {
+ await validateAdminStep(values, errors)
}
+ this.setValidating(false)
return errors
}
@@ -96,13 +113,16 @@ class CreateGroup extends React.Component {
goNext = (e, setFieldValue) => {
e.preventDefault()
const step = this.stepperRef.current.nextStep()
+ }
+
+ onStep = ({ step }) => {
this.setState({
step
})
}
render() {
- const { step, loaded, createError, validating } = this.state
+ const { step, loaded, createError, validators } = this.state
let form
if (!loaded) {
@@ -134,20 +154,23 @@ class CreateGroup extends React.Component {
onSubmit={this._onSubmit}
>
{({
- handleSubmit, isSubmitting, isValid, values, setFieldValue, setFieldTouched, handleChange,
+ handleSubmit, isSubmitting, isValid, values, errors, setFieldValue, applyFieldValue, setFieldTouched, handleChange,
}) => {
- const disabled = !isValid || validating
+ const disabled = !isValid || !!validators
return (