1- import React , { useEffect , useState } from 'react' ;
1+ import React , { useState } from 'react' ;
22import styled from '@emotion/styled' ;
33import { Button } from '@mui/material' ;
44import { t } from '../../services/intl' ;
55import { fetchJson } from '../../services/fetch' ;
66import { useFeatureContext } from '../utils/FeatureContext' ;
7- import { getUrlOsmId } from '../../services/helpers' ;
7+ import { getDetailPageLink } from '../../services/helpers' ;
88import { LonLat } from '../../services/types' ;
99
1010const Spacer = styled . div `
@@ -30,18 +30,9 @@ const getData = async (center: LonLat, osmId: string) => {
3030const OpenPlaceGuideLink = ( ) => {
3131 const [ instances , setInstances ] = useState < Instance [ ] > ( [ ] ) ;
3232 const { feature } = useFeatureContext ( ) ;
33- const osmId = getUrlOsmId ( feature . osmMeta ) ;
34-
35- useEffect ( ( ) => {
36- getData ( feature . center , osmId ) . then ( ( data ) => setInstances ( data ?? [ ] ) ) ;
37- } , [ feature . center , osmId ] ) ;
38-
39- if ( instances . length === 0 ) {
40- return null ;
41- }
4233
4334 const selfInstance = {
44- url : ` ${ window . location . origin } /detail/ ${ osmId } ` ,
35+ url : getDetailPageLink ( feature ) ,
4536 name : 'map.et' ,
4637 } ;
4738
@@ -50,22 +41,7 @@ const OpenPlaceGuideLink = () => {
5041 < Button variant = "contained" href = { selfInstance . url } >
5142 { t ( 'featurepanel.detail_page' ) }
5243 </ Button >
53-
5444 < Spacer />
55- { instances . map ( ( instance ) =>
56- instance . name === selfInstance . name ? (
57- ''
58- ) : (
59- < >
60- < a href = { instance . url } >
61- { t ( 'featurepanel.more_in_openplaceguide' , {
62- instanceName : instance . name ,
63- } ) }
64- </ a >
65- < Spacer />
66- </ >
67- ) ,
68- ) }
6945 </ >
7046 ) ;
7147} ;
0 commit comments