Skip to content

Commit 0cdf406

Browse files
committed
Modified sectionsInfo to be DRY on register/index
1 parent 3dfa4c9 commit 0cdf406

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

  • frontend/src/pages/_events/slug/register

frontend/src/pages/_events/slug/register/index.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ export default RequiresPermission(() => {
238238
return sorted.concat(event?.customQuestions ?? [])
239239
}, [event])
240240

241+
const sectionsInfo = (sections, index) => {
242+
return {
243+
sections: sections.length,
244+
activeSection: index + 1,
245+
}
246+
}
247+
241248
const setNextStep = useCallback(
242249
(nextStep, values, path) => {
243250
const newFormData = path
@@ -337,10 +344,7 @@ export default RequiresPermission(() => {
337344
isActive={activeStep === index}
338345
section={section}
339346
data={formData}
340-
sectionsInfo={{
341-
sections: sections.length,
342-
activeSection: index + 1,
343-
}}
347+
sectionsInfo={sectionsInfo(sections, index)}
344348
onPrev={setPrevStep}
345349
prevLabel={prevStep ? prevStep.label : null}
346350
onNext={(values, path) => {
@@ -352,10 +356,7 @@ export default RequiresPermission(() => {
352356
<RegistrationSection
353357
isActive={activeStep === index}
354358
data={formData}
355-
sectionsInfo={{
356-
sections: sections.length,
357-
activeSection: index + 1,
358-
}}
359+
sectionsInfo={sectionsInfo(sections, index)}
359360
label={section.label}
360361
fields={section.fields}
361362
onPrev={setPrevStep}

0 commit comments

Comments
 (0)