UPDATE
This commit is contained in:
@@ -7,7 +7,7 @@ on:
|
|||||||
- '**'
|
- '**'
|
||||||
- '.gitea/workflows/frontend.yml'
|
- '.gitea/workflows/frontend.yml'
|
||||||
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [production]
|
branches: [production]
|
||||||
paths:
|
paths:
|
||||||
- '**'
|
- '**'
|
||||||
|
|||||||
+4
-1
@@ -30,7 +30,10 @@ FROM base AS deps
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm ci --ignore-scripts
|
|
||||||
|
# استفاده از کش داکر برای npm (تغییر اصلی در این بخش انجام شده است)
|
||||||
|
RUN --mount=type=cache,target=/root/.npm \
|
||||||
|
npm ci --ignore-scripts
|
||||||
|
|
||||||
# ---- build stage ----
|
# ---- build stage ----
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useEffect, useRef, useCallback } from 'react'
|
import { useEffect, useRef, useCallback, useState } from 'react'
|
||||||
import type L from 'leaflet'
|
import type L from 'leaflet'
|
||||||
import 'leaflet/dist/leaflet.css'
|
import 'leaflet/dist/leaflet.css'
|
||||||
import 'leaflet-draw/dist/leaflet.draw.css'
|
import 'leaflet-draw/dist/leaflet.draw.css'
|
||||||
@@ -49,6 +49,7 @@ export default function CropZoningMap({
|
|||||||
const drawnItemsRef = useRef<L.FeatureGroup | null>(null)
|
const drawnItemsRef = useRef<L.FeatureGroup | null>(null)
|
||||||
const drawControlRef = useRef<L.Control.Draw | null>(null)
|
const drawControlRef = useRef<L.Control.Draw | null>(null)
|
||||||
const zonesLayerRef = useRef<L.GeoJSON | null>(null)
|
const zonesLayerRef = useRef<L.GeoJSON | null>(null)
|
||||||
|
const [isMapReady, setIsMapReady] = useState(false)
|
||||||
|
|
||||||
const renderZonesFromApi = useCallback(
|
const renderZonesFromApi = useCallback(
|
||||||
(map: L.Map, zones: ZoneMapData[]) => {
|
(map: L.Map, zones: ZoneMapData[]) => {
|
||||||
@@ -217,8 +218,10 @@ export default function CropZoningMap({
|
|||||||
}
|
}
|
||||||
|
|
||||||
mapInstanceRef.current = map
|
mapInstanceRef.current = map
|
||||||
|
setIsMapReady(true)
|
||||||
|
|
||||||
cleanupFn = () => {
|
cleanupFn = () => {
|
||||||
|
setIsMapReady(false)
|
||||||
if (!readOnly) {
|
if (!readOnly) {
|
||||||
map.off(L.Draw.Event.CREATED, onCreated)
|
map.off(L.Draw.Event.CREATED, onCreated)
|
||||||
map.off(L.Draw.Event.EDITED, onEdited)
|
map.off(L.Draw.Event.EDITED, onEdited)
|
||||||
@@ -245,14 +248,17 @@ export default function CropZoningMap({
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mapInstanceRef.current) return
|
if (!isMapReady || !mapInstanceRef.current) return
|
||||||
|
|
||||||
|
mapInstanceRef.current.invalidateSize()
|
||||||
|
|
||||||
if (zonesData && zonesData.length > 0) {
|
if (zonesData && zonesData.length > 0) {
|
||||||
renderZonesFromApi(mapInstanceRef.current, zonesData)
|
renderZonesFromApi(mapInstanceRef.current, zonesData)
|
||||||
} else if (zonesLayerRef.current) {
|
} else if (zonesLayerRef.current) {
|
||||||
mapInstanceRef.current.removeLayer(zonesLayerRef.current)
|
mapInstanceRef.current.removeLayer(zonesLayerRef.current)
|
||||||
zonesLayerRef.current = null
|
zonesLayerRef.current = null
|
||||||
}
|
}
|
||||||
}, [zonesData, optimizationKey, renderZonesFromApi])
|
}, [isMapReady, zonesData, optimizationKey, renderZonesFromApi])
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user