@@ -5,9 +5,8 @@ import Loader from '@components/ui/Loader';
55import { formatNumber } from "@utils/formatUtils" ;
66import { MillesimeDisplay } from "@components/features/ocsge/MillesimeDisplay" ;
77import { LandMillesimeTable } from "@components/features/ocsge/LandMillesimeTable" ;
8- import { Millesime , MillesimeByIndex } from "@services/types/land" ;
8+ import { LandDetailResultType , Millesime , MillesimeByIndex } from "@services/types/land" ;
99import { useArtificialisation } from "@hooks/useArtificialisation" ;
10- import { ProjectDetailResultType } from "@services/types/project" ;
1110
1211/*
1312Ce composant est un composant hybride qui permet de récupérer du contenu côté serveur via Django et de l'intégrer directement dans l'interface React.
@@ -39,17 +38,11 @@ interface UrlsType {
3938}
4039
4140const ArtificialisationSection : React . FC < {
42- data : ArtificialisationData ;
4341 urls : UrlsType ;
44- } > = ( { data, urls } ) => {
45- const { landArtifStockIndex, isLoading, error } = useArtificialisation ( {
46- projectData : {
47- land_type : data . land_type ,
48- land_id : data . land_id
49- } as ProjectDetailResultType ,
50- landData : {
51- millesimes_by_index : data . millesimes_by_index
52- } as any
42+ landData : LandDetailResultType ;
43+ } > = ( { landData, urls } ) => {
44+ const { landArtifStockIndex : data , isLoading, error } = useArtificialisation ( {
45+ landData
5346 } ) ;
5447
5548 if ( isLoading ) return < Loader /> ;
@@ -66,8 +59,8 @@ const ArtificialisationSection: React.FC<{
6659 Surface artificialisée
6760 { " " }
6861 < MillesimeDisplay
69- is_interdepartemental = { data . is_interdepartemental }
70- landArtifStockIndex = { landArtifStockIndex }
62+ is_interdepartemental = { landData . is_interdepartemental }
63+ landArtifStockIndex = { data }
7164 />
7265 </ p >
7366 < span className = { `fr-badge ${
@@ -86,8 +79,8 @@ const ArtificialisationSection: React.FC<{
8679 ) }
8780 </ span >
8881 < MillesimeDisplay
89- is_interdepartemental = { data . is_interdepartemental }
90- landArtifStockIndex = { landArtifStockIndex }
82+ is_interdepartemental = { landData . is_interdepartemental }
83+ landArtifStockIndex = { data }
9184 between = { true }
9285 className = "fr-text--sm fr-ml-1w"
9386 />
@@ -103,9 +96,9 @@ const ArtificialisationSection: React.FC<{
10396
10497 < div className = "fr-my-3w" >
10598 < LandMillesimeTable
106- millesimes = { data . millesimes }
107- territory_name = { data . territory_name }
108- is_interdepartemental = { data . is_interdepartemental }
99+ millesimes = { landData . millesimes }
100+ territory_name = { landData . name }
101+ is_interdepartemental = { landData . is_interdepartemental }
109102 />
110103 </ div >
111104
@@ -117,8 +110,8 @@ const ArtificialisationSection: React.FC<{
117110const Synthese : React . FC < {
118111 endpoint : string ;
119112 urls : UrlsType ;
120- artificialisationData ?: ArtificialisationData
121- } > = ( { endpoint, urls, artificialisationData } ) => {
113+ landData ?: LandDetailResultType ;
114+ } > = ( { endpoint, urls, landData } ) => {
122115 const { content, isLoading, error } = useHtmlLoader ( endpoint ) ;
123116
124117 if ( isLoading ) return < Loader /> ;
@@ -131,7 +124,7 @@ const Synthese: React.FC<{
131124 < div dangerouslySetInnerHTML = { { __html : content } } />
132125 </ div >
133126 </ div >
134- { artificialisationData && < ArtificialisationSection data = { artificialisationData } urls = { urls } /> }
127+ { landData ?. has_ocsge && < ArtificialisationSection landData = { landData } urls = { urls } /> }
135128 </ div >
136129 ) ;
137130} ;
0 commit comments