Commit 854b9cf4 authored by juminet's avatar juminet

[client/geothermie] add new constraint on out-of-region for issue 48

parent cec1cfb9
import * as io from 'io-ts';
import { ReactNode } from 'react';
import { DIV } from 'sdi/components/elements';
import { getSystem } from '../queries/geothermie';
import tr from 'sdi/locale';
import { markdown } from 'sdi/ports/marked';
import { getSystem, isOutRegion } from '../queries/geothermie';
import renderCarrot from './carrot';
import renderPaginator from './paginator';
import { renderGeoSidebar } from './sidebar';
......@@ -46,17 +48,26 @@ const rectify = rect(r => {
setDiagramHeight(r.height);
});
const renderGeothermie = (...node: ReactNode[]) =>
DIV(
{ className: 'geo-output', ref: rectify },
renderGeoSidebar(),
DIV(
{ className: 'content' },
renderPaginator(),
DIV({ className: 'content--body' }, ...node)
const renderOutRegion = () =>
DIV({ className: 'content' },
DIV({ className: 'content--body' },
markdown(tr.geo('outOfRegion'))
)
);
const renderGeothermie = (...node: ReactNode[]) =>
DIV(
{ className: 'geo-output', ref: rectify },
renderGeoSidebar(),
isOutRegion() ? renderOutRegion() :
DIV(
{ className: 'content' },
renderPaginator(),
DIV({ className: 'content--body' }, ...node)
)
);
export const general = () =>
renderGeothermie(renderDepthTable(), renderCarrot(), renderText());
......@@ -64,23 +75,23 @@ export const license = () =>
renderGeothermie(renderDepthTable(), renderCarrot(), renderText());
export const geology = () =>
getSystem().map(sys => {
if (sys === 'close') {
return renderGeothermie(
renderLeftCloseTable(),
// renderConnect('close-carrot'),
renderCarrot(),
// renderConnect('carrot-conductivity'),
renderRightCloseTable()
);
} else {
return renderGeothermie(
renderLeftOpenTable(),
renderCarrot(),
renderRightOpenTable()
);
}
});
getSystem().map(sys => {
if (sys === 'close') {
return renderGeothermie(
renderLeftCloseTable(),
// renderConnect('close-carrot'),
renderCarrot(),
// renderConnect('carrot-conductivity'),
renderRightCloseTable()
);
} else {
return renderGeothermie(
renderLeftOpenTable(),
renderCarrot(),
renderRightOpenTable()
);
}
});
export const finance = () => renderGeothermie(renderText());
......
......@@ -7,7 +7,8 @@ import {
isConstraintSoil,
isStrictlyConstraintSoil,
getConstraintSoil,
getSystem
getSystem,
getConstraintRegion,
} from '../../queries/geothermie';
import { markdown } from 'sdi/ports/marked';
......@@ -151,18 +152,22 @@ const renderNoConstraints = () =>
);
const render = () =>
DIV(
{ className: 'paginator-text' },
renderConstraintsHeader(),
isConstraintWater()
? DIV({}, renderExclusion())
: isConstraints() // any constraints ?
? getSystem().getOrElse('close') === 'close'
? renderCloseConstraint()
: isConstraintNatura()
? renderOpenNaturaConstraint()
: renderOpenSoilConstraint()
: renderNoConstraints()
);
getConstraintRegion() !== 'in' ?
DIV( {},
markdown(tr.geo('outOfRegionLicense'))
):
DIV(
{ className: 'paginator-text' },
renderConstraintsHeader(),
isConstraintWater()
? DIV({}, renderExclusion())
: isConstraints() // any constraints ?
? getSystem().getOrElse('close') === 'close'
? renderCloseConstraint()
: isConstraintNatura()
? renderOpenNaturaConstraint()
: renderOpenSoilConstraint()
: renderNoConstraints()
);
export default render;
......@@ -1026,6 +1026,16 @@ const messages = {
fr: 'Dévillien (?)',
nl: 'TODO',
en: 'TODO'
},
outOfRegion : {
fr: texts.outOfRegionFR,
nl: ' ',
en: ' '
},
outOfRegionLicense : {
fr: texts.outOfRegionLicenseFR,
nl: ' ',
en: ' '
}
};
......
export const pagGeneralFR = `
Informations
Informations
générales
`;
export const pagGeneralNL = `
Algemene
Algemene
informatie
`;
export const pagLicenseFR = `
Étapes et
Étapes et
démarches
`;
export const pagLicenseNL = `
Aanvraag voor
Aanvraag voor
een vergunning'
`;
export const pagGeologyFR = `
Données
Données
du sous-sol
`;
export const pagGeologyNL = `
`;
export const pagFinanceFR = `
Exemples
Exemples
d'estimations
`;
export const pagFinanceNL = `
......@@ -264,3 +264,7 @@ ___
### Mise en oeuvre
`;
export const outOfRegionFR = 'Vous avez sélectionné un endroit hors de la région Bruxelloise pour lequel les données géologiques sont indisponibles. Nous vous renvoyons vers l\'outil [SmartGeoTherm](https://tool.smartgeotherm.be/geo/alg).';
export const outOfRegionLicenseFR = 'Vous avez sélectionné un endroit hors de la région Bruxelloise. Les démarches à entreprendre sont indépendantes de Bruxelles-Environnement.';
......@@ -74,6 +74,14 @@ export const getConstraintSoil =
c => c.soil
);
export const getConstraintRegion =
() => getDataConstraint().map(c => c.constraints).fold(
'none',
c => c.region
);
export const isOutRegion = () => getConstraintRegion() === 'none';
export const getAddress = () => fromNullable(query('geo/address'));
export const getFormatAddress =
......
......@@ -22,6 +22,8 @@ export const DepthPointIO = io.intersection([
export type DepthPoint = io.TypeOf<typeof DepthPointIO>;
//type RegionIO = io.literal('in')
export const ConstraintPointIO = io.interface({
x: io.Integer,
y: io.Integer,
......@@ -29,6 +31,7 @@ export const ConstraintPointIO = io.interface({
'natura': io.boolean,
'water': io.boolean,
'soil': io.string,
'region': io.string,
})
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment