mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-03-01 12:44:17 +00:00
item index page is now not opening internal profile if external profile exist
This commit is contained in:
parent
0f7490aa39
commit
8cac8d72dd
@ -1,8 +1,10 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
import { useSetItemsApi, useSetItemsData } from './hooks/useItems'
|
||||
import { usePopupForm } from './hooks/usePopupForm'
|
||||
import { useAddTag } from './hooks/useTags'
|
||||
import LayerContext from './LayerContext'
|
||||
import { ItemFormPopup } from './Subcomponents/ItemFormPopup'
|
||||
|
||||
import type { LayerProps } from '#types/LayerProps'
|
||||
import type { Tag } from '#types/Tag'
|
||||
@ -42,6 +44,7 @@ export const Layer = ({
|
||||
const addTag = useAddTag()
|
||||
const [newTagsToAdd] = useState<Tag[]>([])
|
||||
const [tagsReady] = useState<boolean>(false)
|
||||
const { popupForm } = usePopupForm()
|
||||
|
||||
useEffect(() => {
|
||||
data &&
|
||||
@ -116,6 +119,8 @@ export const Layer = ({
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
{/* Auto-render ItemFormPopup when popupForm matches this layer */}
|
||||
{popupForm && popupForm.layer.name === name && <ItemFormPopup />}
|
||||
</LayerContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
@ -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,29 @@ 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.custom_profile_url && i.position) {
|
||||
navigate('/')
|
||||
// Wait for navigation to complete before setting popup
|
||||
setTimeout(() => {
|
||||
if (i.position && i.layer) {
|
||||
setPopupForm({
|
||||
position: new LatLng(i.position.coordinates[1], i.position.coordinates[0]),
|
||||
layer: i.layer,
|
||||
item: i,
|
||||
})
|
||||
}
|
||||
}, 100)
|
||||
} else {
|
||||
navigate('/edit-item/' + i.id)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
@ -41,7 +66,7 @@ export const ItemCard = ({
|
||||
loading={loading}
|
||||
item={i}
|
||||
api={i.layer?.api}
|
||||
editCallback={() => navigate('/edit-item/' + i.id)}
|
||||
editCallback={() => handleEdit()}
|
||||
setPositionCallback={() => {
|
||||
map.closePopup()
|
||||
setSelectPosition(i)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user