Skip to content

Commit

Permalink
fix: use origin instead of env var
Browse files Browse the repository at this point in the history
  • Loading branch information
MaGOs92 committed Oct 1, 2024
1 parent 844f354 commit e928056
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/components/DeploiementBAL/DeploiementBALDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useStatsDeploiement } from '@/hooks/useStatsDeploiement'
import { getEpcis } from '@/lib/api-geo'
import { BANStats } from '@/types/api-ban.types'
import { Departement } from '@/types/api-geo.types'
import { useCallback, useState } from 'react'
import { useCallback, useEffect, useState } from 'react'
import Map, { Layer, NavigationControl, Source } from 'react-map-gl/maplibre'
import TabDeploiementBAL from './TabDeploiementBAL'
import { StyledDeploiementBALDashboard } from './DeploiementBALDashboard.styles'
Expand All @@ -29,6 +29,11 @@ export default function DeploiementBALMap({ initialStats, initialFilter, departe
const searchParams = useSearchParams()
const { stats, formatedStats, filter, setFilter, filteredCodesCommmune, geometry } = useStatsDeploiement({ initialStats, initialFilter })
const [selectedTab, setSelectedTab] = useState<'source' | 'bal'>('source')
const [origin, setOrigin] = useState('')

useEffect(() => {
setOrigin(window.location.origin)
}, [])

const handleSearch = useCallback(async (input: string) => {
const filteredEpcis = await getEpcis({ q: input, limit: 10, fields: ['centre', 'contour'] })
Expand Down Expand Up @@ -79,7 +84,7 @@ export default function DeploiementBALMap({ initialStats, initialFilter, departe
>
<NavigationControl showZoom showCompass position="top-right" />
<FullScreenControl position="top-right" />
<Source promoteId="code" id="data" type="vector" tiles={[`${process.env.NEXT_PUBLIC_ADRESSE_URL}/api/deploiement-stats/{z}/{x}/{y}.pbf`]}>
<Source promoteId="code" id="data" type="vector" tiles={[`${origin}/api/deploiement-stats/{z}/{x}/{y}.pbf`]}>
<Layer
id="bal-polygon-fill"
type="fill"
Expand All @@ -106,7 +111,6 @@ export default function DeploiementBALMap({ initialStats, initialFilter, departe
</Map>
</div>
<div className="stats-wrapper">

<Tabs
selectedTabId={selectedTab}
tabs={[
Expand Down
2 changes: 1 addition & 1 deletion src/components/DeploiementBAL/TabDeploiementBAL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function TabDeploiementBAL({ stats, formatedStats, filteredCodesC
const handleDownloadCSV = async () => {
try {
setIsLoadingCSV(true)
const url = new URL(`${process.env.NEXT_PUBLIC_ADRESSE_URL}/api/deploiement-stats`)
const url = new URL(`${window.location.origin}/api/deploiement-stats`)
url.searchParams.append('codesCommune', filteredCodesCommmune.toString())

const csvHeaders = ['code', 'nom', 'nbNumeros', 'certificationPercentage', 'hasBAL', 'nomClient']
Expand Down

0 comments on commit e928056

Please sign in to comment.