From 878940a6d571073e8e10d304d0691363ce8f2cda Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Thu, 8 Jul 2021 16:22:12 +0100 Subject: [PATCH] initial dynamic forms --- actions/index.js | 36 ++- components/breadcrumbs.js | 25 +- components/elements/index.js | 252 ++++++++++++++++++ components/newappeal/advertapplication.js | 2 +- components/newappeal/buildfield.js | 95 +++++++ components/newappeal/buildrow.js | 39 +++ components/newappeal/buildsection.js | 52 ++++ components/newappeal/enforcementnotice.js | 2 +- components/newappeal/ldc.js | 2 +- components/newappeal/planningappeal.js | 2 +- locales/cy/common.json | 2 +- locales/cy/myportal.json | 4 +- locales/en/common.json | 2 +- .../{pins_dns.js => pinswg_dns.js} | 0 .../{pins_row.js => pinswg_row.js} | 0 pages/myportal/index.js | 2 + .../planningappeals78.js => [appealtypes].js} | 48 ++-- pages/newappeal/index.js | 2 + pages/newappeal/selectappeal.js | 127 +++++++++ pages/searchresults.js | 32 ++- .../javascript/govuk-frontend-3.13.0.min.js | 1 + store/appealType/action.js | 18 ++ store/appealType/reducer.js | 16 ++ store/store.js | 4 +- styles/sass/welshgov/_application.scss | 4 +- 25 files changed, 709 insertions(+), 60 deletions(-) create mode 100644 components/elements/index.js create mode 100644 components/newappeal/buildfield.js create mode 100644 components/newappeal/buildrow.js create mode 100644 components/newappeal/buildsection.js rename pages/api/appealforms/{pins_dns.js => pinswg_dns.js} (100%) rename pages/api/appealforms/{pins_row.js => pinswg_row.js} (100%) rename pages/newappeal/{appealtypes/planningappeals78.js => [appealtypes].js} (75%) create mode 100644 pages/newappeal/selectappeal.js create mode 100644 public/assets/javascript/govuk-frontend-3.13.0.min.js create mode 100644 store/appealType/action.js create mode 100644 store/appealType/reducer.js diff --git a/actions/index.js b/actions/index.js index b1ba846f..0b32ddd4 100644 --- a/actions/index.js +++ b/actions/index.js @@ -43,16 +43,32 @@ export const getBasicSearch = (searchString) => { export const getFormData = (whichForm) => { console.log("got to axios", whichForm); - return axios - .get("http://localhost:3000/api/appealforms/pinswg_dns", { - //.get("http://localhost:3000/api/appealforms/pinswg_planningobligationappeals106", { - //.get("http://localhost:3000/api/appealforms/pinswg_planningconditionss73s79", { - //.get("http://localhost:3000/api/appealforms/pinswg_row", { - //.get("http://localhost:3000/api/appealforms/pinswg_transportandworkact", { - //.get("http://localhost:3000/api/appealforms/pinswg_harbourrevisionorder", { - //.get("http://localhost:3000/api/appealforms/pinswg_planningappeals78", { - //.get("http://localhost:3000/api/appealforms/pinswg_householderappealhas", { - httpsAgent: new https.Agent({ rejectUnauthorized: false }), + return ( + axios + //.get("http://localhost:3000/api/appealforms/pinswg_dns", { + //.get("http://localhost:3000/api/appealforms/pinswg_planningobligationappeals106", { + //.get("http://localhost:3000/api/appealforms/pinswg_planningconditionss73s79", { + //.get("http://localhost:3000/api/appealforms/pinswg_row", { + //.get("http://localhost:3000/api/appealforms/pinswg_transportandworkact", { + //.get("http://localhost:3000/api/appealforms/pinswg_harbourrevisionorder", { + //.get("http://localhost:3000/api/appealforms/pinswg_planningappeals78", { + //.get(http://localhost:3000/api/appealforms/pinswg_householderappealhas", { + .get("http://localhost:3000/api/appealforms/pinswg_" + whichForm, { + httpsAgent: new https.Agent({ rejectUnauthorized: false }), + }) + .then((res) => res.data) + .catch((error) => { + console.log("thiserror", error); + }) + ); +}; + +export const getAppealsTypes = () => { + console.log("got to axios: appeal types"); + + return axios + .get("http://localhost:3000/api/lookups/pinswg_appealcasetype", { + httpsAgent: new https.Agent({ rejectUnauthorized: false }), }) .then((res) => res.data) .catch((error) => { diff --git a/components/breadcrumbs.js b/components/breadcrumbs.js index c85aef7e..6192d47e 100644 --- a/components/breadcrumbs.js +++ b/components/breadcrumbs.js @@ -2,6 +2,7 @@ import Link from "next/link"; import jsonpath from "jsonpath"; import _ from "lodash"; import { useRouter } from "next/router"; +import useTranslation from "next-translate/useTranslation"; const Breadcrumbs = (props) => { const { @@ -14,11 +15,13 @@ const Breadcrumbs = (props) => { applicant_ref, } = props; const router = useRouter(); - const { course, section } = router.query; + const { appealType, section } = router.query; + + let { t } = useTranslation(); function Breadcrumb() { if (slug) { - var coursePageURL = course + "/" + slug; + var coursePageURL = appealType + "/" + slug; if (_.isEmpty(courseContent)) { return null; } else { @@ -43,37 +46,37 @@ const Breadcrumbs = (props) => { return (