Skip to content

Commit

Permalink
add hasPlanningData property to teams.settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Nov 19, 2023
1 parent a706501 commit 8611ec3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,11 @@ function Component(props: Props) {
const wktPolygon: string | undefined =
siteBoundary && stringify(siteBoundary);

// Configure which planx teams should query Digital Land (or continue to use custom GIS) and set URL params accordingly
// In future, Digital Land will theoretically support any UK address and this list won't be necessary, but data collection still limited to select councils!
const digitalLandOrganisations: string[] = [
"opensystemslab", // for UK-wide testing, subject to data availability
"barnet",
"birmingham",
"buckinghamshire",
"canterbury",
"camden",
"doncaster",
"gloucester",
"lambeth",
"medway",
"newcastle",
"southwark",
"st-albans",
];
// Check if this team should query Planning Data (or continue to use custom GIS) and set URL params accordingly
// In future, Planning Data will theoretically support any UK address and this db setting won't be necessary, but data collection still limited to select councils!
const hasPlanningData = useStore(
(state) => state.teamSettings?.hasPlanningData,
);

const digitalLandParams: Record<string, string> = {
geom: wktPolygon || wktPoint,
Expand All @@ -89,9 +77,7 @@ function Component(props: Props) {
const teamGisEndpoint: string =
root +
new URLSearchParams(
digitalLandOrganisations.includes(teamSlug)
? digitalLandParams
: customGisParams,
hasPlanningData ? digitalLandParams : customGisParams,
).toString();

const fetcher: Fetcher<GISResponse | GISResponse["constraints"]> = (
Expand Down Expand Up @@ -119,10 +105,7 @@ function Component(props: Props) {
error: roadsError,
isValidating: isValidatingRoads,
} = useSWR(
() =>
usrn && digitalLandOrganisations.includes(teamSlug)
? classifiedRoadsEndpoint
: null,
() => (usrn && hasPlanningData ? classifiedRoadsEndpoint : null),
fetcher,
{ revalidateOnFocus: false },
);
Expand Down Expand Up @@ -154,7 +137,7 @@ function Component(props: Props) {
const _constraints: Array<
EnhancedGISResponse | GISResponse["constraints"]
> = [];
if (digitalLandOrganisations.includes(teamSlug)) {
if (hasPlanningData) {
if (data && !dataError)
_constraints.push({
...data,
Expand Down
1 change: 1 addition & 0 deletions editor.planx.uk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface TeamSettings {
};
supportEmail?: string;
boundary?: string;
hasPlanningData?: boolean;
}

export interface NotifyPersonalisation {
Expand Down

0 comments on commit 8611ec3

Please sign in to comment.