mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-04-06 01:25:33 +00:00
add select position to item menu on index page
This commit is contained in:
parent
8cef4ab537
commit
3b4346b66c
@ -1,5 +1,13 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
import type { Item } from '#types/Item'
|
||||||
export const SelectPosition = ({ setSelectNewItemPosition }: { setSelectNewItemPosition }) => {
|
import type { LayerProps } from '#types/LayerProps'
|
||||||
|
|
||||||
|
export const SelectPosition = ({
|
||||||
|
setSelectNewItemPosition,
|
||||||
|
selectNewItemPosition,
|
||||||
|
}: {
|
||||||
|
setSelectNewItemPosition: React.Dispatch<React.SetStateAction<Item | LayerProps | null>>
|
||||||
|
selectNewItemPosition?: Item | LayerProps | null
|
||||||
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div className='tw:animate-pulseGrow tw:button tw:z-1000 tw:absolute tw:right-5 tw:top-4 tw:drop-shadow-md'>
|
<div className='tw:animate-pulseGrow tw:button tw:z-1000 tw:absolute tw:right-5 tw:top-4 tw:drop-shadow-md'>
|
||||||
<label
|
<label
|
||||||
@ -12,7 +20,14 @@ export const SelectPosition = ({ setSelectNewItemPosition }: { setSelectNewItemP
|
|||||||
</label>
|
</label>
|
||||||
<div className='tw:alert tw:bg-base-100 tw:text-base-content'>
|
<div className='tw:alert tw:bg-base-100 tw:text-base-content'>
|
||||||
<div>
|
<div>
|
||||||
<span className='tw:text-lg'>Select position on the map!</span>
|
{selectNewItemPosition && 'text' in selectNewItemPosition && (
|
||||||
|
<span className='tw:text-lg'>
|
||||||
|
Select new position of <b>{selectNewItemPosition.name}</b> on the map!
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{selectNewItemPosition && 'menuIcon' in selectNewItemPosition && (
|
||||||
|
<span className='tw:text-lg'>Select position on the map!</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -307,7 +307,10 @@ export function UtopiaMapInner({
|
|||||||
<MapEventListener />
|
<MapEventListener />
|
||||||
<AddButton triggerAction={setSelectNewItemPosition} />
|
<AddButton triggerAction={setSelectNewItemPosition} />
|
||||||
{selectNewItemPosition != null && (
|
{selectNewItemPosition != null && (
|
||||||
<SelectPosition setSelectNewItemPosition={setSelectNewItemPosition} />
|
<SelectPosition
|
||||||
|
selectNewItemPosition={selectNewItemPosition}
|
||||||
|
setSelectNewItemPosition={setSelectNewItemPosition}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
|
import { useMap } from 'react-leaflet'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
|
|
||||||
|
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'
|
||||||
import { HeaderView } from '#components/Map/Subcomponents/ItemPopupComponents/HeaderView'
|
import { HeaderView } from '#components/Map/Subcomponents/ItemPopupComponents/HeaderView'
|
||||||
@ -21,6 +23,8 @@ export const ItemCard = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const windowDimensions = useWindowDimensions()
|
const windowDimensions = useWindowDimensions()
|
||||||
|
const map = useMap()
|
||||||
|
const setSelectPosition = useSetSelectPosition()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -38,6 +42,11 @@ export const ItemCard = ({
|
|||||||
item={i}
|
item={i}
|
||||||
api={i.layer?.api}
|
api={i.layer?.api}
|
||||||
editCallback={() => navigate('/edit-item/' + i.id)}
|
editCallback={() => navigate('/edit-item/' + i.id)}
|
||||||
|
setPositionCallback={() => {
|
||||||
|
map.closePopup()
|
||||||
|
setSelectPosition(i)
|
||||||
|
navigate('/')
|
||||||
|
}}
|
||||||
deleteCallback={() => deleteCallback(i)}
|
deleteCallback={() => deleteCallback(i)}
|
||||||
></HeaderView>
|
></HeaderView>
|
||||||
<div className='tw:overflow-y-auto tw:overflow-x-hidden tw:max-h-64 fade'>
|
<div className='tw:overflow-y-auto tw:overflow-x-hidden tw:max-h-64 fade'>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user