From 0013093d94b7e2ae38210ebaf8494e07c3a2b686 Mon Sep 17 00:00:00 2001 From: Mohammad Sajad Pourajam Date: Wed, 1 Apr 2026 23:02:24 +0330 Subject: [PATCH] UPDATE --- .gitea/workflows/frontend.yml | 2 +- Dockerfile | 5 ++++- .../dashboards/farm/cropZoning/CropZoningMap.tsx | 12 +++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/frontend.yml b/.gitea/workflows/frontend.yml index da8b559..02a942b 100644 --- a/.gitea/workflows/frontend.yml +++ b/.gitea/workflows/frontend.yml @@ -7,7 +7,7 @@ on: - '**' - '.gitea/workflows/frontend.yml' - pull_request: +pull_request: branches: [production] paths: - '**' diff --git a/Dockerfile b/Dockerfile index 12cebee..5f4c735 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,10 @@ FROM base AS deps WORKDIR /app 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 ---- FROM base AS builder diff --git a/src/views/dashboards/farm/cropZoning/CropZoningMap.tsx b/src/views/dashboards/farm/cropZoning/CropZoningMap.tsx index 48bb88c..4c7b1c0 100644 --- a/src/views/dashboards/farm/cropZoning/CropZoningMap.tsx +++ b/src/views/dashboards/farm/cropZoning/CropZoningMap.tsx @@ -1,6 +1,6 @@ 'use client' -import { useEffect, useRef, useCallback } from 'react' +import { useEffect, useRef, useCallback, useState } from 'react' import type L from 'leaflet' import 'leaflet/dist/leaflet.css' import 'leaflet-draw/dist/leaflet.draw.css' @@ -49,6 +49,7 @@ export default function CropZoningMap({ const drawnItemsRef = useRef(null) const drawControlRef = useRef(null) const zonesLayerRef = useRef(null) + const [isMapReady, setIsMapReady] = useState(false) const renderZonesFromApi = useCallback( (map: L.Map, zones: ZoneMapData[]) => { @@ -217,8 +218,10 @@ export default function CropZoningMap({ } mapInstanceRef.current = map + setIsMapReady(true) cleanupFn = () => { + setIsMapReady(false) if (!readOnly) { map.off(L.Draw.Event.CREATED, onCreated) map.off(L.Draw.Event.EDITED, onEdited) @@ -245,14 +248,17 @@ export default function CropZoningMap({ }, []) useEffect(() => { - if (!mapInstanceRef.current) return + if (!isMapReady || !mapInstanceRef.current) return + + mapInstanceRef.current.invalidateSize() + if (zonesData && zonesData.length > 0) { renderZonesFromApi(mapInstanceRef.current, zonesData) } else if (zonesLayerRef.current) { mapInstanceRef.current.removeLayer(zonesLayerRef.current) zonesLayerRef.current = null } - }, [zonesData, optimizationKey, renderZonesFromApi]) + }, [isMapReady, zonesData, optimizationKey, renderZonesFromApi]) return (