Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react'

import { Box } from '@material-ui/core'
import { Box, Typography } from '@material-ui/core'
import { makeStyles } from '@material-ui/core/styles'

import ArrowBackIcon from '@material-ui/icons/ArrowBack'
Expand Down Expand Up @@ -45,6 +45,10 @@ const useStyles = makeStyles(theme => ({
display: 'none',
},
},
sectionsNum: {
color: 'white',
fontWeight: 'bold'
},
buttonIcon: {
marginLeft: theme.spacing(1),
marginRight: theme.spacing(1),
Expand All @@ -58,6 +62,7 @@ const RegistrationBottomBar = ({
onNext,
errors,
dirty,
sectionsInfo,
}) => {
const classes = useStyles()
const [enabled, setEnabled] = useState(false)
Expand All @@ -77,6 +82,11 @@ const RegistrationBottomBar = ({
</Button>
)}
<Box className={classes.right}>
{sectionsInfo && (
<Typography className={classes.sectionsNum}>
{`${sectionsInfo.activeSection}/${sectionsInfo.sections}`}
</Typography>
)}
<ErrorDisplay errors={errors} />
<Button
className={classes.nextButton}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const useStyles = makeStyles(theme => ({
}))

export default props => {
const { fields, onNext, nextLabel, prevLabel, onPrev, data, isActive } =
const { sectionsInfo, fields, onNext, nextLabel, prevLabel, onPrev, data, isActive } =
props
const { event, registration } = useContext(EventDetailContext)
const userProfile = useSelector(UserSelectors.userProfile)
Expand Down Expand Up @@ -131,6 +131,7 @@ export default props => {
onNext={handleSubmit}
errors={errors}
dirty={dirty}
sectionsInfo={sectionsInfo}
/>,
document.body,
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const useStyles = makeStyles(theme => ({
},
}))

export default ({ section, onNext, nextLabel, onPrev, prevLabel, data }) => {
export default ({ section, sectionsInfo, onNext, nextLabel, onPrev, prevLabel, data }) => {
const classes = useStyles()
const { registration } = useContext(EventDetailContext)
console.log('section', section)
Expand Down Expand Up @@ -194,6 +194,7 @@ export default ({ section, onNext, nextLabel, onPrev, prevLabel, data }) => {
onNext={handleSubmit}
errors={errors}
dirty={dirty}
sectionsInfo={sectionsInfo}
/>,
document.body,
)}
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/pages/_events/slug/register/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ export default RequiresPermission(() => {
isActive={activeStep === index}
section={section}
data={formData}
sectionsInfo={{
sections: sections.length,
activeSection: index + 1,
}}
Comment on lines +335 to +338
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional

Since this object sectionsInfo is passed as a prop for the RegistrationSection component on lin 347, it would be good to write once, and pass the same object to both components, as to avoid differences between both cases

onPrev={setPrevStep}
prevLabel={prevStep ? prevStep.label : null}
onNext={(values, path) => {
Expand All @@ -343,6 +347,10 @@ export default RequiresPermission(() => {
<RegistrationSection
isActive={activeStep === index}
data={formData}
sectionsInfo={{
sections: sections.length,
activeSection: index + 1,
}}
label={section.label}
fields={section.fields}
onPrev={setPrevStep}
Expand Down