mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-04-06 01:25:33 +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 { useEffect, useState } from 'react'
|
||||||
|
|
||||||
import { useSetItemsApi, useSetItemsData } from './hooks/useItems'
|
import { useSetItemsApi, useSetItemsData } from './hooks/useItems'
|
||||||
|
import { usePopupForm } from './hooks/usePopupForm'
|
||||||
import { useAddTag } from './hooks/useTags'
|
import { useAddTag } from './hooks/useTags'
|
||||||
import LayerContext from './LayerContext'
|
import LayerContext from './LayerContext'
|
||||||
|
import { ItemFormPopup } from './Subcomponents/ItemFormPopup'
|
||||||
|
|
||||||
import type { LayerProps } from '#types/LayerProps'
|
import type { LayerProps } from '#types/LayerProps'
|
||||||
import type { Tag } from '#types/Tag'
|
import type { Tag } from '#types/Tag'
|
||||||
@ -42,6 +44,7 @@ export const Layer = ({
|
|||||||
const addTag = useAddTag()
|
const addTag = useAddTag()
|
||||||
const [newTagsToAdd] = useState<Tag[]>([])
|
const [newTagsToAdd] = useState<Tag[]>([])
|
||||||
const [tagsReady] = useState<boolean>(false)
|
const [tagsReady] = useState<boolean>(false)
|
||||||
|
const { popupForm } = usePopupForm()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
data &&
|
data &&
|
||||||
@ -116,6 +119,8 @@ export const Layer = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
{/* Auto-render ItemFormPopup when popupForm matches this layer */}
|
||||||
|
{popupForm && popupForm.layer.name === name && <ItemFormPopup />}
|
||||||
</LayerContext.Provider>
|
</LayerContext.Provider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
import { LatLng } from 'leaflet'
|
||||||
import { useMap } from 'react-leaflet'
|
import { useMap } from 'react-leaflet'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
|
|
||||||
|
import { usePopupForm } from '#components/Map/hooks/usePopupForm'
|
||||||
import { useSetSelectPosition } from '#components/Map/hooks/useSelectPosition'
|
import { useSetSelectPosition } from '#components/Map/hooks/useSelectPosition'
|
||||||
import useWindowDimensions from '#components/Map/hooks/useWindowDimension'
|
import useWindowDimensions from '#components/Map/hooks/useWindowDimension'
|
||||||
import { StartEndView, TextView } from '#components/Map/Subcomponents/ItemPopupComponents'
|
import { StartEndView, TextView } from '#components/Map/Subcomponents/ItemPopupComponents'
|
||||||
@ -25,6 +27,29 @@ export const ItemCard = ({
|
|||||||
const windowDimensions = useWindowDimensions()
|
const windowDimensions = useWindowDimensions()
|
||||||
const map = useMap()
|
const map = useMap()
|
||||||
const setSelectPosition = useSetSelectPosition()
|
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 (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -41,7 +66,7 @@ export const ItemCard = ({
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
item={i}
|
item={i}
|
||||||
api={i.layer?.api}
|
api={i.layer?.api}
|
||||||
editCallback={() => navigate('/edit-item/' + i.id)}
|
editCallback={() => handleEdit()}
|
||||||
setPositionCallback={() => {
|
setPositionCallback={() => {
|
||||||
map.closePopup()
|
map.closePopup()
|
||||||
setSelectPosition(i)
|
setSelectPosition(i)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user