From e52dc6f52fdf91d49e4ccc7702e0386bc80728dd Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Thu, 8 Jul 2021 17:17:12 +0100 Subject: [PATCH] pagination between sections --- components/newappeal/buildsection.js | 72 ++++++++++++++++++++-------- pages/newappeal/[appealtypes].js | 6 ++- 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/components/newappeal/buildsection.js b/components/newappeal/buildsection.js index b9708a06..53d7af9a 100644 --- a/components/newappeal/buildsection.js +++ b/components/newappeal/buildsection.js @@ -1,52 +1,86 @@ import Link from "next/link"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; +import { useState, useEffect } from "react"; import xpath from "xpath"; import BuildRow from "./buildrow"; -export default function BuildSection(props) { +const BuildSection = (props) => { + useEffect(() => { + document.title = `You clicked ${currentSection} times`; + window.scrollTo(0, 0); + }); + let { t } = useTranslation(); const router = useRouter(); const { locale } = router; - const { formXML, whichSection, sectionCount } = props; + const { formXML, sectionCount } = props; + const [currentSection, setCurrentSection] = useState(1); const parser = new DOMParser(); var doc = parser.parseFromString(props.formXML, "text/xml"); var titles = xpath.select( - "//form/tabs/tab[" + - (parseInt(whichSection) + 1) + - " ]/labels/label/@description", + "//form/tabs/tab[" + currentSection + " ]/labels/label/@description", doc ); var rowXML = xpath.select( "/form/tabs/tab[" + - (parseInt(whichSection) + 1) + + currentSection + "]/columns//sections/section/rows/row", doc ); + + const handleParam = (setValue) => (e) => setValue(e.target.value); + + const basicSearch = (event) => { + event.preventDefault(); + console.log(query); + // /searchresults + }; + return (
-

- {props.whichSection} - {titles[0].value}{" "} -

+

{titles[0].value}

- + {} +
+ {props.sectionCount != currentSection ? ( + + ) : ( + "" + )} + {currentSection > 1 ? ( + + setCurrentSection(currentSection - 1) + } + > + Back + + ) : ( + "" + )} +
); -} +}; + +export default BuildSection; diff --git a/pages/newappeal/[appealtypes].js b/pages/newappeal/[appealtypes].js index cfb25920..c551b930 100644 --- a/pages/newappeal/[appealtypes].js +++ b/pages/newappeal/[appealtypes].js @@ -80,7 +80,11 @@ const Home = (props) => {
- {Sections} + +