-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Regulation Page - Hardcoded data #365
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I vote to rename this accessor to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Kameron-Heyen @zlannin we need to drop the word "regulatory", actually. The use of "regulatory" came from a bit of a misunderstanding. We're getting information on an overylay, which could be regulatory, administrative, etc. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,40 @@ | ||||||
import { | ||||||
RegulationDetails, | ||||||
RegulatoryOverlayInfoListItem, | ||||||
} from "@data-contracts"; | ||||||
import axios from "axios"; | ||||||
|
||||||
// TODO: Wire to API when route is created | ||||||
export const getRegulationDetails = async (areaUuid: string) => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
/*const { data } = await axios.get<RegulationDetails>( | ||||||
`${process.env.REACT_APP_WEBAPI_URL}Regulation/${areaUuid}`, | ||||||
); */ | ||||||
|
||||||
const data = { | ||||||
waDEAreaReportingUuid: "C0o_RUCO356", | ||||||
reportingAreaNativeId: "CO356", | ||||||
waDEReportingAreaName: "WaDE Blank", | ||||||
waDEOverlayAreaType: "Administration", | ||||||
nativeReportingAreaType: "Groundwater Management District", | ||||||
reportingAreaName: "Arikaree", | ||||||
reportingAreaState: "CO", | ||||||
// areaLastUpdated: new Date("08/05/2005"), | ||||||
managingAgencyOrganizationName: "Colorado Division of Water Resources", | ||||||
managingAgencyState: "CO", | ||||||
managingAgencyWebsite: "https://water.state.co.us/", | ||||||
} as RegulationDetails; | ||||||
|
||||||
return data; | ||||||
}; | ||||||
|
||||||
export const getRegulatoryOverlayInfoList = async (areaUuid: string) => { | ||||||
const data = [ | ||||||
{ | ||||||
waDEOverlayUuid: "C0o_RUCO356", | ||||||
overlayNativeId: "WaDE Blank", | ||||||
overlayType: "Groundwater Management District", | ||||||
}, | ||||||
] as RegulatoryOverlayInfoListItem[]; | ||||||
|
||||||
return data; | ||||||
}; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11,12 +11,11 @@ | |||||
padding: 10px; | ||||||
border-bottom: 1px solid $bs-gray-600; | ||||||
} | ||||||
.water-rights-card, .site-card { | ||||||
|
||||||
.water-rights-card, .site-card, .regulation-card { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any reason why we're not just using a |
||||||
.card-header{ | ||||||
font-size: 20px; | ||||||
color: $white; | ||||||
color: $white; | ||||||
padding: 10px; | ||||||
display: flex; | ||||||
align-items: center; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update parent folder from |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { DetailsPage } from "../DetailsPageLayout"; | ||
import RegulationProperties from "./RegulationProperties"; | ||
import RegulationTabs from "./RegulationTabs"; | ||
|
||
//import { useAlerts } from "./hooks/useAlerts"; | ||
|
||
import "./regulation.scss"; | ||
import RegulationMap from "./RegulationMap"; | ||
|
||
export function Layout() { | ||
// useAlerts(); // TODO: Wire up / for the popup alerts for loading/errors | ||
return ( | ||
<DetailsPage> | ||
<DetailsPage.Header>Overlay Landing Page</DetailsPage.Header> | ||
<DetailsPage.Properties> | ||
<RegulationProperties /> | ||
</DetailsPage.Properties> | ||
<DetailsPage.Map> | ||
<RegulationMap /> | ||
</DetailsPage.Map> | ||
<DetailsPage.Tabs> | ||
<RegulationTabs /> | ||
</DetailsPage.Tabs> | ||
</DetailsPage> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,93 @@ | ||||||||||||||
import { useParams } from "react-router-dom"; | ||||||||||||||
import { createContext, FC, useContext, useState } from "react"; | ||||||||||||||
import { UseQueryResult } from "react-query"; | ||||||||||||||
import { FeatureCollection, GeoJsonProperties, Geometry } from "geojson"; | ||||||||||||||
import { | ||||||||||||||
useWaterRightSiteLocations, | ||||||||||||||
useRegulationDetails, | ||||||||||||||
useWaterRightInfoList, | ||||||||||||||
useRegulatoryOverlayInfoList, | ||||||||||||||
} from "../../../hooks/queries"; | ||||||||||||||
import { | ||||||||||||||
RegulationDetails, | ||||||||||||||
RegulatoryOverlayInfoListItem, | ||||||||||||||
WaterRightInfoListItem, | ||||||||||||||
} from "@data-contracts"; | ||||||||||||||
|
||||||||||||||
type Query<T> = Pick< | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. opportunity for a shared type? |
||||||||||||||
UseQueryResult<T, unknown>, | ||||||||||||||
"data" | "isError" | "isLoading" | ||||||||||||||
>; | ||||||||||||||
|
||||||||||||||
const defaultQuery = { data: undefined, isError: false, isLoading: false }; | ||||||||||||||
|
||||||||||||||
export interface HostData { | ||||||||||||||
detailsQuery: Query<RegulationDetails>; | ||||||||||||||
locationsQuery: Query<FeatureCollection<Geometry, GeoJsonProperties>>; | ||||||||||||||
regulatoryOverlayInfoListQuery: Query<RegulatoryOverlayInfoListItem[]>; | ||||||||||||||
waterRightInfoListQuery: Query<WaterRightInfoListItem[]>; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
type ActiveTabType = "right" | "regulatory"; | ||||||||||||||
tarrball marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
|
||||||||||||||
interface RegulationDetailsPageContextState { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
allocationUuid: string | undefined; | ||||||||||||||
activeTab: ActiveTabType; | ||||||||||||||
setActiveTab: (tab: ActiveTabType) => void; | ||||||||||||||
hostData: HostData; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
const defaultState: RegulationDetailsPageContextState = { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
allocationUuid: undefined, | ||||||||||||||
activeTab: "regulatory", | ||||||||||||||
setActiveTab: () => {}, | ||||||||||||||
hostData: { | ||||||||||||||
detailsQuery: defaultQuery, | ||||||||||||||
locationsQuery: defaultQuery, | ||||||||||||||
regulatoryOverlayInfoListQuery: defaultQuery, | ||||||||||||||
waterRightInfoListQuery: defaultQuery, | ||||||||||||||
}, | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
const RegulationDetailsContext = | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
createContext<RegulationDetailsPageContextState>(defaultState); | ||||||||||||||
export const useRegulationDetailsContext = () => | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
useContext(RegulationDetailsContext); | ||||||||||||||
|
||||||||||||||
export const RegulationDetailsProvider: FC = ({ children }) => { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
const { id: areaUuid } = useParams(); | ||||||||||||||
|
||||||||||||||
const [activeTab, setActiveTab] = useState<ActiveTabType>( | ||||||||||||||
defaultState.activeTab, | ||||||||||||||
); | ||||||||||||||
|
||||||||||||||
const detailsQuery = useRegulationDetails(areaUuid); | ||||||||||||||
const regulationLocationsQuery = useWaterRightSiteLocations(areaUuid); // TODO: Create a hook for RegulatoryOverlay | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
const regulatoryOverlayInfoListQuery = useRegulatoryOverlayInfoList( | ||||||||||||||
areaUuid, | ||||||||||||||
{ | ||||||||||||||
enabled: activeTab === "regulatory", | ||||||||||||||
}, | ||||||||||||||
); | ||||||||||||||
const waterRightInfoListQuery = useWaterRightInfoList(areaUuid, { | ||||||||||||||
enabled: activeTab === "right", | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
const filterContextProviderValue: RegulationDetailsPageContextState = { | ||||||||||||||
allocationUuid: areaUuid, | ||||||||||||||
activeTab, | ||||||||||||||
setActiveTab, | ||||||||||||||
hostData: { | ||||||||||||||
detailsQuery: detailsQuery, | ||||||||||||||
locationsQuery: regulationLocationsQuery, | ||||||||||||||
regulatoryOverlayInfoListQuery: regulatoryOverlayInfoListQuery, | ||||||||||||||
waterRightInfoListQuery: waterRightInfoListQuery, | ||||||||||||||
}, | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
return ( | ||||||||||||||
<RegulationDetailsContext.Provider value={filterContextProviderValue}> | ||||||||||||||
{children} | ||||||||||||||
</RegulationDetailsContext.Provider> | ||||||||||||||
Comment on lines
+89
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
); | ||||||||||||||
}; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,27 @@ | ||||||||||
import useSiteDigestMapPopup from "../../../hooks/map-popups/useSiteDigestMapPopup"; | ||||||||||
import DetailsMap from "../DetailsMap"; | ||||||||||
import { useRegulationDetailsContext } from "./Provider"; | ||||||||||
import MapProvider from "../../../contexts/MapProvider"; | ||||||||||
import { useMapLegend } from "./hooks/useMapLegend"; | ||||||||||
|
||||||||||
function RegulationMap() { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
return ( | ||||||||||
<MapProvider> | ||||||||||
<Layout /> | ||||||||||
</MapProvider> | ||||||||||
); | ||||||||||
} | ||||||||||
|
||||||||||
function Layout() { | ||||||||||
const { | ||||||||||
hostData: { locationsQuery }, | ||||||||||
} = useRegulationDetailsContext(); | ||||||||||
|
||||||||||
useSiteDigestMapPopup(); | ||||||||||
useMapLegend(); | ||||||||||
|
||||||||||
if (locationsQuery.isLoading || !locationsQuery.data) return null; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO you should always avoid these types of one liners. It's tougher to see that this is a function exit/jump (a return, a throw, a break, a continue) at a glance, and it's harder to get a breakpoint in there if you ever want to step through. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
return <DetailsMap mapData={locationsQuery.data} />; | ||||||||||
} | ||||||||||
|
||||||||||
export default RegulationMap; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,99 @@ | ||||||
import { Card, Col, Row } from "react-bootstrap"; | ||||||
import Domain from "mdi-react/DomainIcon"; | ||||||
import HexagonOutlineIcon from "mdi-react/HexagonOutlineIcon"; | ||||||
|
||||||
import { PropertyValue } from "../PropertyValue"; | ||||||
|
||||||
import { useRegulationDetailsContext } from "./Provider"; | ||||||
|
||||||
function RegulationProperties() { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const { | ||||||
hostData: { | ||||||
detailsQuery: { data: regulationDetails }, | ||||||
}, | ||||||
} = useRegulationDetailsContext(); | ||||||
|
||||||
return ( | ||||||
<div> | ||||||
{regulationDetails && ( | ||||||
<Row className="pt-2"> | ||||||
<Row className="pt-2"> | ||||||
<Col> | ||||||
<Card className="regulation-card h-100 shadow-sm rounded-3"> | ||||||
<Card.Header> | ||||||
<HexagonOutlineIcon className="rotate-90" /> | ||||||
<span>Reporting Area Information</span> | ||||||
</Card.Header> | ||||||
<Card.Body> | ||||||
<div className="d-flex p-2 flex-column"> | ||||||
<PropertyValue | ||||||
label="WaDE Area Reporting UUID" | ||||||
value={regulationDetails.waDEAreaReportingUuid} | ||||||
/> | ||||||
<PropertyValue | ||||||
label="Reporting Area Native ID" | ||||||
value={regulationDetails.reportingAreaNativeId} | ||||||
/> | ||||||
<PropertyValue | ||||||
label="WaDE Reporting Area Name" | ||||||
value={regulationDetails.waDEReportingAreaName} | ||||||
/> | ||||||
<PropertyValue | ||||||
label="WaDE Overlay Area Type" | ||||||
value={regulationDetails.waDEOverlayAreaType} | ||||||
/> | ||||||
<PropertyValue | ||||||
label="Native Reporting Area Type" | ||||||
value={regulationDetails.nativeReportingAreaType} | ||||||
/> | ||||||
<PropertyValue | ||||||
label="Reporting Area Name" | ||||||
value={regulationDetails.reportingAreaName} | ||||||
/> | ||||||
<PropertyValue | ||||||
label="State" | ||||||
value={regulationDetails.reportingAreaState} | ||||||
/> | ||||||
<PropertyValue | ||||||
label="Area Last Updated Date" | ||||||
value={regulationDetails.areaLastUpdated} | ||||||
/> | ||||||
</div> | ||||||
</Card.Body> | ||||||
</Card> | ||||||
</Col> | ||||||
</Row> | ||||||
<Row className="pt-2"> | ||||||
<Col> | ||||||
<Card className="regulation-card h-100 shadow-sm rounded-3"> | ||||||
<Card.Header> | ||||||
<Domain /> | ||||||
<span>Managing Agency</span> | ||||||
</Card.Header> | ||||||
<Card.Body> | ||||||
<div className="d-flex p-2 flex-column"> | ||||||
<PropertyValue | ||||||
label="Organization Name" | ||||||
value={regulationDetails.managingAgencyOrganizationName} | ||||||
/> | ||||||
<PropertyValue | ||||||
label="State" | ||||||
value={regulationDetails.managingAgencyState} | ||||||
/> | ||||||
<PropertyValue | ||||||
label="Website" | ||||||
value={regulationDetails.managingAgencyWebsite} | ||||||
isUrl={true} | ||||||
/> | ||||||
</div> | ||||||
</Card.Body> | ||||||
</Card> | ||||||
</Col> | ||||||
</Row> | ||||||
</Row> | ||||||
)} | ||||||
</div> | ||||||
); | ||||||
} | ||||||
|
||||||
export default RegulationProperties; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.