diff --git a/frontend/src/app/components/common/Collapsible.tsx b/frontend/src/app/components/common/Collapsible.tsx index fb71d38e..e906e970 100644 --- a/frontend/src/app/components/common/Collapsible.tsx +++ b/frontend/src/app/components/common/Collapsible.tsx @@ -1,32 +1,45 @@ -import React, { useState, FC } from 'react'; +import React, { FC, useState, useEffect } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { IconProp } from '@fortawesome/fontawesome-svg-core'; import { faPlus, faMinus } from '@fortawesome/fontawesome-free-solid'; +import '../../content/pages/documentpreview/DocumentPreview.scss'; interface CollapsibleProps { title: string; children: React.ReactNode; + isOpen: boolean; } -const Collapsible: FC = ({ title, children }) => { - const [isOpen, setIsOpen] = useState(false); +const Collapsible: FC = ({ title, children, isOpen }) => { + const [isOpenonClick, setIsOpenOnClick] = useState(isOpen); + const icon = isOpenonClick ? faMinus : (faPlus as IconProp); - const toggleCollapsible = () => { - setIsOpen(!isOpen); + const contentStyle = { + display: isOpenonClick ? 'block' : 'none', }; - const icon = isOpen ? faMinus : (faPlus as IconProp); - - const contentStyle = { - display: isOpen ? 'block' : 'none', + const toggleCollapsibleOnClick = () => { + setIsOpenOnClick(!isOpenonClick); }; + useEffect(() => { + setIsOpenOnClick(isOpen); + }, [isOpen]); + return (
-
- -
{title}
+
+ +
+ {title} +
+ +
{children}
); diff --git a/frontend/src/app/content/pages/IndexPage.tsx b/frontend/src/app/content/pages/IndexPage.tsx index b838ee14..315dc0a0 100644 --- a/frontend/src/app/content/pages/IndexPage.tsx +++ b/frontend/src/app/content/pages/IndexPage.tsx @@ -15,48 +15,46 @@ export interface IndexPageProps { } const IndexPage: FC = ({ data }) => { - const { dtid } = useParams<{ dtid: string }>(); - const dtidNumber = dtid ? parseInt(dtid, 10) : null; - const generateReportHandler = () => { - if (dtidNumber) { - // generateReportNew(dtidNumber, data!.fileNum, 'Land Use Report'); - } - }; - - return ( - <> -
Preview - Land Use Report (Draft)
-
- -
-
DTID:
-
- {data.dtid} -
-
-
-
Tenure File Number:
-
- {data.fileNum} -
-
-
-
Primary Contact Name:
-
{data.primaryContactName}
-
- - - - - - - - - - - - - ); + // const { dtid } = useParams<{ dtid: string }>(); + // const dtidNumber = dtid ? parseInt(dtid, 10) : null; + // const generateReportHandler = () => { + // if (dtidNumber) { + // // generateReportNew(dtidNumber, data!.fileNum, 'Land Use Report'); + // } + // }; + // return ( + // <> + //
Preview - Land Use Report (Draft)
+ //
+ //
+ //
DTID:
+ //
+ // {data.dtid} + //
+ //
+ //
+ //
Tenure File Number:
+ //
+ // {data.fileNum} + //
+ //
+ //
+ //
Primary Contact Name:
+ //
{data.primaryContactName}
+ //
+ // + // + // + // + // + // + // + // + // + // + // + // ); + return <>; }; export default IndexPage; diff --git a/frontend/src/app/content/pages/LandingPage.tsx b/frontend/src/app/content/pages/LandingPage.tsx index ff651fa2..9e957477 100644 --- a/frontend/src/app/content/pages/LandingPage.tsx +++ b/frontend/src/app/content/pages/LandingPage.tsx @@ -25,14 +25,14 @@ import { ProvisionJson, SaveProvisionData } from '../../components/table/reports import VariablesTable, { SaveVariableData, VariableJson } from '../../components/table/reports/VariablesTable'; import { Alert, Button, Row } from 'react-bootstrap'; import { getDocumentTypes } from '../../common/manage-doc-types'; -import { getVariables, getVariablesByDocType } from '../../common/manage-provisions'; +import { getVariablesByDocType } from '../../common/manage-provisions'; import { useDispatch, useSelector } from 'react-redux'; import { setProvisionDataObjects, setSelectedProvisionIds } from '../../store/reducers/provisionSlice'; import { setSelectedVariableIds, setVariables } from '../../store/reducers/variableSlice'; import { RootState } from '../../store/store'; import { setSearchState } from '../../store/reducers/searchSlice'; import { useParams } from 'react-router-dom'; -import CustomCollapsible from './documentpreview/CustomCollapsible'; +// import Collapsible from './documentpreview/Collapsible'; const LandingPage: FC = () => { const { dtidNumber, docTypeFromUrl } = useParams(); @@ -190,8 +190,10 @@ const LandingPage: FC = () => { setDtid(dtidValue); // Fetch any existing documentData const displayData: { dtr: DTRDisplayObject | null; error: string | null } = await getDisplayData(dtidValue); - if (!displayData.error) setData(displayData.dtr); - else { + if (!displayData.error) { + setData(displayData.dtr); + setIsOpen(true); + } else { setError(displayData.error); setShowError(true); } @@ -275,7 +277,6 @@ const LandingPage: FC = () => { setIsOpen(false); setSelectedDocTypeId(null); }; - const toggleCollapsible = () => setIsOpen(!isOpen); const getReportData = () => { const selectedProvisions = provisions.filter((provision) => selectedProvisionIds.includes(provision.provision_id)); @@ -381,30 +382,15 @@ const LandingPage: FC = () => {
Primary Contact Name:
{data?.primaryContactName}
- + {data ? : } - - + + {data ? : } - - + + {data ? : } - +

Create Document

@@ -430,11 +416,11 @@ const LandingPage: FC = () => { {provisionGroups && dtid && documentType ? ( <> - + - +