From 9cb65c8d512baade19388421185a657b9e949abf Mon Sep 17 00:00:00 2001 From: Enzo Vezzaro Date: Fri, 15 Apr 2022 06:59:48 -0400 Subject: [PATCH] fix warning code climate (similar blocks) --- src/components/Publish/Actions/index.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/Publish/Actions/index.tsx b/src/components/Publish/Actions/index.tsx index 4c3001938..28e0acd98 100644 --- a/src/components/Publish/Actions/index.tsx +++ b/src/components/Publish/Actions/index.tsx @@ -32,15 +32,23 @@ export default function Actions({ await connect() } + function handleAction(action: string) { + router.push( + `${router.pathname}/?step=${ + parseInt(router.query.step) + (action === 'next' ? +1 : -1) + }` + ) + } + function handleNext(e: FormEvent) { e.preventDefault() - router.push(`${router.pathname}/?step=${parseInt(router.query.step) + 1}`) + handleAction('next') scrollToRef.current.scrollIntoView() } function handlePrevious(e: FormEvent) { e.preventDefault() - router.push(`${router.pathname}/?step=${parseInt(router.query.step) - 1}`) + handleAction('prev') scrollToRef.current.scrollIntoView() }