From 659efc0d5e6c34b62f1c892d8c737dde1ec95c4a Mon Sep 17 00:00:00 2001 From: Anton Tranelis <31516529+antontranelis@users.noreply.github.com> Date: Sun, 7 Sep 2025 13:42:29 +0200 Subject: [PATCH] fix(lib): adjust index page for external profiles (#361) * don't open internal profile, if item has external profile url * refactor(backend): simplified icon config (#359) * simplified icon config * fixed linting * fixed linting * fix linting and searchControl * adjust useSelectPosition * adjust useSelectPosition * fixed presets * removed menuIcon artefacts * fix example * adjust icon size in addButton * item index page is now not opening internal profile if external profile exist * fix imports * reset layer * fix behaviour * set map position to popup form --- app/src/App.tsx | 4 ++-- lib/src/Components/Templates/ItemCard.tsx | 29 ++++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/src/App.tsx b/app/src/App.tsx index fbb525c3..354d216e 100644 --- a/app/src/App.tsx +++ b/app/src/App.tsx @@ -267,14 +267,14 @@ function App() { path='attestation-form' element={} /> - {layers.map((l: any) => ( + {layers.map((l: LayerProps) => ( } diff --git a/lib/src/Components/Templates/ItemCard.tsx b/lib/src/Components/Templates/ItemCard.tsx index e8b5b1f3..2cd4fcf9 100644 --- a/lib/src/Components/Templates/ItemCard.tsx +++ b/lib/src/Components/Templates/ItemCard.tsx @@ -1,6 +1,8 @@ +import { LatLng } from 'leaflet' import { useMap } from 'react-leaflet' import { useNavigate } from 'react-router-dom' +import { usePopupForm } from '#components/Map/hooks/usePopupForm' import { useSetSelectPosition } from '#components/Map/hooks/useSelectPosition' import useWindowDimensions from '#components/Map/hooks/useWindowDimension' import { StartEndView, TextView } from '#components/Map/Subcomponents/ItemPopupComponents' @@ -25,6 +27,31 @@ export const ItemCard = ({ const windowDimensions = useWindowDimensions() const map = useMap() const setSelectPosition = useSetSelectPosition() + const { setPopupForm } = usePopupForm() + + const handleEdit = () => { + if (!i.layer) { + throw new Error('Layer is not defined') + } + + if (i.layer.itemType.small_form_edit && i.position) { + navigate('/') + // Wait for navigation to complete before setting popup + setTimeout(() => { + if (i.position && i.layer) { + const position = new LatLng(i.position.coordinates[1], i.position.coordinates[0]) + setPopupForm({ + position, + layer: i.layer, + item: i, + }) + map.setView(position, map.getZoom(), { duration: 1 }) + } + }, 100) + } else { + navigate('/edit-item/' + i.id) + } + } return (
navigate('/edit-item/' + i.id)} + editCallback={() => handleEdit()} setPositionCallback={() => { map.closePopup() setSelectPosition(i)